new tests and 'find_qty_at_price_level' fixed

This commit is contained in:
Taha Afzal committed 2019-04-30 12:30:04 -04:00
1 parent e84c7d4f8c
commit b6709b426c
3 files changed
+75 -25

No files matched your search

@@ -242,24 +242,22 @@ public:
static bool find_qty_at_price_level (const Book& book,
api::Side book_side,
Price target_price,
double tick_size,
double,
Quantity& price_qty,
Quantity& cumm_qty){
price_qty = Quantity(0); cumm_qty = Quantity(0);
const size_t n_levels = book.n_levels();
const bts::orderman::BookSide& book_depth = book.side(book_side);
for (size_t level = 0; level < n_levels; level++){
const md::PriceSize& level_price_qty = book_depth[level];
double level_price = level_price_qty.price();
const md::PriceSize& level_price_qty = book_depth[level];
double level_price = level_price_qty.price();
price_qty = Quantity(level_price_qty.size());
if(securities::is_better(book_side,target_price,Price(level_price)) ||
price_qty.value()==0)
break;
cumm_qty = Quantity(cumm_qty.value() + price_qty.value());
if (bts::securities::test_price_equality (level_price,
target_price.value(),
tick_size))
return true;
}
price_qty = Quantity(0); cumm_qty = Quantity(0);
return false;
}
return cumm_qty.value()!=0;
}
// returns true if the price (3rd arg)
// crosses into the side (2nd arg) of the
+38
View File
@@ -0,0 +1,38 @@
This is about live updating of algos. This can be done by selecting one or more
working algos from the order book, and changing one or more parameters.
0. This needs sim market data **not** to be merged with replay (or cert), so we can create our own markets.
Also make sure you have limits to trade SI Future
1. Bring up a ladder, lets say in SIN1 (does not matter which security). Create an ask side market
of 100 at 20.055, by entering 5 20 lot orders.
2. Select these orders in the orderbook. Make sure the price and quantity show up correctly in the Params
tab on the right. Change the price to 20.050 and make sure it applies to all the 5 orders.
3. Now enter 10 5 lot Lean orders at 20.025 with
Cross threshold=10
Max Chase=5
On Toward=No Change
4. Move the ask side market to 20.045 now. Leans should continue to work as is.
5. Select all the lean orders and change the Trade Toward Behaviour to Cancel (dont commit yet).
As the parameter is changed its name should turn Green along with a *. Revert back and it should go to
No Change. Select a few of the leans and make sure Trade Toward Behaviour is No Change. Now Change it
to Cancel and commit. Make sure it is set to Cancel for all the lean orders.
6. Move the ask book to 20.040. This should cancel all the leans (verifies the change
in 5 made through). Move the market back to 20.050
7. Enter 2 leans, 4 and 6 lots (configured like 3) at 20.025 and 20.020 respectively. In the orderbook
select both and make sure the Price and Size show as - (since they are different). Change the Trade Toward
Behaviour on both to Cancel and make sure that goes through (you can validate that by viewing
the parameters from the ladder ->miniOB -> update)
8. Now change the 20.020 lean's Trade Toward to Detach. Now select both and Trade Toward should
show as -.
9. Now we will generalize 7 and 8. The idea is to make the parameters different bw the 2 orders,
make sure they appear as - when both are selected. Also verify that when you mass update a parameter, the
rest of them should continue with their current value.
+29 -15
View File
@@ -7,32 +7,46 @@ Also make sure you have limits to trade SI Future
1. Bring up a ladder, lets say in SIN1 (does not matter which security)
2. Create both sides of the market by entering 10 lot limit orders at 15.550 and 15.575
2. Create the ask side of the market by sending a 10 lot limit order at 20.050
(if there are no markets use the M View and the ticket to enter, if you already had left over
orders cancel them)
Basics:
3. Enter a 5 lot buy lean order at 15.540 with the following parameters
Cross Threshold = Absolute:7
3. Enter a 1 lot buy lean order at 20.025 with the following parameters
Cross Threshold = Absolute:5
Max Chase Ticks = 2
On Toward = No Change
Child = Limit
Verify that the Lean order along with the Child order shows up
4. Now since our threshold = 7, decrease the ask market to 6 and verify that the lean crosses into it
and gets filled. Verify that both the Child and Lean show up correctly (status, price, qty and filled qty)
in the OrderBook.
4. Now since the threshold = 5, decrease the ask market to 5 and verify that the lean does NOT cross yet.
Now decrease it to 4 and the lean will force its child it to cross and get filled at 20.050.
5. Repeat 2 and 3. Now in the OrderBook select this lean order and change its Cross Threshold to 15. This
should cause Lean order to cross and filled.
"On Toward":
6. Repeat 2 and 3
a. Move the ask market toward your lean order. Since the On Toward is No Change, nothing should happen.
b. Enter a new Lean order with On Toward set to Cancel. Move the ask
another tick closer and the Lean along with the Child order should be cancelled
c. Now enter another Lean with On Toward = Detach. This should detach the Child, ie the Lean should
go to Canceled State and Child should keep working. Cancel it
d. Enter another Lean order this time with OnToward=Reprice. What this will do is reset the opposite
market its watching to this new level. If you decrease the qty at this level to below the threshold (7)
it should cross.
This is when the market moves towards the order, in the case of a buy order that is the ask market
price decreasing.
Lean can repond with No Change, Reprice, Cancel or Detach.
6. No Change :
a. Repeat 2 and 3
b. Move the ask market toward your lean order. Since the On Toward is No Change, the observed market remains at 20.05.
Now decrease the ask qty to 4 and the lean should cross the market at 20.050 (it will get filled at 20.045)
Reprice:
7. Reprice
a. Repeat 2 and 3
b. Move the ask market toward your lean order. Since the On Toward is Reprice, the Lean resets the
observed market to new top of book (20.045). Now decrease the ask qty to 4
and the lean should cross the market at 20.045.
8. Cancel
a. Repeat 2 and 3
b. Move the ask market toward your lean order. This should cancel the lean and its child.
8. Detach
a. Repeat 2 and 3
b. Move the ask market toward your lean order. Make sure the child order is detached (the child continues
to work, and the algo is gone)