fix convert
This commit is contained in:
15
order.py
15
order.py
@@ -75,6 +75,7 @@ class OrderManager:
|
|||||||
elif action_type == "cancel":
|
elif action_type == "cancel":
|
||||||
self.exchange.send_cancel_message(**kwargs)
|
self.exchange.send_cancel_message(**kwargs)
|
||||||
elif action_type == "convert":
|
elif action_type == "convert":
|
||||||
|
|
||||||
self.exchange.send_convert_message(**kwargs)
|
self.exchange.send_convert_message(**kwargs)
|
||||||
|
|
||||||
# 전송한 시간 기록
|
# 전송한 시간 기록
|
||||||
@@ -128,13 +129,25 @@ class OrderManager:
|
|||||||
)
|
)
|
||||||
|
|
||||||
def convert(self, symbol: str, dir: str, size: int):
|
def convert(self, symbol: str, dir: str, size: int):
|
||||||
return self._attempt_send(
|
result = self._attempt_send(
|
||||||
"convert",
|
"convert",
|
||||||
order_id=self.next_order(),
|
order_id=self.next_order(),
|
||||||
symbol=symbol,
|
symbol=symbol,
|
||||||
dir=dir,
|
dir=dir,
|
||||||
size=size,
|
size=size,
|
||||||
)
|
)
|
||||||
|
if result and symbol == "VALE":
|
||||||
|
if dir == Dir.BUY:
|
||||||
|
self.positions["VALE"] -= size
|
||||||
|
self.positions["VALBZ"] += size
|
||||||
|
self.future_positions["VALE"] -= size
|
||||||
|
self.future_positions["VALBZ"] += size
|
||||||
|
else:
|
||||||
|
self.positions["VALE"] += size
|
||||||
|
self.positions["VALBZ"] -= size
|
||||||
|
self.future_positions["VALE"] += size
|
||||||
|
self.future_positions["VALBZ"] -= size
|
||||||
|
return result
|
||||||
|
|
||||||
def cancel(self, order_id: int):
|
def cancel(self, order_id: int):
|
||||||
return self._attempt_send("cancel", order_id=order_id)
|
return self._attempt_send("cancel", order_id=order_id)
|
||||||
|
|||||||
Reference in New Issue
Block a user