mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-20 07:14:20 +01:00
examples: add rest create order example
This commit is contained in:
committed by
Jacob Plaster
parent
f6837452fb
commit
9a84dd7114
43
bfxapi/examples/rest/create_order.py
Normal file
43
bfxapi/examples/rest/create_order.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import os
|
||||
import sys
|
||||
import asyncio
|
||||
import time
|
||||
sys.path.append('../')
|
||||
|
||||
from bfxapi import Client
|
||||
|
||||
API_KEY=os.getenv("BFX_KEY")
|
||||
API_SECRET=os.getenv("BFX_SECRET")
|
||||
|
||||
bfx = Client(
|
||||
API_KEY=API_KEY,
|
||||
API_SECRET=API_SECRET,
|
||||
logLevel='DEBUG'
|
||||
)
|
||||
|
||||
async def create_order():
|
||||
response = await bfx.rest.submit_order("tBTCUSD", 10, 0.1)
|
||||
# response is in the form of a Notification object
|
||||
for o in response.notify_info:
|
||||
# each item is in the form of an Order object
|
||||
print ("Order: ", o)
|
||||
|
||||
async def cancel_order():
|
||||
response = await bfx.rest.submit_cancel_order(1185510865)
|
||||
# response is in the form of a Notification object
|
||||
# notify_info is in the form of an order object
|
||||
print ("Order: ", response.notify_info)
|
||||
|
||||
async def update_order():
|
||||
response = await bfx.rest.submit_update_order(1185510771, price=15, amount=0.055)
|
||||
# response is in the form of a Notification object
|
||||
# notify_info is in the form of an order object
|
||||
print ("Order: ", response.notify_info)
|
||||
|
||||
async def run():
|
||||
await create_order()
|
||||
await cancel_order()
|
||||
await update_order()
|
||||
|
||||
t = asyncio.ensure_future(run())
|
||||
asyncio.get_event_loop().run_until_complete(t)
|
||||
Reference in New Issue
Block a user