mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 14:54:21 +01:00
examples: update examples with new ordermanager
This commit is contained in:
@@ -10,14 +10,24 @@ API_SECRET=os.getenv("BFX_SECRET")
|
||||
bfx = Client(
|
||||
API_KEY=API_KEY,
|
||||
API_SECRET=API_SECRET,
|
||||
logLevel='INFO'
|
||||
logLevel='DEBUG'
|
||||
)
|
||||
|
||||
@bfx.ws.on('order_snapshot')
|
||||
async def close_all(data):
|
||||
await bfx.ws.close_all_orders()
|
||||
|
||||
@bfx.ws.on('order_confirmed')
|
||||
def trade_completed(order, trade):
|
||||
async def trade_completed(order, trade):
|
||||
print ("Order confirmed.")
|
||||
print (order)
|
||||
print (trade)
|
||||
## close the order
|
||||
# await order.close()
|
||||
# or
|
||||
# await bfx.ws.close_order(order.id)
|
||||
# or
|
||||
# await bfx.ws.close_all_orders()
|
||||
|
||||
@bfx.ws.on('error')
|
||||
def log_error(msg):
|
||||
@@ -25,7 +35,7 @@ def log_error(msg):
|
||||
|
||||
@bfx.ws.on('authenticated')
|
||||
async def submit_order(auth_message):
|
||||
await bfx.ws.submit_order('tBTCUSD', 0, 0.01, 'EXCHANGE MARKET')
|
||||
await bfx.ws.submit_order('tBTCUSD', 19000, 0.01, 'EXCHANGE LIMIT')
|
||||
|
||||
# If you dont want to use a decorator
|
||||
# ws.on('authenticated', submit_order)
|
||||
|
||||
@@ -10,7 +10,7 @@ API_SECRET=os.getenv("BFX_SECRET")
|
||||
bfx = Client(
|
||||
API_KEY=API_KEY,
|
||||
API_SECRET=API_SECRET,
|
||||
logLevel='INFO'
|
||||
logLevel='DEBUG'
|
||||
)
|
||||
|
||||
@bfx.ws.on('order_update')
|
||||
@@ -19,6 +19,11 @@ def order_updated(order, trade):
|
||||
print (order)
|
||||
print (trade)
|
||||
|
||||
@bfx.ws.once('order_update')
|
||||
async def order_once_updated(order, trade):
|
||||
# update a second time using the object function
|
||||
await order.update(price=80, amount=0.02, flags="2nd update")
|
||||
|
||||
@bfx.ws.once('order_confirmed')
|
||||
async def trade_completed(order, trade):
|
||||
print ("Order confirmed.")
|
||||
|
||||
Reference in New Issue
Block a user