Hi guys ,
For your daytraders out there, the following is an attempt to buy at a maximum given price (limit), then immediately bracket the order with both an upper limit sell and a lower stop/limit sell order. This is not a strategy. No attempt is made to find profitable logic. The intent is just to post the required bracket orders, verify they are working, monitor their results, and calculate their p&l's.
As most of you who day-trade know, waiting a whole minute for fulfillment or measurement of results is a killer to most strategies.
Some of the challenges encountered:
1) to keep tabs of any existing orders which may not fill at all or not when you want them to
2) to eliminate any superfluous orders after a gain (target reached) or loss (breach reached) is encountered.
3) to factor in situations (long-legged doji candlestick pattern) when both the target and the loss are hit within the same minute
4) to figure out what the actual sale prices that trigger are, since the order attributes do not include a transaction price.
The following is far from perfect, but it resolves most of those issues. It's still buggy, for example in the date ranges of this backtest it is not killing off the final breach order, which ends up triggering and getting us short the position, which is not our intention.
Perhaps these efforts may help someone else. I welcome all critiques, suggestions, etc
Of course a more sophisticated strategy would have to create a list of orders, to deal with multiple stocks, but I wanted to focus on the details of getting one transaction down perfectly before moving on to more sophisticated frameworks.
|Returns||1 Month||3 Month||6 Month||12 Month|
|Alpha||1 Month||3 Month||6 Month||12 Month|
|Beta||1 Month||3 Month||6 Month||12 Month|
|Sharpe||1 Month||3 Month||6 Month||12 Month|
|Sortino||1 Month||3 Month||6 Month||12 Month|
|Volatility||1 Month||3 Month||6 Month||12 Month|
|Max Drawdown||1 Month||3 Month||6 Month||12 Month|