From 5b818bf276ecd64629ec5955cee81795e16e842e Mon Sep 17 00:00:00 2001 From: Kevin Darby Date: Wed, 29 May 2019 17:43:05 -0400 Subject: [PATCH] test for prorata order --- .../orders/algo/algo_orders/ProRataAlgo.cpp | 1 + testing/manual/algos/pro_rata_controlled.txt | 87 +++++++++++++++++++ testing/manual/algos/scratch_controlled.txt | 9 +- 3 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 testing/manual/algos/pro_rata_controlled.txt diff --git a/src/lib/orderman/orders/algo/algo_orders/ProRataAlgo.cpp b/src/lib/orderman/orders/algo/algo_orders/ProRataAlgo.cpp index 00a39730c..bebd90879 100644 --- a/src/lib/orderman/orders/algo/algo_orders/ProRataAlgo.cpp +++ b/src/lib/orderman/orders/algo/algo_orders/ProRataAlgo.cpp @@ -187,6 +187,7 @@ void ProRataAlgo::scratch(std::pair kk) Price scratch_price; Quantity scratch_quan; SpreaderUtils::traverse_depth_for_quantity(me->last_book, cross_side, kk.second, scratch_price, scratch_quan); + //Quantity scratch_quan = Price(me->book_at_inception.side(other_side)[0].price()) scratch_price = securities::worsen_price(cross_side, scratch_price, me->chase_diff); Update update; diff --git a/testing/manual/algos/pro_rata_controlled.txt b/testing/manual/algos/pro_rata_controlled.txt new file mode 100644 index 000000000..b9ea169e6 --- /dev/null +++ b/testing/manual/algos/pro_rata_controlled.txt @@ -0,0 +1,87 @@ +Test Author: Kevin +If it breaks: Kevin + +When the prorata order is placed, it acts as a slightly more complex hedging algorithm than Cover. +It will: + - Classify each fill as a normal fill or an 'overfill' according to "Fill Limit" parameters + - Standard fills are hedged with the "Hedge" child order + - Over fills are hedge with the "Overfill Hedge" child order + +The prorata order works the child until the Fill Limit is breached. +Once the fill limit is breached, the algo will begin the 'get out process' +Unless: + - If "Enable Stay In" is checked, AND + a) The opposite inside market (at inception) doesn't move against us AND + b) The same side quantity remains ABOVE the "Stay in Threshold" +If "Enable Stay In" is not checked, 'get out process' begins right away + +"Get Out Process" means + 1) Cancel the child order + 2) Scratch the overfill hedges if and only if the "Enable Scratch on Overfill" is checked + -Scratches are done "Chase Ticks" through the original opposite market + + +0. This needs sim market data **not** to be merged with replay (or +cert), so we can create our own markets. Use the following key to set +market data up: + +ExchangeSim { + value { + merge_with_md: false + } +} + +1. Bring up a ladder, lets say in SIM:ESU9 (does not matter which security) + +2. Create the ask side of the market by sending 50 lot sell limit orders at 2833.25 through 2832.25 +(if there are no markets use the M View and the ticket to enter, if you already had left over +orders cancel them) + +2. Create the bid side of the market by sending 50 lot buy limit orders at 2830.75 through 2831.50. +You should have no orders at 2831.50, 2831.75 and 2832. + +Basics: +3. Enter a 20 lot buy prorata order at 2831.50 with the following parameters + + Hedge Ticks = 1 + Chase Ticks = 1 + Fill Limit = Absolute:5 + Stay in Threshold = Absolute:21 + Enable Scratch on Overfill = true + Enable Stay In = true + +Verify that the Prorata order along with the Child order shows up. + +Next put a 50 lot buy limit order on top of your prorata at 2831.50 + + +4) Using 1 lot limit sells, fill 5 of your prorata order. Verify that you see covers going in 1 tick better + +5) Cancel the 50 lot limit at 2831.50. Nothing should happen. Put the 50 lot back. + +6) Fill one more 1 lot. + +7) Again cancel the 50 lot limit at 2831.50. You should see: + - The remainder of the 20 lot should cancel + - 1 lot of your hedges should scratch to sell at 2831.25 + - The parent order should stay in + - You should still be working 5 sales for hedges + +8) Fill the 5 sells, it should cancel the parent. + +9) Repeat 3-8, but this time set Enable Scratch on Overfill = false, Enable Stay In = true + - You should see the same results in 7, except the 1 lot scratch won't happen so you'll still have 6 working hedges + +9) Repeat 3-6, but this time set Enable Scratch on Overfill = false, Enable Stay In = false + - After filling your last lot in 1 you should see your working order cancel, with 6 hedges working + - The ladder may deceive you here, check the OB + - Cancel your hedges, this should cancel the whole chain + +9) Repeat 3-6, but this time set Enable Scratch on Overfill = true, Enable Stay In = false + - After filling your last lot in 1 you should see your working order cancel, one hedge scratch (at 2831.50), and 5 hedges working + - The ladder may deceive you here, check the OB + - Cancel your hedges, this should cancel the whole chain + +10) Repeat all of this on the sell side + + diff --git a/testing/manual/algos/scratch_controlled.txt b/testing/manual/algos/scratch_controlled.txt index 0d8740cb4..e711374a2 100644 --- a/testing/manual/algos/scratch_controlled.txt +++ b/testing/manual/algos/scratch_controlled.txt @@ -27,10 +27,11 @@ You should have no orders at 2831.75 and 2832. Basics: 3. Enter a 20 lot buy scratch order at 2831.50 with the following parameters -Scratch Threshold = Absolute:21 -Max Chase Ticks = 2 -Child = Limit -Verify that the Lean order along with the Child order shows up + Scratch Threshold = Absolute:21 + Max Chase Ticks = 2 + Child = Limit + + Verify that the Scratch order along with the Child order shows up 4) Now cancel the 50 lot sell at 2832.25, you should see the 20 lot scratch pay 2832.50 on 20