3
$\begingroup$

I'm looking for a way to make my own Python backtester (like zipline or pyalgotrade) or improve one of these backtesters.

One major lack of these backtesters is the lack of support of bracket orders ("child" stoploss and takeprofit orders linked to a "parent" order)

I wonder how I should model bracket orders ?

$\endgroup$
3
$\begingroup$

You will need an entry and then a "Grouped" stop loss and take profit (one cancels other). An implementation of this exists in quantstrat in R called ordersets.

Documentation and source code can be found here:

https://r-forge.r-project.org/scm/viewvc.php/pkg/quantstrat/R/orders.R?view=markup&root=blotter

You will unfortunately need to port this and other infrastructure over to python.

In my opinion the Blotter/Quantstrat backtesting framework has the most support for various order types it also reconciles with the brokerage statements of one of the contributors.

Here is an example of a Q/A solving this in S/O. https://stackoverflow.com/questions/10445936/r-quantstrat-orders-cancel-each-other

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.