Skip to content

Commit

Permalink
Merge pull request #154 from InjectiveLabs/f/add_historical_orders_me…
Browse files Browse the repository at this point in the history
…thods

F/add historical orders methods
  • Loading branch information
achilleas-kal committed Oct 11, 2022
2 parents 789137c + 9db6f7b commit 5102595
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 92 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ Note that the [sync client](https://github.com/InjectiveLabs/sdk-python/blob/mas


### Changelogs
**0.5.8.5**
* Add StreamOrdersHistory
* Add more request params in OrdersHistory

**0.5.8.4**
* Adjust block and timeouts to new block time
* Set explicit version for protobuf and grpcio-tool dependencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@
async def main() -> None:
network = Network.testnet()
client = AsyncClient(network, insecure=False)
market_id = "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce"
order_side = "buy" # buy or sell
market_id = "0x1c79dac019f73e4060494ab1b4fcba734350656d6fc4d474f6a238c13c6f9ced"
order_side = "sell" # sell or buy
subaccount_id = "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000"
orders = await client.stream_derivative_orders(
market_id=market_id,
order_side=order_side,
subaccount_id=subaccount_id
orders = await client.stream_historical_derivative_orders(
market_id=market_id
)
async for order in orders:
print(order)
Expand Down
41 changes: 0 additions & 41 deletions examples/exchange_client/derivative_exchange_rpc/6_Orders.py

This file was deleted.

41 changes: 0 additions & 41 deletions examples/exchange_client/spot_exchange_rpc/5_Orders.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ async def main() -> None:
market_id = "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0"
order_side = "sell" # sell or buy
subaccount_id = "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000"
orders = await client.stream_spot_orders(
limit = 2
orders = await client.stream_historical_spot_orders(
market_id=market_id,
order_side=order_side,
subaccount_id=subaccount_id
limit=limit
)
async for order in orders:
print(order)
Expand Down
27 changes: 27 additions & 0 deletions pyinjective/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ async def get_historical_spot_orders(self, market_id: str, **kwargs):
market_id=market_id,
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"),
Expand Down Expand Up @@ -661,6 +662,30 @@ async def stream_spot_orders(self, market_id: str, **kwargs):
metadata = await self.load_cookie(type="exchange")
return self.stubSpotExchange.StreamOrders.__call__(req, metadata=metadata)

async def stream_historical_spot_orders(self, market_id: str, **kwargs):
req = spot_exchange_rpc_pb.StreamOrdersHistoryRequest(
market_id=market_id,
direction=kwargs.get("direction"),
subaccount_id=kwargs.get("subaccount_id"),
order_types=kwargs.get("order_types"),
state=kwargs.get("state"),
execution_types=kwargs.get("execution_types")
)
metadata = await self.load_cookie(type="exchange")
return self.stubSpotExchange.StreamOrdersHistory.__call__(req, metadata=metadata)

async def stream_historical_derivative_orders(self, market_id: str, **kwargs):
req = derivative_exchange_rpc_pb.StreamOrdersHistoryRequest(
market_id=market_id,
direction=kwargs.get("direction"),
subaccount_id=kwargs.get("subaccount_id"),
order_types=kwargs.get("order_types"),
state=kwargs.get("state"),
execution_types=kwargs.get("execution_types")
)
metadata = await self.load_cookie(type="exchange")
return self.stubDerivativeExchange.StreamOrdersHistory.__call__(req, metadata=metadata)

async def stream_spot_trades(self, **kwargs):
req = spot_exchange_rpc_pb.StreamTradesRequest(
market_id=kwargs.get("market_id"),
Expand Down Expand Up @@ -738,7 +763,9 @@ async def get_historical_derivative_orders(self, market_id: str, **kwargs):
market_id=market_id,
direction=kwargs.get("direction"),
order_types=kwargs.get("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"),
start_time=kwargs.get("start_time"),
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
EMAIL = "[email protected]"
AUTHOR = "Injective Labs"
REQUIRES_PYTHON = ">=3.7.0"
VERSION = "0.5.8.4"
VERSION = "0.5.8.5"

REQUIRED = [
"grpcio",
Expand Down

0 comments on commit 5102595

Please sign in to comment.