예제 #1
0
    def setUp(self):
        self.skipIfBase()
        super().setUp()

        if self.is_rest:
            self.client = create_rest_client(self.platform_id, version=self.version)
            self.client_authed = create_rest_client(self.platform_id, True, self.version)
        else:
            self.client = create_ws_client(self.platform_id, version=self.version)
            self.client_authed = create_ws_client(self.platform_id, True, self.version)
예제 #2
0
# set_up_logging()

# Change to Platform.BINANCE to see example
TEST_PLATFORM = Platform.OKEX

TEST_SYMBOLS = {
    Platform.BINANCE: ['ETHBTC', 'BTCUSDT'],
    Platform.OKEX: ['eth_btc', 'btc_usdt'],
}

client = utils.create_rest_client(platform_id=TEST_PLATFORM)
print('\n\nTrade history\n\n')
print(client.fetch_trades_history(TEST_SYMBOLS[TEST_PLATFORM][0], limit=10))
print('\n\n---------------------')
print('\n\nCandles\n\n')
print(
    client.fetch_candles(TEST_SYMBOLS[TEST_PLATFORM][0],
                         Interval.MIN_1,
                         limit=10))
print('\n\n---------------------')

client = utils.create_ws_client(platform_id=TEST_PLATFORM)
client.on_data_item = lambda item: print(item)  # print received parsed objects
client.subscribe(endpoints=[Endpoint.TRADE, Endpoint.CANDLE],
                 symbols=TEST_SYMBOLS[TEST_PLATFORM],
                 interval=Interval.MIN_1)

print('\n\nWebsocket data\n\n')
# Sleep to display incoming websocket items from separate thread
time.sleep(15)