reordered methods in bfxbot. added stubs of close order and close position

This commit is contained in:
Giulio De Pasquale 2020-12-16 10:12:10 +00:00
parent 5544d681f4
commit a958d2f120

View File

@ -57,6 +57,21 @@ class BfxBot:
## TODO: handle _on_new_tick() from Strategy ## TODO: handle _on_new_tick() from Strategy
await self.__status[symbol].__add_event__(Event(EventKind.NEW_TICK, self.__ticker.current_tick)) await self.__status[symbol].__add_event__(Event(EventKind.NEW_TICK, self.__ticker.current_tick))
def close_order(self, symbol: Symbol, order_id: int):
raise NotImplementedError
def close_position(self, symbol: Symbol, position_id: int):
raise NotImplementedError
def set_strategy(self, symbol, strategy: Strategy):
if symbol in self.__status:
self.__status[symbol].strategy = strategy
else:
self.__status[symbol] = SymbolStatus(symbol, strategy)
async def start(self):
await self.__update_status__()
def symbol_event_handler(self, symbol) -> EventHandler: def symbol_event_handler(self, symbol) -> EventHandler:
if symbol not in self.__status: if symbol not in self.__status:
return None return None
@ -69,16 +84,7 @@ class BfxBot:
return self.__status[symbol] return self.__status[symbol]
async def start(self):
await self.__update_status__()
async def update(self): async def update(self):
sleep(self.__ticker.seconds) sleep(self.__ticker.seconds)
self.__ticker.inc() self.__ticker.inc()
await self.__update_status__() await self.__update_status__()
def set_strategy(self, symbol, strategy: Strategy):
if symbol in self.__status:
self.__status[symbol].strategy = strategy
else:
self.__status[symbol] = SymbolStatus(symbol, strategy)