Skip to content

Commit 92e21ff

Browse files
committed
feat: add OrdersHistory
1 parent 6398438 commit 92e21ff

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2021 Injective Labs
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""Injective Exchange API client for Python. Example only."""
15+
16+
import asyncio
17+
import logging
18+
19+
from pyinjective.async_client import AsyncClient
20+
from pyinjective.constant import Network
21+
22+
async def main() -> None:
23+
network = Network.testnet()
24+
client = AsyncClient(network, insecure=False)
25+
market_id = "0x54d4505adef6a5cef26bc403a33d595620ded4e15b9e2bc3dd489b714813366a"
26+
subaccount_id = "0x1b99514e320ae0087be7f87b1e3057853c43b799000000000000000000000000"
27+
skip = 10
28+
limit = 10
29+
orders = await client.get_historical_derivative_orders(
30+
market_id=market_id,
31+
subaccount_id=subaccount_id,
32+
skip=skip,
33+
limit=limit
34+
)
35+
print(orders)
36+
37+
if __name__ == '__main__':
38+
logging.basicConfig(level=logging.INFO)
39+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Copyright 2021 Injective Labs
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""Injective Exchange API client for Python. Example only."""
15+
16+
import asyncio
17+
import logging
18+
19+
from pyinjective.async_client import AsyncClient
20+
from pyinjective.constant import Network
21+
22+
async def main() -> None:
23+
network = Network.testnet()
24+
client = AsyncClient(network, insecure=False)
25+
market_id = "0xa508cb32923323679f29a032c70342c147c17d0145625922b0ef22e955c844c0"
26+
subaccount_id = "0xed8c4C43E03E24b7F12975472da771Ce2f8b857c000000000000000000000000"
27+
skip = 10
28+
limit = 10
29+
orders = await client.get_historical_spot_orders(
30+
market_id=market_id,
31+
subaccount_id=subaccount_id,
32+
skip=skip,
33+
limit=limit
34+
)
35+
print(orders)
36+
37+
if __name__ == '__main__':
38+
logging.basicConfig(level=logging.INFO)
39+
asyncio.get_event_loop().run_until_complete(main())

pyinjective/async_client.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -591,6 +591,19 @@ async def get_spot_orders(self, market_id: str, **kwargs):
591591
)
592592
return await self.stubSpotExchange.Orders(req)
593593

594+
async def get_historical_spot_orders(self, market_id: str, **kwargs):
595+
req = spot_exchange_rpc_pb.OrdersHistoryRequest(
596+
market_id=market_id,
597+
direction=kwargs.get("direction"),
598+
order_type=kwargs.get("order_type"),
599+
subaccount_id=kwargs.get("subaccount_id"),
600+
skip=kwargs.get("skip"),
601+
limit=kwargs.get("limit"),
602+
start_time=kwargs.get("start_time"),
603+
end_time=kwargs.get("end_time")
604+
)
605+
return await self.stubSpotExchange.OrdersHistory(req)
606+
594607
async def get_spot_trades(self, **kwargs):
595608
req = spot_exchange_rpc_pb.TradesRequest(
596609
market_id=kwargs.get("market_id"),
@@ -693,6 +706,19 @@ async def get_derivative_orders(self, market_id: str, **kwargs):
693706
)
694707
return await self.stubDerivativeExchange.Orders(req)
695708

709+
async def get_historical_derivative_orders(self, market_id: str, **kwargs):
710+
req = derivative_exchange_rpc_pb.OrdersHistoryRequest(
711+
market_id=market_id,
712+
direction=kwargs.get("direction"),
713+
order_type=kwargs.get("order_type"),
714+
subaccount_id=kwargs.get("subaccount_id"),
715+
skip=kwargs.get("skip"),
716+
limit=kwargs.get("limit"),
717+
start_time=kwargs.get("start_time"),
718+
end_time=kwargs.get("end_time")
719+
)
720+
return await self.stubDerivativeExchange.OrdersHistory(req)
721+
696722
async def get_derivative_trades(self, **kwargs):
697723
req = derivative_exchange_rpc_pb.TradesRequest(
698724
market_id=kwargs.get("market_id"),

0 commit comments

Comments
 (0)