refactor submit

_limit and expore the 'paper' like feature
no_orderid_in_error
Konstantine Tsafatinos 2022-04-11 21:23:28 -04:00
parent 250d9cbc03
commit 59434b9a8a
1 changed files with 11 additions and 20 deletions

View File

@ -300,42 +300,34 @@ class Client:
async def submit_limit( async def submit_limit(
self, self,
oid: str,
symbol: str, symbol: str,
price: float, price: float,
action: str, action: str,
size: float, size: float,
reqid: str = None, reqid: str = None,
validate: bool = False # set True test call without a real submission
) -> dict: ) -> dict:
''' '''
Place an order and return integer request id provided by client. Place an order and return integer request id provided by client.
''' '''
# Build common data dict for common keys from both endpoints
data = {
"pair": symbol,
"price": str(price),
"validate": validate
}
if reqid is None: if reqid is None:
# Build order data for kraken api # Build order data for kraken api
data = { data["ordertype"] = "limit"
"ordertype": "limit", data["type"] = action
"type": action, data["volume"] = str(size)
"volume": str(size),
"pair": symbol,
"price": str(price),
# set to True test AddOrder call without a real submission
"validate": False
}
return await self.endpoint('AddOrder', data) return await self.endpoint('AddOrder', data)
else: else:
# Edit order data for kraken api # Edit order data for kraken api
data = { data["txid"] = reqid
"txid": reqid,
"pair": symbol,
"price": str(price),
# set to True test EditOrder call without a real submission
"validate": False
}
return await self.endpoint('EditOrder', data) return await self.endpoint('EditOrder', data)
async def submit_cancel( async def submit_cancel(
self, self,
reqid: str, reqid: str,
@ -581,7 +573,6 @@ async def handle_order_requests(
order = BrokerdOrder(**request_msg) order = BrokerdOrder(**request_msg)
# call our client api to submit the order # call our client api to submit the order
resp = await client.submit_limit( resp = await client.submit_limit(
oid=order.oid,
symbol=order.symbol, symbol=order.symbol,
price=order.price, price=order.price,
action=order.action, action=order.action,