Skip to content

Commit fabfa01

Browse files
authored
Get Orders Route - Optional API Params (#64)
* bumped to v0.2.2 * examples to invoke get orders method * added order type to get orders * added optional params to get order request --------- Co-authored-by: YameenMalik <[email protected]>
1 parent 09ea91f commit fabfa01

File tree

4 files changed

+64
-3
lines changed

4 files changed

+64
-3
lines changed

examples/17.get_orders.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
'''
2+
This example shows how users can get their orders information.
3+
The get_orders route provides a number of optional params that can be
4+
mixed together to fetch the exact data that user needs.
5+
'''
6+
from config import TEST_ACCT_KEY, TEST_NETWORK
7+
from firefly_exchange_client import FireflyClient, Networks, MARKET_SYMBOLS, ORDER_STATUS, ORDER_TYPE
8+
import asyncio
9+
10+
async def main():
11+
12+
client = FireflyClient(True, Networks[TEST_NETWORK], TEST_ACCT_KEY)
13+
await client.init(True)
14+
15+
16+
print("Get all ETH market orders regardless of their type/status")
17+
orders = await client.get_orders({
18+
"symbol": MARKET_SYMBOLS.ETH,
19+
})
20+
print('Received orders: ', len(orders))
21+
22+
print("Get orders based on status")
23+
orders = await client.get_orders({
24+
"symbol": MARKET_SYMBOLS.ETH,
25+
"statuses": [ORDER_STATUS.OPEN, ORDER_STATUS.PENDING]
26+
})
27+
print('Received orders: ', len(orders))
28+
29+
30+
print("Get an order using id")
31+
orders = await client.get_orders({
32+
"symbol": MARKET_SYMBOLS.ETH,
33+
"orderId": 180318
34+
})
35+
print('Received orders: ', len(orders))
36+
37+
print("Get orders using hashes")
38+
orders = await client.get_orders({
39+
"symbol": MARKET_SYMBOLS.ETH,
40+
"orderHashes": [
41+
"0x21eeb24b0af6832989484e61294db70e8cf8ce0e030c6cfbbb23f3b3d85f9374",
42+
"0xd61fe390f6e6d89a884c73927741ba7d2d024e01f65af61f13363403e805e2c0"]
43+
})
44+
print('Received orders: ', len(orders))
45+
46+
print("Get only MARKET orders")
47+
orders = await client.get_orders({
48+
"symbol": MARKET_SYMBOLS.ETH,
49+
"orderType": [ORDER_TYPE.MARKET]
50+
})
51+
print('Received orders: ', len(orders))
52+
53+
await client.apis.close_session();
54+
55+
56+
if __name__ == "__main__":
57+
event_loop = asyncio.get_event_loop()
58+
event_loop.run_until_complete(main())

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "firefly_exchange_client"
3-
version = "0.2.1"
3+
version = "0.2.2"
44
description = "Library to interact with firefly exchange protocol including its off-chain api-gateway and on-chain contracts"
55
readme = "README.md"
66
requires-python = ">=3.8"

src/firefly_exchange_client/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ async def get_orders(self,params:GetOrderRequest):
706706
Returns:
707707
- list: a list of orders
708708
"""
709-
params = extract_enums(params,["symbol","statuses"])
709+
params = extract_enums(params,["symbol","statuses", "orderType"])
710710

711711
return await self.apis.get(
712712
SERVICE_URLS["USER"]["ORDERS"],

src/firefly_exchange_client/interfaces.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ class GetUserTradesRequest(TypedDict):
134134
parentAddress: str # (optional) should be provided by sub account
135135

136136
class GetOrderRequest(GetTransactionHistoryRequest):
137-
statuses:List[ORDER_STATUS] # status of orders to be fetched
137+
statuses:List[ORDER_STATUS] # (optional) status of orders to be fetched
138+
orderId: int #(optional) the id of order to be fetched
139+
orderType: List[ORDER_TYPE]; # (optional) type of order Limit/Market
140+
orderHashes: List[str] # (optional) hashes of order to be fetched
138141
parentAddress : str # (optional) should be provided by sub accounts
139142

140143
class GetFundingHistoryRequest(TypedDict):

0 commit comments

Comments
 (0)