-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pegged Orders #15
Comments
Yes trailing orders are supported.
|
Makes sense, very nice. Thanks. I think pegged orders are a bit different from trialing orders, no ? |
I get a memory leak with the following example, using trailing stop limit sell: CppTrader::Matching::MarketManager market;
// Prepare symbol & order book
const char name[8] = "test";
CppTrader::Matching::Symbol symbol{0, name};
market.AddSymbol(symbol);
market.AddOrderBook(symbol);
// Enable automatic matching
market.EnableMatching();
uint64_t order_id = 1;
// Add buy limit orders
market.AddOrder(CppTrader::Matching::Order::BuyLimit(order_id++, 0, 2521, 200));
market.AddOrder(CppTrader::Matching::Order::BuyLimit(order_id++, 0, 2519, 300));
market.AddOrder(CppTrader::Matching::Order::BuyLimit(order_id++, 0, 2515, 785));
market.AddOrder(CppTrader::Matching::Order::BuyLimit(order_id++, 0, 2510, 170));
// Add sell limit orders
market.AddOrder(CppTrader::Matching::Order::SellLimit(order_id++, 0, 2556, 300));
market.AddOrder(CppTrader::Matching::Order::SellLimit(order_id++, 0, 2555, 1000));
market.AddOrder(CppTrader::Matching::Order::SellLimit(order_id++, 0, 2535, 200));
market.AddOrder(CppTrader::Matching::Order::SellLimit(order_id++, 0, 2530, 150));
market.AddOrder(CppTrader::Matching::Order::TrailingSellStopLimit(9999, 0, 2500, 2520, 150, 1));
market.AddOrder(CppTrader::Matching::Order::BuyLimit(order_id++, 0, 2550, 500));
market.AddOrder(CppTrader::Matching::Order::SellLimit(order_id++, 0, 2529, 500)); Assertion failed: ((_allocated == 0) && "Memory leak detected! Allocated memory size must be zero!"), function clear, file allocator_pool.inl, line 338. The leak seam to be caused because of the TrailingSellStopLimit and after the submission of the last SellLimit |
Any suggestions on this ? Thank you |
Visual Leak Detector read settings from: Z:\soft\Development\VisualLeakDetector\vld.ini Trading detailsAdd symbol: Symbol(Id=0; Name="test ")Add order book: OrderBook(Symbol=Symbol(Id=0; Name="test "); Bids=0; Asks=0; BuyStop=0; SellStop=0; TrailingBuyStop=0; TrailingSellStop=0) Add order: Order(Id=1; SymbolId=0; Type=LIMIT; Side=BUY; Price=2521; StopPrice=0; Quantity=200; ExecutedQuantity=0; LeavesQuantity=200; GTC) Add level: Level(Type=BID; Price=2521; TotalVolume=200; HiddenVolume=0; VisibleVolume=200; Orders=1) - Top of the book! Update order book: OrderBook(Symbol=Symbol(Id=0; Name="test "); Bids=1; Asks=0; BuyStop=0; SellStop=0; TrailingBuyStop=0; TrailingSellStop=0) - Top of the book! Add order: Order(Id=2; SymbolId=0; Type=LIMIT; Side=BUY; Price=2519; StopPrice=0; Quantity=300; ExecutedQuantity=0; LeavesQuantity=300; GTC) Add level: Level(Type=BID; Price=2519; TotalVolume=300; HiddenVolume=0; VisibleVolume=300; Orders=1) Update order book: OrderBook(Symbol=Symbol(Id=0; Name="test "); Bids=2; Asks=0; BuyStop=0; SellStop=0; TrailingBuyStop=0; TrailingSellStop=0) Add order: Order(Id=3; SymbolId=0; Type=LIMIT; Side=BUY; Price=2515; StopPrice=0; Quantity=785; ExecutedQuantity=0; LeavesQuantity=785; GTC) Add level: Level(Type=BID; Price=2515; TotalVolume=785; HiddenVolume=0; VisibleVolume=785; Orders=1) Update order book: OrderBook(Symbol=Symbol(Id=0; Name="test "); Bids=3; Asks=0; BuyStop=0; SellStop=0; TrailingBuyStop=0; TrailingSellStop=0) Add order: Order(Id=4; SymbolId=0; Type=LIMIT; Side=BUY; Price=2510; StopPrice=0; Quantity=170; ExecutedQuantity=0; LeavesQuantity=170; GTC) Add level: Level(Type=BID; Price=2510; TotalVolume=170; HiddenVolume=0; VisibleVolume=170; Orders=1) Update order book: OrderBook(Symbol=Symbol(Id=0; Name="test "); Bids=4; Asks=0; BuyStop=0; SellStop=0; TrailingBuyStop=0; TrailingSellStop=0) Add order: Order(Id=5; SymbolId=0; Type=LIMIT; Side=SELL; Price=2556; StopPrice=0; Quantity=300; ExecutedQuantity=0; LeavesQuantity=300; GTC) Add level: Level(Type=ASK; Price=2556; TotalVolume=300; HiddenVolume=0; VisibleVolume=300; Orders=1) - Top of the book! Update order book: OrderBook(Symbol=Symbol(Id=0; Name="test "); Bids=4; Asks=1; BuyStop=0; SellStop=0; TrailingBuyStop=0; TrailingSellStop=0) - Top of the book! Add order: Order(Id=6; SymbolId=0; Type=LIMIT; Side=SELL; Price=2555; StopPrice=0; Quantity=1000; ExecutedQuantity=0; LeavesQuantity=1000; GTC) Add level: Level(Type=ASK; Price=2555; TotalVolume=1000; HiddenVolume=0; VisibleVolume=1000; Orders=1) - Top of the book! Update order book: OrderBook(Symbol=Symbol(Id=0; Name="test "); Bids=4; Asks=2; BuyStop=0; SellStop=0; TrailingBuyStop=0; TrailingSellStop=0) - Top of the book! Add order: Order(Id=7; SymbolId=0; Type=LIMIT; Side=SELL; Price=2535; StopPrice=0; Quantity=200; ExecutedQuantity=0; LeavesQuantity=200; GTC) Add level: Level(Type=ASK; Price=2535; TotalVolume=200; HiddenVolume=0; VisibleVolume=200; Orders=1) - Top of the book! Update order book: OrderBook(Symbol=Symbol(Id=0; Name="test "); Bids=4; Asks=3; BuyStop=0; SellStop=0; TrailingBuyStop=0; TrailingSellStop=0) - Top of the book! Add order: Order(Id=8; SymbolId=0; Type=LIMIT; Side=SELL; Price=2530; StopPrice=0; Quantity=150; ExecutedQuantity=0; LeavesQuantity=150; GTC) Add level: Level(Type=ASK; Price=2530; TotalVolume=150; HiddenVolume=0; VisibleVolume=150; Orders=1) - Top of the book! Update order book: OrderBook(Symbol=Symbol(Id=0; Name="test "); Bids=4; Asks=4; BuyStop=0; SellStop=0; TrailingBuyStop=0; TrailingSellStop=0) - Top of the book! Add order: Order(Id=9999; SymbolId=0; Type=TRAILING-STOP-LIMIT; Side=SELL; Price=2520; StopPrice=2500; Quantity=150; ExecutedQuantity=0; LeavesQuantity=150; GTC; TrailingDistance=1; TrailingStep=0) Add order: Order(Id=9; SymbolId=0; Type=LIMIT; Side=BUY; Price=2550; StopPrice=0; Quantity=500; ExecutedQuantity=0; LeavesQuantity=500; GTC) Execute order: Order(Id=8; SymbolId=0; Type=LIMIT; Side=SELL; Price=2530; StopPrice=0; Quantity=150; ExecutedQuantity=0; LeavesQuantity=150; GTC) with price 2530 and quantity 150 Delete order: Order(Id=8; SymbolId=0; Type=LIMIT; Side=SELL; Price=2530; StopPrice=0; Quantity=150; ExecutedQuantity=150; LeavesQuantity=0; GTC) Delete level: Level(Type=ASK; Price=2530; TotalVolume=0; HiddenVolume=0; VisibleVolume=0; Orders=0) - Top of the book! Update order book: OrderBook(Symbol=Symbol(Id=0; Name="test "); Bids=4; Asks=3; BuyStop=0; SellStop=0; TrailingBuyStop=0; TrailingSellStop=1) - Top of the book! Execute order: Order(Id=9; SymbolId=0; Type=LIMIT; Side=BUY; Price=2550; StopPrice=0; Quantity=500; ExecutedQuantity=0; LeavesQuantity=500; GTC) with price 2530 and quantity 150 Execute order: Order(Id=7; SymbolId=0; Type=LIMIT; Side=SELL; Price=2535; StopPrice=0; Quantity=200; ExecutedQuantity=0; LeavesQuantity=200; GTC) with price 2535 and quantity 200 Delete order: Order(Id=7; SymbolId=0; Type=LIMIT; Side=SELL; Price=2535; StopPrice=0; Quantity=200; ExecutedQuantity=200; LeavesQuantity=0; GTC) Delete level: Level(Type=ASK; Price=2535; TotalVolume=0; HiddenVolume=0; VisibleVolume=0; Orders=0) - Top of the book! Update order book: OrderBook(Symbol=Symbol(Id=0; Name="test "); Bids=4; Asks=2; BuyStop=0; SellStop=0; TrailingBuyStop=0; TrailingSellStop=1) - Top of the book! Execute order: Order(Id=9; SymbolId=0; Type=LIMIT; Side=BUY; Price=2550; StopPrice=0; Quantity=500; ExecutedQuantity=150; LeavesQuantity=350; GTC) with price 2535 and quantity 200 Add level: Level(Type=BID; Price=2550; TotalVolume=150; HiddenVolume=0; VisibleVolume=150; Orders=1) - Top of the book! Update order book: OrderBook(Symbol=Symbol(Id=0; Name="test "); Bids=5; Asks=2; BuyStop=0; SellStop=0; TrailingBuyStop=0; TrailingSellStop=1) - Top of the book! Update order: Order(Id=9999; SymbolId=0; Type=TRAILING-STOP-LIMIT; Side=SELL; Price=2554; StopPrice=2534; Quantity=150; ExecutedQuantity=0; LeavesQuantity=150; GTC; TrailingDistance=1; TrailingStep=0) Add order: Order(Id=10; SymbolId=0; Type=LIMIT; Side=SELL; Price=2529; StopPrice=0; Quantity=500; ExecutedQuantity=0; LeavesQuantity=500; GTC) Execute order: Order(Id=9; SymbolId=0; Type=LIMIT; Side=BUY; Price=2550; StopPrice=0; Quantity=500; ExecutedQuantity=350; LeavesQuantity=150; GTC) with price 2550 and quantity 150 Delete order: Order(Id=9; SymbolId=0; Type=LIMIT; Side=BUY; Price=2550; StopPrice=0; Quantity=500; ExecutedQuantity=500; LeavesQuantity=0; GTC) Delete level: Level(Type=BID; Price=2550; TotalVolume=0; HiddenVolume=0; VisibleVolume=0; Orders=0) - Top of the book! Update order book: OrderBook(Symbol=Symbol(Id=0; Name="test "); Bids=4; Asks=2; BuyStop=0; SellStop=0; TrailingBuyStop=0; TrailingSellStop=1) - Top of the book! Execute order: Order(Id=10; SymbolId=0; Type=LIMIT; Side=SELL; Price=2529; StopPrice=0; Quantity=500; ExecutedQuantity=0; LeavesQuantity=500; GTC) with price 2550 and quantity 150 Add level: Level(Type=ASK; Price=2529; TotalVolume=350; HiddenVolume=0; VisibleVolume=350; Orders=1) - Top of the book! Update order book: OrderBook(Symbol=Symbol(Id=0; Name="test "); Bids=4; Asks=3; BuyStop=0; SellStop=0; TrailingBuyStop=0; TrailingSellStop=1) - Top of the book! Update order: Order(Id=9999; SymbolId=0; Type=LIMIT; Side=SELL; Price=2554; StopPrice=0; Quantity=150; ExecutedQuantity=0; LeavesQuantity=150; GTC) Add level: Level(Type=ASK; Price=2554; TotalVolume=150; HiddenVolume=0; VisibleVolume=150; Orders=1) Update order book: OrderBook(Symbol=Symbol(Id=0; Name="test "); Bids=4; Asks=4; BuyStop=0; SellStop=0; TrailingBuyStop=0; TrailingSellStop=0) |
The issue is not reproducing on my side. Could you please check if it still actual on your side? |
Is there support for pegged order types ? or support for limit orders that dynamically move with the best market quotes ?
The text was updated successfully, but these errors were encountered: