Skip to content

Commit 5102595

Browse files
Merge pull request #154 from InjectiveLabs/f/add_historical_orders_methods
F/add historical orders methods
2 parents 789137c + 9db6f7b commit 5102595

File tree

7 files changed

+39
-92
lines changed

7 files changed

+39
-92
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ Note that the [sync client](https://github.com/InjectiveLabs/sdk-python/blob/mas
7878

7979

8080
### Changelogs
81+
**0.5.8.5**
82+
* Add StreamOrdersHistory
83+
* Add more request params in OrdersHistory
84+
8185
**0.5.8.4**
8286
* Adjust block and timeouts to new block time
8387
* Set explicit version for protobuf and grpcio-tool dependencies

examples/exchange_client/derivative_exchange_rpc/10_StreamOrders.py renamed to examples/exchange_client/derivative_exchange_rpc/10_StreamHistoricalOrders.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@
2222
async def main() -> None:
2323
network = Network.testnet()
2424
client = AsyncClient(network, insecure=False)
25-
market_id = "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce"
26-
order_side = "buy" # buy or sell
25+
market_id = "0x1c79dac019f73e4060494ab1b4fcba734350656d6fc4d474f6a238c13c6f9ced"
26+
order_side = "sell" # sell or buy
2727
subaccount_id = "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000"
28-
orders = await client.stream_derivative_orders(
29-
market_id=market_id,
30-
order_side=order_side,
31-
subaccount_id=subaccount_id
28+
orders = await client.stream_historical_derivative_orders(
29+
market_id=market_id
3230
)
3331
async for order in orders:
3432
print(order)

examples/exchange_client/derivative_exchange_rpc/6_Orders.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

examples/exchange_client/spot_exchange_rpc/5_Orders.py

Lines changed: 0 additions & 41 deletions
This file was deleted.

examples/exchange_client/spot_exchange_rpc/8_StreamOrders.py renamed to examples/exchange_client/spot_exchange_rpc/8_StreamHistoricalOrders.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ async def main() -> None:
2525
market_id = "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0"
2626
order_side = "sell" # sell or buy
2727
subaccount_id = "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000"
28-
orders = await client.stream_spot_orders(
28+
limit = 2
29+
orders = await client.stream_historical_spot_orders(
2930
market_id=market_id,
30-
order_side=order_side,
31-
subaccount_id=subaccount_id
31+
limit=limit
3232
)
3333
async for order in orders:
3434
print(order)

pyinjective/async_client.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ async def get_historical_spot_orders(self, market_id: str, **kwargs):
618618
market_id=market_id,
619619
direction=kwargs.get("direction"),
620620
order_types=kwargs.get("order_types"),
621+
execution_types=kwargs.get("execution_types"),
621622
subaccount_id=kwargs.get("subaccount_id"),
622623
skip=kwargs.get("skip"),
623624
limit=kwargs.get("limit"),
@@ -661,6 +662,30 @@ async def stream_spot_orders(self, market_id: str, **kwargs):
661662
metadata = await self.load_cookie(type="exchange")
662663
return self.stubSpotExchange.StreamOrders.__call__(req, metadata=metadata)
663664

665+
async def stream_historical_spot_orders(self, market_id: str, **kwargs):
666+
req = spot_exchange_rpc_pb.StreamOrdersHistoryRequest(
667+
market_id=market_id,
668+
direction=kwargs.get("direction"),
669+
subaccount_id=kwargs.get("subaccount_id"),
670+
order_types=kwargs.get("order_types"),
671+
state=kwargs.get("state"),
672+
execution_types=kwargs.get("execution_types")
673+
)
674+
metadata = await self.load_cookie(type="exchange")
675+
return self.stubSpotExchange.StreamOrdersHistory.__call__(req, metadata=metadata)
676+
677+
async def stream_historical_derivative_orders(self, market_id: str, **kwargs):
678+
req = derivative_exchange_rpc_pb.StreamOrdersHistoryRequest(
679+
market_id=market_id,
680+
direction=kwargs.get("direction"),
681+
subaccount_id=kwargs.get("subaccount_id"),
682+
order_types=kwargs.get("order_types"),
683+
state=kwargs.get("state"),
684+
execution_types=kwargs.get("execution_types")
685+
)
686+
metadata = await self.load_cookie(type="exchange")
687+
return self.stubDerivativeExchange.StreamOrdersHistory.__call__(req, metadata=metadata)
688+
664689
async def stream_spot_trades(self, **kwargs):
665690
req = spot_exchange_rpc_pb.StreamTradesRequest(
666691
market_id=kwargs.get("market_id"),
@@ -738,7 +763,9 @@ async def get_historical_derivative_orders(self, market_id: str, **kwargs):
738763
market_id=market_id,
739764
direction=kwargs.get("direction"),
740765
order_types=kwargs.get("order_types"),
766+
execution_types=kwargs.get("execution_types"),
741767
subaccount_id=kwargs.get("subaccount_id"),
768+
is_conditional=kwargs.get("is_conditional"),
742769
skip=kwargs.get("skip"),
743770
limit=kwargs.get("limit"),
744771
start_time=kwargs.get("start_time"),

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
1818
AUTHOR = "Injective Labs"
1919
REQUIRES_PYTHON = ">=3.7.0"
20-
VERSION = "0.5.8.4"
20+
VERSION = "0.5.8.5"
2121

2222
REQUIRED = [
2323
"grpcio",

0 commit comments

Comments
 (0)