I am running tests on live data. The script for exit uses simple stop and profit taker order from strategy builder section:
SetProfitTarget("", CalculationMode.Percent, Profit_taker);
SetTrailStop("", CalculationMode.Percent, Trail, false);
In 99% of cases all works fine. However, sometimes when the order is filled partially, eg. the current position 332 but short sell was filled as 100 and 232 in 2 orders, then stop order fills only 100 quantity and status in orders tab for stop order changes into "filled" and no more stop orders are followed remaining 232 shares.This is really annoying, because I am stuck with the shares that already should be sold. Please see below attached image from order tab.
Here are also the all logs i have:
Once the partially filled share short order is filled (blue highlighted part) the script thinks that there is only 100 quantity, so the stop order and profit taker is all the time in logs updated for quantity 100. Even though after few milliseconds the order short sell is filling another 232 quantity. (green higlighted)
Could you please advise how to repair it?
9:30:04 AM | Order | Order='e157b16faa1645bf8332cc1e18bc612d/SimStrateg_C_D_profit_taker' Name='Sell short' New state='Submitted' Instrument='CLIR' Action='Sell short' Limit price=0 Stop price=0 Quantity=332 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' |
9:30:04 AM | Order | Order='e157b16faa1645bf8332cc1e18bc612d/SimStrateg_C_D_profit_taker' Name='Sell short' New state='Accepted' Instrument='CLIR' Action='Sell short' Limit price=0 Stop price=0 Quantity=332 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' |
9:30:04 AM | Order | Order='e157b16faa1645bf8332cc1e18bc612d/SimStrateg_C_D_profit_taker' Name='Sell short' New state='Working' Instrument='CLIR' Action='Sell short' Limit price=0 Stop price=0 Quantity=332 Type='Market' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error='' |
9:30:04 AM | Order | Order='e157b16faa1645bf8332cc1e18bc612d/SimStrateg_C_D_profit_taker' Name='Sell short' New state='Partially filled' Instrument='CLIR' Action='Sell short' Limit price=0 Stop price=0 Quantity=332 Type='Market' Time in force=GTC Oco='' Filled=100 Fill price=3.01 Error='No error' Native error='' |
9:30:04 AM | NinjaScript | NinjaScript strategy 'shortpremarket113realtimeprofitstop/203694206' submitting order |
9:30:04 AM | Execution | Execution='b9d654501a93412fa3a7ac548d50c77e' Instrument='CLIR' Account='SimStrateg_C_D_profit_taker' Exchange=Default Price=3.01 Quantity=100 Market position=Short Operation=Operation_Add Order='e157b16faa1645bf8332cc1e18bc612d' Time='6/17/2020 9:30 AM' |
9:30:04 AM | Order | Order='cb73d3b3661047289c9bcc9c20d1282b/SimStrateg_C_D_profit_taker' Name='Trail stop' New state='Submitted' Instrument='CLIR' Action='Buy to cover' Limit price=0 Stop price=3.61 Quantity=100 Type='Stop Market' Time in force=GTC Oco='b9d654501a93412fa3a7ac548d50c77e' Filled=0 Fill price=0 Error='No error' Native error='' |
9:30:04 AM | NinjaScript | NinjaScript strategy 'shortpremarket113realtimeprofitstop/203694206' submitting order |
9:30:04 AM | Position | Instrument='CLIR' Account='SimStrateg_C_D_profit_taker' Average price=3.01 Quantity=100 Market position=Short Operation=Operation_Add |
9:30:04 AM | Order | Order='c74f18ebefc74ad28a5865db608bfb06/SimStrateg_C_D_profit_taker' Name='Profit target' New state='Submitted' Instrument='CLIR' Action='Buy to cover' Limit price=2.41 Stop price=0 Quantity=100 Type='Limit' Time in force=GTC Oco='b9d654501a93412fa3a7ac548d50c77e' Filled=0 Fill price=0 Error='No error' Native error='' |
9:30:04 AM | Order | Order='e157b16faa1645bf8332cc1e18bc612d/SimStrateg_C_D_profit_taker' Name='Sell short' New state='Filled' Instrument='CLIR' Action='Sell short' Limit price=0 Stop price=0 Quantity=332 Type='Market' Time in force=GTC Oco='' Filled=332 Fill price=3.0030120481927711 Error='No error' Native error='' |
9:30:04 AM | Execution | Execution='ca6fbddcb1f24c0e893e68b1d1181ca6' Instrument='CLIR' Account='SimStrateg_C_D_profit_taker' Exchange=Default Price=3 Quantity=232 Market position=Short Operation=Operation_Add Order='e157b16faa1645bf8332cc1e18bc612d' Time='6/17/2020 9:30 AM' |
9:30:04 AM | Position | Instrument='CLIR' Account='SimStrateg_C_D_profit_taker' Average price=3.0030120481927711 Quantity=332 Market position=Short Operation=Update |
9:30:04 AM | Order | Order='cb73d3b3661047289c9bcc9c20d1282b/SimStrateg_C_D_profit_taker' Name='Trail stop' New state='Accepted' Instrument='CLIR' Action='Buy to cover' Limit price=0 Stop price=3.61 Quantity=100 Type='Stop Market' Time in force=GTC Oco='b9d654501a93412fa3a7ac548d50c77e' Filled=0 Fill price=0 Error='No error' Native error='' |
9:30:04 AM | Order | Order='c74f18ebefc74ad28a5865db608bfb06/SimStrateg_C_D_profit_taker' Name='Profit target' New state='Accepted' Instrument='CLIR' Action='Buy to cover' Limit price=2.41 Stop price=0 Quantity=100 Type='Limit' Time in force=GTC Oco='b9d654501a93412fa3a7ac548d50c77e' Filled=0 Fill price=0 Error='No error' Native error='' |
9:30:04 AM | Order | Order='c74f18ebefc74ad28a5865db608bfb06/SimStrateg_C_D_profit_taker' Name='Profit target' New state='Change submitted' Instrument='CLIR' Action='Buy to cover' Limit price=2.4 Stop price=0 Quantity=100 Type='Limit' Time in force=GTC Oco='b9d654501a93412fa3a7ac548d50c77e' Filled=0 Fill price=0 Error='No error' Native error='' |
9:30:04 AM | Order | Order='c74f18ebefc74ad28a5865db608bfb06/SimStrateg_C_D_profit_taker' Name='Profit target' New state='Accepted' Instrument='CLIR' Action='Buy to cover' Limit price=2.4 Stop price=0 Quantity=100 Type='Limit' Time in force=GTC Oco='b9d654501a93412fa3a7ac548d50c77e' Filled=0 Fill price=0 Error='No error' Native error='' |
9:30:04 AM | Order | Order='c74f18ebefc74ad28a5865db608bfb06/SimStrateg_C_D_profit_taker' Name='Profit target' New state='Working' Instrument='CLIR' Action='Buy to cover' Limit price=2.4 Stop price=0 Quantity=100 Type='Limit' Time in force=GTC Oco='b9d654501a93412fa3a7ac548d50c77e' Filled=0 Fill price=0 Error='No error' Native error='' |
9:32:22 AM | Order | Order='cb73d3b3661047289c9bcc9c20d1282b/SimStrateg_C_D_profit_taker' Name='Trail stop' New state='Filled' Instrument='CLIR' Action='Buy to cover' Limit price=0 Stop price=3.56 Quantity=100 Type='Stop Market' Time in force=GTC Oco='b9d654501a93412fa3a7ac548d50c77e' Filled=100 Fill price=3.56 Error='No error' Native error='' |
9:32:22 AM | Order | Order='cb73d3b3661047289c9bcc9c20d1282b/SimStrateg_C_D_profit_taker' Name='Trail stop' New state='Working' Instrument='CLIR' Action='Buy to cover' Limit price=0 Stop price=3.56 Quantity=100 Type='Stop Market' Time in force=GTC Oco='b9d654501a93412fa3a7ac548d50c77e' Filled=0 Fill price=0 Error='No error' Native error='' |
9:32:22 AM | Position | Instrument='CLIR' Account='SimStrateg_C_D_profit_taker' Average price=3.0030120481927711 Quantity=232 Market position=Short Operation=Update |
9:32:22 AM | Execution | Execution='c597b473e42b4ff1b3d24bc4715c963d' Instrument='CLIR' Account='SimStrateg_C_D_profit_taker' Exchange=Default Price=3.56 Quantity=100 Market position=Long Operation=Operation_Add Order='cb73d3b3661047289c9bcc9c20d1282b' Time='6/17/2020 9:32 AM' |
9:32:22 AM | Order | Order='c74f18ebefc74ad28a5865db608bfb06/SimStrateg_C_D_profit_taker' Name='Profit target' New state='Cancel submitted' Instrument='CLIR' Action='Buy to cover' Limit price=2.4 Stop price=0 Quantity=100 Type='Limit' Time in force=GTC Oco='b9d654501a93412fa3a7ac548d50c77e' Filled=0 Fill price=0 Error='No error' Native error='' |
9:32:22 AM | Order | Order='c74f18ebefc74ad28a5865db608bfb06/SimStrateg_C_D_profit_taker' Name='Profit target' New state='Cancelled' Instrument='CLIR' Action='Buy to cover' Limit price=2.4 Stop price=0 Quantity=100 Type='Limit' Time in force=GTC Oco='b9d654501a93412fa3a7ac548d50c77e' Filled=0 Fill price=0 Error='No error' Native error='' |
Comment