Пример #1
0
def connect_and_stream_position_data(ip, port):
    try:
        socket_client = SocketClient(ip, port)
        gateway = GatewayInterface(socket_client)
        gateway.set_data_handlers(position_data=on_position_data)
        gateway.request_position_updates()
        socket_client.loop()
    except KeyboardInterrupt:
        pass
    except Exception as e:
        print e

    socket_client.shutdown()
def connect_and_stream_account_data(ip, port):
    try:
        socket_client = SocketClient(ip, port)
        gateway = GatewayInterface(socket_client)
        gateway.set_data_handlers(account_data=on_account_data)
        gateway.request_account_updates()
        socket_client.loop()
    except KeyboardInterrupt:
        pass
    except Exception as e:
        print e

    socket_client.shutdown()
def connect_and_stream_order_data(ip, port):
    try:
        socket_client = SocketClient(ip, port)
        gateway = GatewayInterface(socket_client)
        gateway.set_data_handlers(unhandled_data=on_unhandled_server_data,
                                  account_data=on_account_data,
                                  order_data=on_order_data)
        gateway.request_order_updates()
        socket_client.loop()
    except KeyboardInterrupt:
        pass
    except Exception as e:
        print e

    socket_client.shutdown()
def connect_and_stream_market_data(ip, port, contracts):
    try:
        socket_client = SocketClient(ip, port)
        gateway = GatewayInterface(socket_client)
        gateway.set_data_handlers(market_data=on_market_data)

        for contract in contracts:
            gateway.request_market_data(contract)

        socket_client.loop()
    except KeyboardInterrupt:
        pass
    except Exception as e:
        print e

    socket_client.shutdown()
def connect_and_stream_market_data(ip, port, contracts):
    try:
        socket_client = SocketClient(ip, port)
        gateway = GatewayInterface(socket_client)
        gateway.set_data_handlers(market_data=on_market_data)

        for contract in contracts:
            gateway.request_market_data(contract)

        socket_client.loop()
    except KeyboardInterrupt:
        pass
    except Exception as e:
        print e

    socket_client.shutdown()