vectorbt icon indicating copy to clipboard operation
vectorbt copied to clipboard

[WIP] Order price can now be 0 to accommodate unusual scenarios

Open davidandreoletti opened this issue 4 years ago • 1 comments

Awesome lib!

Example scenario: Closing a position at 100% loss such as simulating an open position on a stock (price > 0) and then "closing" said position when the stock is delisted (ie stock price is 0)

davidandreoletti avatar Jun 07 '21 19:06 davidandreoletti

It's not as simple as that. Your current change would allow filling literally any order of any size when the price is zero. See #83 for a workaround.

Edit: what can work is automatically replacing any zero price with nan; this way any order will be ignored while the ticker is delisted. But with one exception: if some special condition is met (e.g., the size type is target shares and the size is 0), it will close the position at 100% loss. Then you as a user are responsible for selecting an appropriate timestamp to close the position. Or we could automatically close any position if the price hits zero and ignore all subsequent order requests, but this would rule out re-entering the same position in case of relisting.

polakowo avatar Jun 07 '21 20:06 polakowo