Skip to content

Commit 7086d47

Browse files
EXC-1670 Added userTradesHistory route (#91)
* added route * func name fix
1 parent d6eff2e commit 7086d47

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

examples/9.user_data.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ async def main():
4646
print("User trades:")
4747
pprint(trades)
4848

49+
# fetches user trades
50+
trades = await client.get_user_trades_history({"symbol":MARKET_SYMBOLS.BTC})
51+
print("User trades history:")
52+
pprint(trades["data"])
4953

5054
# fetches user account's general data like leverage, pnl etc.
5155
account_data = await client.get_user_account_data()

src/firefly_exchange_client/client.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -878,6 +878,21 @@ async def get_user_trades(self,params:GetUserTradesRequest):
878878
params,
879879
True
880880
)
881+
882+
async def get_user_trades_history(self,params:GetUserTradesHistoryRequest):
883+
"""
884+
Returns a list of user trades history.
885+
Inputs:
886+
params(GetUserTradesHistoryRequest): params to query trades (e.g. symbol)
887+
Returns:
888+
list: a list of positions
889+
"""
890+
params = extract_enums(params,["symbol","type"])
891+
return await self.apis.get(
892+
SERVICE_URLS["USER"]["USER_TRADES_HISTORY"],
893+
params,
894+
True
895+
)
881896

882897
async def get_user_account_data(self, parentAddress:str = ""):
883898
"""

src/firefly_exchange_client/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@
9292
"FUND_GAS": "/account/fundGas",
9393
"TRANSFER_HISTORY": "/userTransferHistory",
9494
"FUNDING_HISTORY": "/userFundingHistory",
95-
"CANCEL_ON_DISCONNECT": "/dms-countdown"
95+
"CANCEL_ON_DISCONNECT": "/dms-countdown",
96+
"USER_TRADES_HISTORY": "/userTradesHistory",
9697
},
9798
"ORDERS": {
9899
"ORDERS": "/orders",

src/firefly_exchange_client/interfaces.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ class GetUserTradesRequest(TypedDict):
134134
type: ORDER_TYPE
135135
parentAddress: str # (optional) should be provided by sub account
136136

137+
class GetUserTradesHistoryRequest(TypedDict):
138+
symbol: MARKET_SYMBOLS
139+
maker: bool
140+
fromId: int
141+
startTime: int
142+
endTime: int
143+
limit: int
144+
cursor: int
145+
type: ORDER_TYPE
146+
parentAddress: str # (optional) should be provided by sub account
147+
137148
class GetOrderRequest(GetTransactionHistoryRequest):
138149
statuses:List[ORDER_STATUS] # (optional) status of orders to be fetched
139150
orderId: int #(optional) the id of order to be fetched

0 commit comments

Comments
 (0)