chronoxor / CppTrader

High performance components for building Trading Platform such as ultra fast matching engine, order book processor
MIT License
833 stars 254 forks source link

Trailing Stop Limit Seems Only Work One Time, For Second Time With Same Scenario Is not Executed #31

Closed devararendy closed 2 years ago

devararendy commented 2 years ago

Dear @chronoxor

i'm using cpptrader-example-matching_engine from commit 43b8cfbc438373d3fb9b784025f6018f453e4e72

I have a Trailing Stop Limit Scenario as shown below :

add symbol 1 BTC_ETH add book 1 enable matching

add limit sell 1 1 1000 100 add limit sell 2 1 1100 100 add limit sell 3 1 1100 100 add limit buy 4 1 900 100 add trailing stop-limit sell 5 1 700 700 100 100 0 add limit buy 6 1 1000 100 add limit buy 7 1 1100 100 add limit sell 8 1 900 100 add limit buy 9 1 1100 200

At first attempt the Trailing Stop is working and Executed. But When I retry with same scenario (without re-running the executable) the Trailing Stop Limit is not working. And why SellStop value is so big ?:

add limit sell 1 1 1000 100 add limit sell 2 1 1100 100 add limit sell 3 1 1100 100 add limit buy 4 1 900 100 add trailing stop-limit sell 5 1 700 700 100 100 0 add limit buy 6 1 1000 100 add limit buy 7 1 1100 100 add limit sell 8 1 900 100 add limit buy 9 1 1100 200

I will attach the screen shot also to make it easier to see / debug

  1. First Attempt and Trailing Stop is working image

  2. Second Attempt with same scenario Trailing Stop is not working (without rerunning the executable) image

Thank You very much Have a nice day

Best Regards

chronoxor commented 2 years ago

Fixed! Thanks for reporting!