btoandav20: Trailing Stop by percent gives error
Using trailamount seems to be ok, but trailpercent gives error.
self.long_order2 = self.buy_bracket(exectype=bt.Order.Stop, stopexec=bt.Order.StopTrail, size=qty,
limitprice=TP2_price,
price=entry_price,
# stopprice=stoploss_price,
stopargs={
# 'trailamount': stop_dist,
'trailpercent': 0.01,
},
)
File "brokers/backtrader/algo.py, line 574, in buy_risk
'trailpercent': 0.01,
File "/usr/local/lib/python3.7/site-packages/backtrader/strategy.py", line 1169, in buy_bracket
olimit = self.sell(**kargs)
File "/usr/local/lib/python3.7/site-packages/backtrader/strategy.py", line 969, in sell
**kwargs)
File "/usr/local/lib/python3.7/site-packages/btoandav20/brokers/oandav20broker.py", line 315, in sell
return self._transmit(order)
File "/usr/local/lib/python3.7/site-packages/btoandav20/brokers/oandav20broker.py", line 272, in _transmit
self.o.order_create(parent, stopside, takeside)
File "/usr/local/lib/python3.7/site-packages/btoandav20/stores/oandav20store.py", line 385, in order_create
'.%df' % order.data.contractdetails['displayPrecision']),
TypeError: unsupported format string passed to NoneType.__format__
At a glance, it looks like there might not be support for trailing stop by percent? https://github.com/ftomassetti/backtrader-oandav20/blob/master/btoandav20/stores/oandav20store.py#L384 If so, could it be added?
Thank you for the library! 👍
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (11 by maintainers)
will check the new code later and close this issue if it works probably.
Will close this issue, since it seems to be working
for the atr value, it will not update the created order. if you want to update an existing order, you would need to cancel them manually and create new ones.