fix convert
This commit is contained in:
1
bot.py
1
bot.py
@@ -105,6 +105,7 @@ def on_trade(message: dict, orderman: OrderManager, state: StateManager):
|
||||
print("Good")
|
||||
if (p_vale + 1) * SZ + FEE < (p_valbz - 1) * SZ:
|
||||
orderman.buy("VALE", p_vale + 1, -SZ)
|
||||
orderman.convert("VALE", SZ)
|
||||
orderman.sell("VALBZ", p_valbz - 1, SZ)
|
||||
|
||||
|
||||
|
||||
13
order.py
13
order.py
@@ -81,6 +81,19 @@ class OrderManager:
|
||||
price=price,
|
||||
size=size,
|
||||
)
|
||||
def convert(self, symbol: str, size: int):
|
||||
if symbol == "VALE":
|
||||
target = "VALBZ"
|
||||
self.future_positions["VALE"] -= size
|
||||
self.future_positions["VALBZ"] += size
|
||||
self.positions["VALE"] -= size
|
||||
self.positions["VALBZ"] += size
|
||||
return self.exchange.send_convert_message(
|
||||
order_id=self._next_order(),
|
||||
symbol=symbol,
|
||||
dir="BUY",
|
||||
size=size,
|
||||
)
|
||||
|
||||
def buy(self, symbol: str, price: int, size: int):
|
||||
return self._attempt_send(
|
||||
|
||||
Reference in New Issue
Block a user