Closed superdevel7 closed 1 month ago
Hi! Thanks for mention this. Your suggestions? Did you solve this?
In backtrader_binance/binance_store.py
I changed the create_order
function.
@retry
def create_order(self, symbol, side, type, size, price):
params = dict()
if type in [ORDER_TYPE_LIMIT, ORDER_TYPE_STOP_LOSS_LIMIT]:
params.update({
'timeInForce': TIME_IN_FORCE_GTC
})
if type == ORDER_TYPE_STOP_LOSS:
params.update({
'stopPrice': self.format_price(symbol, price)
})
elif type != ORDER_TYPE_MARKET:
params.update({
'price': self.format_price(symbol, price)
})
return self.binance.create_order(
symbol=symbol,
side=side,
type=type,
quantity=self.format_quantity(symbol, size),
newOrderRespType='RESULT',
**params)
And it worked. You can review this.
cool, please create Pull Request for this, I will approve this change
Thanks for PR)
When I create the following order in my backtrader strategy, I got 1106 error.
self.broker.buy(data=data, exectype=bt.Order.Stop, price=price, size=0.01, valid=expiration_time)
I think it is because of using the parameterprice
rather thanstopPrice
for the ordery type STOP_LOSS.