Donald

Order closed with unexpected price

Programming


Hi there, I have a script running in the live-test environment.

I found that one of my order for 7500HK was closed at $4.77 on 7-Jul. However, I checked other data sources, the lowest price on that day doesn't hit that low.

Is there anything wrong?


 
admin

It is a common industrial practice to base on bid/ask for TP/SL monitoring.

For example, you purchase 100 shares of stock ABC at $10. Also, you set SL level at $8 such that you want to limit the loss amount to $200 [i.e. 100*($8-$10)].

As it is a long position, your mark-to-market PL will be calculated as 100*(Bid - $10).


Time Bid Ask Last Mark-to-market PL
1 10 10.1 10.4 0
2 9.5 9.8 9.6 -50
3 8.8 9.3 9 -120
4 8 8.5 8.3 -200
5 7.5 8.1 8 -250

Therefore, your SL will be triggered at time 4 with a loss amount $200 realized.

However, for SL based on last price, it will be triggered at time 5. The realized loss will be $250, which can be much more than the orginal expected $200.


Our system currently doesn't support TP/SL based on last price.

If you really need to follow this logic, you will need to listen to a higher frequent data stream and monitor in your script.


 
Donald
Original Posted by - b'admin':

It is a common industrial practice to base on bid/ask for TP/SL monitoring.

For example, you purchase 100 shares of stock ABC at $10. Also, you set SL level at $8 such that you want to limit the loss amount to $200 [i.e. 100*($8-$10)].

As it is a long position, your mark-to-market PL will be calculated as 100*(Bid - $10).


Time Bid Ask Last Mark-to-market PL
1 10 10.1 10.4 0
2 9.5 9.8 9.6 -50
3 8.8 9.3 9 -120
4 8 8.5 8.3 -200
5 7.5 8.1 8 -250

Therefore, your SL will be triggered at time 4 with a loss amount $200 realized.

However, for SL based on last price, it will be triggered at time 5. The realized loss will be $250, which can be much more than the orginal expected $200.


Our system currently doesn't support TP/SL based on last price.

If you really need to follow this logic, you will need to listen to a higher frequent data stream and monitor in your script.


Thanks for the explanation. 
Could you provide an example how to implement?