mirror of
https://github.com/aljazceru/bitfinex-api-py.git
synced 2025-12-19 23:04:21 +01:00
Objectify orders and order manager
This commit is contained in:
@@ -24,7 +24,8 @@ def now_in_mills():
|
||||
return int(round(time.time() * 1000))
|
||||
|
||||
class Order:
|
||||
def __init__(self, closingOrderArray):
|
||||
def __init__(self, bfxapi, closingOrderArray):
|
||||
self.bfxapi = bfxapi
|
||||
self.id = closingOrderArray[OrderClosedModel.ID]
|
||||
self.gId = closingOrderArray[OrderClosedModel.GID]
|
||||
self.cId = closingOrderArray[OrderClosedModel.CID]
|
||||
@@ -45,11 +46,40 @@ class Order:
|
||||
self.placeId = closingOrderArray[OrderClosedModel.PLACE_ID]
|
||||
self.is_pending_bool = True
|
||||
self.is_confirmed_bool = False
|
||||
self.is_open_bool = False
|
||||
|
||||
async def update(self, price=None, amount=None, delta=None, price_aux_limit=None,
|
||||
price_trailing=None, flags=None, time_in_force=None):
|
||||
payload = { "id": self.id }
|
||||
if price is not None:
|
||||
payload['price'] = str(price)
|
||||
if amount is not None:
|
||||
payload['amount'] = str(amount)
|
||||
if delta is not None:
|
||||
payload['delta'] = str(delta)
|
||||
if price_aux_limit is not None:
|
||||
payload['price_aux_limit'] = str(price_aux_limit)
|
||||
if price_trailing is not None:
|
||||
payload['price_trailing'] = str(price_trailing)
|
||||
if flags is not None:
|
||||
payload['flags'] = str(flags)
|
||||
if time_in_force is not None:
|
||||
payload['time_in_force'] = str(time_in_force)
|
||||
await self.bfxapi._send_auth_command('ou', payload)
|
||||
|
||||
async def close(self):
|
||||
await self.bfxapi._send_auth_command('oc', { 'id': self.id })
|
||||
|
||||
def set_confirmed(self):
|
||||
self.is_pending_bool = False
|
||||
self.is_confirmed_bool = True
|
||||
|
||||
def set_open_state(self, isOpen):
|
||||
self.is_open_bool = isOpen
|
||||
|
||||
def isOpen(self):
|
||||
return self.is_open_bool
|
||||
|
||||
def isPending(self):
|
||||
return self.is_pending_bool
|
||||
|
||||
|
||||
Reference in New Issue
Block a user