Skip to content

Commit a991f44

Browse files
authored
Merge pull request #206 from InjectiveLabs/fix/historical_orders_by_market_ids
fix/historical orders by market ids
2 parents 0f23864 + 8b2c988 commit a991f44

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ make tests
8989
### Changelogs
9090
**0.6.3**(change before release)
9191
* Change logging logic to use different loggers for each module and class
92+
* Solved issue preventing requesting spot and derivative historical orders for more than one market_id
9293
* Add `pytest` as a development dependency to implement and run unit tests
9394

9495
**0.6.2.7**

pyinjective/async_client.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -660,12 +660,15 @@ async def get_spot_orders(self, market_id: str, **kwargs):
660660
)
661661
return await self.stubSpotExchange.Orders(req)
662662

663-
async def get_historical_spot_orders(self, market_id: str, **kwargs):
663+
async def get_historical_spot_orders(self, market_id: Optional[str] = None, **kwargs):
664+
market_ids = kwargs.get("market_ids", [])
665+
if market_id is not None:
666+
market_ids.append(market_id)
664667
req = spot_exchange_rpc_pb.OrdersHistoryRequest(
665-
market_id=market_id,
668+
market_ids=kwargs.get("market_ids", []),
666669
direction=kwargs.get("direction"),
667-
order_types=kwargs.get("order_types"),
668-
execution_types=kwargs.get("execution_types"),
670+
order_types=kwargs.get("order_types", []),
671+
execution_types=kwargs.get("execution_types", []),
669672
subaccount_id=kwargs.get("subaccount_id"),
670673
skip=kwargs.get("skip"),
671674
limit=kwargs.get("limit"),
@@ -820,14 +823,19 @@ async def get_derivative_orders(self, market_id: str, **kwargs):
820823
)
821824
return await self.stubDerivativeExchange.Orders(req)
822825

823-
async def get_historical_derivative_orders(self, market_id: str, **kwargs):
826+
async def get_historical_derivative_orders(self, market_id: Optional[str] = None, **kwargs):
827+
market_ids = kwargs.get("market_ids", [])
828+
if market_id is not None:
829+
market_ids.append(market_id)
830+
order_types = kwargs.get("order_types", [])
831+
order_type = kwargs.get("order_type")
832+
if order_type is not None:
833+
order_types.append(market_id)
824834
req = derivative_exchange_rpc_pb.OrdersHistoryRequest(
825-
market_id=market_id,
826-
market_ids=kwargs.get("market_ids"),
835+
market_ids=market_ids,
827836
direction=kwargs.get("direction"),
828-
order_type=kwargs.get("order_type"),
829-
order_types=kwargs.get("order_types"),
830-
execution_types=kwargs.get("execution_types"),
837+
order_types=order_types,
838+
execution_types=kwargs.get("execution_types", []),
831839
subaccount_id=kwargs.get("subaccount_id"),
832840
is_conditional=kwargs.get("is_conditional"),
833841
skip=kwargs.get("skip"),

0 commit comments

Comments
 (0)