Beispiel #1
0
 def __init__(self, config: IbConfig) -> None:
     self._log = Log.create(Log.path(self.log_file))
     self._config = config
     ClientBase.__init__(self,
                         self._log.get_logger('coolqclient'),
                         kWorkerTypeConsole,
                         cmd_redis_ip=self._config.cmd_redis_ip,
                         cmd_redis_port=self._config.cmd_redis_port)
     self._check_task: asyncio.Task = None
     self._error_report_times = 0
     self.add_dispatcher(ConsoleCommandResponse,
                         self.on_console_cmd_response)
Beispiel #2
0
 def __init__(self, config: IbConfig) -> None:
     self._log = Log.create(Log.path(self.log_file))
     self._config: IbConfig = config
     ClientBase.__init__(self,
                         self._log.get_logger('consoleclient'),
                         kWorkerTypeConsole,
                         cmd_redis_ip=self._config.cmd_redis_ip,
                         cmd_redis_port=self._config.cmd_redis_port)
     self._cmd_task: asyncio.Task = None
     self._prompt_session: PromptSession = PromptSession(
         completer=completer, style=style)
     self.add_dispatcher(ConsoleCommandResponse,
                         self.on_console_cmd_response)
Beispiel #3
0
 def __init__(self, config: IbConfig) -> None:
     self._config: IbConfig = config
     self._log = Log.create(Log.path(self.log_file))
     self._logger = self._log.get_logger('server')
     self._clients: Dict[str, WorkerItem] = {}
     self._redis: RedisHandler = None
     self._clients: Dict[str, WorkerItem] = {}
     self._available_channel_id: int = 0
     self._sweep_task: asyncio.Task = None
     self._console_handler: ConsoleHandler = None
     self._transporter = Transporter()
     self._client_id = config.client_id
     self._ib_manager: IbManager = IbManager(
         self._config.ib_ip, self._config.ib_port, self._client_id)
Beispiel #4
0
 def __init__(self, ip: str, port: int, client_id: int):
     self._ib = IB()
     self._ib_ip: str = ip
     self._ib_port: int = port
     self._client_id: int = client_id
     self._subscribed_mkt_contracts: List[str] = []
     self._subscribed_mkt_depth_contracts: List[str] = []
     self._log: Log = Log.create(Log.path(self.log_file))
     self._logger = self._log.get_logger('ibmanager')
     self._recorder: Recorder = Recorder(self._log)
     self._market_recorder: MarketRecorder = MarketRecorder(
         self._ib, self._recorder)
     self._account_recorder: AccountRecorder = AccountRecorder(
         self._ib, self._recorder)
     self._keep_connection_task: asyncio.Task = None
     self._ib.connectedEvent += self.on_ib_connected
     self._ib.disconnectedEvent += self.on_ib_disconnected
     self._reconnect_flag: bool = False
async def test():
    recorder = Recorder(Log.create(Log.path('test')))
    manager = MockTradeManager(recorder)
    strategy = MeanStrategy(0, manager)
    manager.test_strategy(strategy, 'app/data/XAGUSD_5_2019-10-02.csv',
                          'XAGUSD_1002_random')
Beispiel #6
0
async def test():
    logger = Log.create(Log.path('test')).get_logger('test')
    client = ClientBase(logger, 1)
    await client.initialize()