diff --git a/README.md b/README.md index 7b958c44..088462ba 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/examples/exchange_client/derivative_exchange_rpc/10_StreamOrders.py b/examples/exchange_client/derivative_exchange_rpc/10_StreamHistoricalOrders.py similarity index 80% rename from examples/exchange_client/derivative_exchange_rpc/10_StreamOrders.py rename to examples/exchange_client/derivative_exchange_rpc/10_StreamHistoricalOrders.py index 00164558..b184487a 100644 --- a/examples/exchange_client/derivative_exchange_rpc/10_StreamOrders.py +++ b/examples/exchange_client/derivative_exchange_rpc/10_StreamHistoricalOrders.py @@ -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) diff --git a/examples/exchange_client/derivative_exchange_rpc/6_Orders.py b/examples/exchange_client/derivative_exchange_rpc/6_Orders.py deleted file mode 100644 index bf5984ed..00000000 --- a/examples/exchange_client/derivative_exchange_rpc/6_Orders.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2021 Injective Labs -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Injective Exchange API client for Python. Example only.""" - -import asyncio -import logging - -from pyinjective.async_client import AsyncClient -from pyinjective.constant import Network - -async def main() -> None: - network = Network.testnet() - client = AsyncClient(network, insecure=False) - market_id = "0x4ca0f92fc28be0c9761326016b5a1a2177dd6375558365116b5bdda9abc229ce" - order_side = "buy" # buy or sell - subaccount_id = "0xc6fe5d33615a1c52c08018c47e8bc53646a0e101000000000000000000000000" - skip = 10 - limit = 10 - orders = await client.get_derivative_orders( - market_id=market_id, - order_side=order_side, - subaccount_id=subaccount_id, - skip=skip, - limit=limit - ) - print(orders) - -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) - asyncio.get_event_loop().run_until_complete(main()) diff --git a/examples/exchange_client/spot_exchange_rpc/5_Orders.py b/examples/exchange_client/spot_exchange_rpc/5_Orders.py deleted file mode 100644 index 2328926c..00000000 --- a/examples/exchange_client/spot_exchange_rpc/5_Orders.py +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2021 Injective Labs -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -"""Injective Exchange API client for Python. Example only.""" - -import asyncio -import logging - -from pyinjective.async_client import AsyncClient -from pyinjective.constant import Network - -async def main() -> None: - network = Network.testnet() - client = AsyncClient(network, insecure=False) - market_id = "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0" - order_side = "sell" # buy or sell - subaccount_id = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000" - skip = 10 - limit = 10 - orders = await client.get_spot_orders( - market_id=market_id, - order_side=order_side, - subaccount_id=subaccount_id, - skip=skip, - limit=limit - ) - print(orders) - -if __name__ == '__main__': - logging.basicConfig(level=logging.INFO) - asyncio.get_event_loop().run_until_complete(main()) diff --git a/examples/exchange_client/spot_exchange_rpc/8_StreamOrders.py b/examples/exchange_client/spot_exchange_rpc/8_StreamHistoricalOrders.py similarity index 91% rename from examples/exchange_client/spot_exchange_rpc/8_StreamOrders.py rename to examples/exchange_client/spot_exchange_rpc/8_StreamHistoricalOrders.py index 3383245a..a5061df9 100644 --- a/examples/exchange_client/spot_exchange_rpc/8_StreamOrders.py +++ b/examples/exchange_client/spot_exchange_rpc/8_StreamHistoricalOrders.py @@ -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) diff --git a/pyinjective/async_client.py b/pyinjective/async_client.py index e737532e..203d04b9 100644 --- a/pyinjective/async_client.py +++ b/pyinjective/async_client.py @@ -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"), @@ -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"), @@ -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"), diff --git a/setup.py b/setup.py index 50b5004e..078b33cd 100755 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ EMAIL = "achilleas@injectivelabs.com" AUTHOR = "Injective Labs" REQUIRES_PYTHON = ">=3.7.0" -VERSION = "0.5.8.4" +VERSION = "0.5.8.5" REQUIRED = [ "grpcio",