Skip to content

Commit

Permalink
Merge pull request #266 from InjectiveLabs/fix/add_missing_parameters…
Browse files Browse the repository at this point in the history
…_in_spot_and_deriv_messages

Fix/add missing parameters in spot and deriv messages
  • Loading branch information
aarmoa committed Nov 8, 2023
2 parents 05505fe + 96e7f4c commit e4beb6e
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 133 deletions.
102 changes: 83 additions & 19 deletions pyinjective/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,40 +515,57 @@ async def get_spot_orders(self, market_id: str, **kwargs):
subaccount_id=kwargs.get("subaccount_id"),
skip=kwargs.get("skip"),
limit=kwargs.get("limit"),
start_time=kwargs.get("start_time"),
end_time=kwargs.get("end_time"),
market_ids=kwargs.get("market_ids"),
include_inactive=kwargs.get("include_inactive"),
subaccount_total_orders=kwargs.get("subaccount_total_orders"),
trade_id=kwargs.get("trade_id"),
cid=kwargs.get("cid"),
)
return await self.stubSpotExchange.Orders(req)

async def get_historical_spot_orders(self, market_id: Optional[str] = None, **kwargs):
market_ids = kwargs.get("market_ids", [])
if market_id is not None:
market_ids.append(market_id)
order_types = kwargs.get("order_types", [])
order_type = kwargs.get("order_type")
if order_type is not None:
order_types.append(market_id)
req = spot_exchange_rpc_pb.OrdersHistoryRequest(
market_ids=kwargs.get("market_ids", []),
direction=kwargs.get("direction"),
order_types=kwargs.get("order_types", []),
execution_types=kwargs.get("execution_types", []),
subaccount_id=kwargs.get("subaccount_id"),
skip=kwargs.get("skip"),
limit=kwargs.get("limit"),
order_types=order_types,
direction=kwargs.get("direction"),
start_time=kwargs.get("start_time"),
end_time=kwargs.get("end_time"),
state=kwargs.get("state"),
execution_types=kwargs.get("execution_types", []),
market_ids=market_ids,
trade_id=kwargs.get("trade_id"),
active_markets_only=kwargs.get("active_markets_only"),
cid=kwargs.get("cid"),
)
return await self.stubSpotExchange.OrdersHistory(req)

async def get_spot_trades(self, **kwargs):
req = spot_exchange_rpc_pb.TradesRequest(
market_id=kwargs.get("market_id"),
market_ids=kwargs.get("market_ids"),
execution_side=kwargs.get("execution_side"),
direction=kwargs.get("direction"),
subaccount_id=kwargs.get("subaccount_id"),
subaccount_ids=kwargs.get("subaccount_ids"),
skip=kwargs.get("skip"),
limit=kwargs.get("limit"),
start_time=kwargs.get("start_time"),
end_time=kwargs.get("end_time"),
market_ids=kwargs.get("market_ids"),
subaccount_ids=kwargs.get("subaccount_ids"),
execution_types=kwargs.get("execution_types"),
trade_id=kwargs.get("trade_id"),
account_address=kwargs.get("account_address"),
cid=kwargs.get("cid"),
)
return await self.stubSpotExchange.Trades(req)

Expand All @@ -571,6 +588,15 @@ async def stream_spot_orders(self, market_id: str, **kwargs):
market_id=market_id,
order_side=kwargs.get("order_side"),
subaccount_id=kwargs.get("subaccount_id"),
skip=kwargs.get("skip"),
limit=kwargs.get("limit"),
start_time=kwargs.get("start_time"),
end_time=kwargs.get("end_time"),
market_ids=kwargs.get("market_ids"),
include_inactive=kwargs.get("include_inactive"),
subaccount_total_orders=kwargs.get("subaccount_total_orders"),
trade_id=kwargs.get("trade_id"),
cid=kwargs.get("cid"),
)
metadata = await self.network.exchange_metadata(
metadata_query_provider=self._exchange_cookie_metadata_requestor
Expand Down Expand Up @@ -608,12 +634,19 @@ async def stream_historical_derivative_orders(self, market_id: str, **kwargs):
async def stream_spot_trades(self, **kwargs):
req = spot_exchange_rpc_pb.StreamTradesRequest(
market_id=kwargs.get("market_id"),
market_ids=kwargs.get("market_ids"),
execution_side=kwargs.get("execution_side"),
direction=kwargs.get("direction"),
subaccount_id=kwargs.get("subaccount_id"),
skip=kwargs.get("skip"),
limit=kwargs.get("limit"),
start_time=kwargs.get("start_time"),
end_time=kwargs.get("end_time"),
market_ids=kwargs.get("market_ids"),
subaccount_ids=kwargs.get("subaccount_ids"),
execution_types=kwargs.get("execution_types"),
trade_id=kwargs.get("trade_id"),
account_address=kwargs.get("account_address"),
cid=kwargs.get("cid"),
)
metadata = await self.network.exchange_metadata(
metadata_query_provider=self._exchange_cookie_metadata_requestor
Expand Down Expand Up @@ -679,6 +712,15 @@ async def get_derivative_orders(self, market_id: str, **kwargs):
subaccount_id=kwargs.get("subaccount_id"),
skip=kwargs.get("skip"),
limit=kwargs.get("limit"),
start_time=kwargs.get("start_time"),
end_time=kwargs.get("end_time"),
market_ids=kwargs.get("market_ids"),
is_conditional=kwargs.get("is_conditional"),
order_type=kwargs.get("order_type"),
include_inactive=kwargs.get("include_inactive"),
subaccount_total_orders=kwargs.get("subaccount_total_orders"),
trade_id=kwargs.get("trade_id"),
cid=kwargs.get("cid"),
)
return await self.stubDerivativeExchange.Orders(req)

Expand All @@ -691,33 +733,39 @@ async def get_historical_derivative_orders(self, market_id: Optional[str] = None
if order_type is not None:
order_types.append(market_id)
req = derivative_exchange_rpc_pb.OrdersHistoryRequest(
market_ids=market_ids,
direction=kwargs.get("direction"),
order_types=order_types,
execution_types=kwargs.get("execution_types", []),
subaccount_id=kwargs.get("subaccount_id"),
is_conditional=kwargs.get("is_conditional"),
skip=kwargs.get("skip"),
limit=kwargs.get("limit"),
order_types=order_types,
direction=kwargs.get("direction"),
start_time=kwargs.get("start_time"),
end_time=kwargs.get("end_time"),
is_conditional=kwargs.get("is_conditional"),
state=kwargs.get("state"),
execution_types=kwargs.get("execution_types", []),
market_ids=market_ids,
trade_id=kwargs.get("trade_id"),
active_markets_only=kwargs.get("active_markets_only"),
cid=kwargs.get("cid"),
)
return await self.stubDerivativeExchange.OrdersHistory(req)

async def get_derivative_trades(self, **kwargs):
req = derivative_exchange_rpc_pb.TradesRequest(
market_id=kwargs.get("market_id"),
market_ids=kwargs.get("market_ids"),
subaccount_id=kwargs.get("subaccount_id"),
subaccount_ids=kwargs.get("subaccount_ids"),
execution_side=kwargs.get("execution_side"),
direction=kwargs.get("direction"),
subaccount_id=kwargs.get("subaccount_id"),
skip=kwargs.get("skip"),
limit=kwargs.get("limit"),
start_time=kwargs.get("start_time"),
end_time=kwargs.get("end_time"),
market_ids=kwargs.get("market_ids"),
subaccount_ids=kwargs.get("subaccount_ids"),
execution_types=kwargs.get("execution_types"),
trade_id=kwargs.get("trade_id"),
account_address=kwargs.get("account_address"),
cid=kwargs.get("cid"),
)
return await self.stubDerivativeExchange.Trades(req)

Expand All @@ -738,8 +786,19 @@ async def stream_derivative_orderbook_update(self, market_ids: List[str]):
async def stream_derivative_orders(self, market_id: str, **kwargs):
req = derivative_exchange_rpc_pb.StreamOrdersRequest(
market_id=market_id,
order_side=kwargs.get("order_side"),
execution_side=kwargs.get("execution_side"),
direction=kwargs.get("direction"),
subaccount_id=kwargs.get("subaccount_id"),
skip=kwargs.get("skip"),
limit=kwargs.get("limit"),
start_time=kwargs.get("start_time"),
end_time=kwargs.get("end_time"),
market_ids=kwargs.get("market_ids"),
subaccount_ids=kwargs.get("subaccount_ids"),
execution_types=kwargs.get("execution_types"),
trade_id=kwargs.get("trade_id"),
account_address=kwargs.get("account_address"),
cid=kwargs.get("cid"),
)
metadata = await self.network.exchange_metadata(
metadata_query_provider=self._exchange_cookie_metadata_requestor
Expand All @@ -749,14 +808,19 @@ async def stream_derivative_orders(self, market_id: str, **kwargs):
async def stream_derivative_trades(self, **kwargs):
req = derivative_exchange_rpc_pb.StreamTradesRequest(
market_id=kwargs.get("market_id"),
market_ids=kwargs.get("market_ids"),
subaccount_id=kwargs.get("subaccount_id"),
subaccount_ids=kwargs.get("subaccount_ids"),
execution_side=kwargs.get("execution_side"),
direction=kwargs.get("direction"),
subaccount_id=kwargs.get("subaccount_id"),
skip=kwargs.get("skip"),
limit=kwargs.get("limit"),
start_time=kwargs.get("start_time"),
end_time=kwargs.get("end_time"),
market_ids=kwargs.get("market_ids"),
subaccount_ids=kwargs.get("subaccount_ids"),
execution_types=kwargs.get("execution_types"),
trade_id=kwargs.get("trade_id"),
account_address=kwargs.get("account_address"),
cid=kwargs.get("cid"),
)
metadata = await self.network.exchange_metadata(
metadata_query_provider=self._exchange_cookie_metadata_requestor
Expand Down
Loading

0 comments on commit e4beb6e

Please sign in to comment.