Implement trailing stop loss

This commit is contained in:
2022-11-15 07:20:17 +00:00
parent 5c68191e5b
commit d7e81dedb2
5 changed files with 104 additions and 40 deletions

View File

@@ -66,6 +66,11 @@ class OANDAExchange(BaseExchange):
data["order"]["price"] = str(trade.price)
elif trade.type == "market":
data["order"]["priceBound"] = str(trade.price)
if trade.trailing_stop_loss is not None:
data["order"]["trailingStopLossOnFill"] = {
"distance": str(trade.trailing_stop_loss),
"timeInForce": "GTC",
}
r = orders.OrderCreate(self.account_id, data=data)
response = self.call(r)
trade.response = response