コード例 #1
0
    def __init__(
        self, host: str="127.0.0.1", port: int=4001,
        client_id: int=1, auto_conn: bool=True,
        accounts_manager: Optional[delegates.AccountsManagementDelegate]=None,
        connection_listener: Optional[listeners.ConnectionListener]=None,
        notification_listener: Optional[listeners.NotificationListener]=None,
        order_events_listener: Optional[listeners.OrderEventsListener]=None
    ):
        super().__init__()

        self._host = host
        self._port = port
        self._client_id = client_id
        self._accounts_manager = (
            manager.AccountsManager() if accounts_manager is None
            else accounts_manager
        )
        self._orders_manager = manager.OrdersManager(
            event_listener=order_events_listener)

        self._wrapper = _wrapper.IBWrapper(
            accounts_manager=self._accounts_manager,
            orders_manager=self._orders_manager,
            connection_listener=connection_listener,
            notification_listener=notification_listener
        )

        self._client = _client.IBClient(wrapper=self._wrapper)

        if auto_conn:
            self.connect()
コード例 #2
0
ファイル: test_client.py プロジェクト: jihunkim0/ibpy_native
    def setUpClass(cls):
        cls._wrapper = _wrapper.IBWrapper(
            accounts_manager=utils.MockAccountsManagementDelegate(),
            orders_manager=manager.OrdersManager())
        cls._client = _client.IBClient(cls._wrapper)

        cls._client.connect(utils.IB_HOST, utils.IB_PORT, utils.IB_CLIENT_ID)

        thread = threading.Thread(target=cls._client.run)
        thread.start()