Skip to content

EXC-1670 Added userTradesHistory route #91

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions examples/9.user_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ async def main():
print("User trades:")
pprint(trades)

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

# fetches user account's general data like leverage, pnl etc.
account_data = await client.get_user_account_data()
Expand Down
15 changes: 15 additions & 0 deletions src/firefly_exchange_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,21 @@ async def get_user_trades(self,params:GetUserTradesRequest):
params,
True
)

async def get_user_trades_history(self,params:GetUserTradesHistoryRequest):
"""
Returns a list of user trades history.
Inputs:
params(GetUserTradesHistoryRequest): params to query trades (e.g. symbol)
Returns:
list: a list of positions
"""
params = extract_enums(params,["symbol","type"])
return await self.apis.get(
SERVICE_URLS["USER"]["USER_TRADES_HISTORY"],
params,
True
)

async def get_user_account_data(self, parentAddress:str = ""):
"""
Expand Down
3 changes: 2 additions & 1 deletion src/firefly_exchange_client/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@
"FUND_GAS": "/account/fundGas",
"TRANSFER_HISTORY": "/userTransferHistory",
"FUNDING_HISTORY": "/userFundingHistory",
"CANCEL_ON_DISCONNECT": "/dms-countdown"
"CANCEL_ON_DISCONNECT": "/dms-countdown",
"USER_TRADES_HISTORY": "/userTradesHistory",
},
"ORDERS": {
"ORDERS": "/orders",
Expand Down
11 changes: 11 additions & 0 deletions src/firefly_exchange_client/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,17 @@ class GetUserTradesRequest(TypedDict):
type: ORDER_TYPE
parentAddress: str # (optional) should be provided by sub account

class GetUserTradesHistoryRequest(TypedDict):
symbol: MARKET_SYMBOLS
maker: bool
fromId: int
startTime: int
endTime: int
limit: int
cursor: int
type: ORDER_TYPE
parentAddress: str # (optional) should be provided by sub account

class GetOrderRequest(GetTransactionHistoryRequest):
statuses:List[ORDER_STATUS] # (optional) status of orders to be fetched
orderId: int #(optional) the id of order to be fetched
Expand Down