Change examples to use new Client module

This commit is contained in:
Jacob Plaster
2018-11-19 16:50:40 +00:00
parent 4be08dfa43
commit 02e232362b
6 changed files with 45 additions and 45 deletions

View File

@@ -2,27 +2,27 @@ import os
import sys
sys.path.append('../')
from bfxapi.websockets.LiveWebsocket import LiveBfxWebsocket
from bfxapi import Client
ws = LiveBfxWebsocket(
bfx = Client(
logLevel='INFO'
)
@ws.on('error')
@bfx.ws.on('error')
def log_error(err):
print ("Error: {}".format(err))
@ws.on('new_candle')
@bfx.ws.on('new_candle')
def log_candle(candle):
print ("New candle: {}".format(candle))
@ws.on('new_trade')
@bfx.ws.on('new_trade')
def log_trade(trade):
print ("New trade: {}".format(trade))
def start():
ws.subscribe('candles', 'tBTCUSD', timeframe='1m')
ws.subscribe('trades', 'tBTCUSD')
bfx.ws.subscribe('candles', 'tBTCUSD', timeframe='1m')
bfx.ws.subscribe('trades', 'tBTCUSD')
ws.on('connected', start)
ws.run()
bfx.ws.on('connected', start)
bfx.ws.run()