Skip to content

Commit 1754629

Browse files
Merge pull request #5 from InjectiveLabs/examples
Add Python Examples for Exchange API
2 parents ac54f6e + f001b54 commit 1754629

37 files changed

+934
-557
lines changed

examples/exchange_api_examples/accounts_rpc/1_StreamSubaccountBalanceRequest.py

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,20 @@
1717
import logging
1818
import grpc
1919

20-
21-
from injective.exchange_api import injective_accounts_rpc_pb2 as accounts_rpc_pb
22-
from injective.exchange_api import injective_accounts_rpc_pb2_grpc as accounts_rpc_grpc
23-
from injective.exchange_api import injective_derivative_exchange_rpc_pb2 as derivative_exchange_rpc_pb
24-
from injective.exchange_api import injective_derivative_exchange_rpc_pb2_grpc as derivative_exchange_rpc_grpc
25-
from injective.exchange_api import injective_exchange_rpc_pb2 as exchange_rpc_pb
26-
from injective.exchange_api import injective_exchange_rpc_pb2_grpc as exchange_rpc_grpc
27-
from injective.exchange_api import injective_insurance_rpc_pb2 as insurance_rpc_pb
28-
from injective.exchange_api import injective_insurance_rpc_pb2_grpc as insurance_rpc_grpc
29-
from injective.exchange_api import injective_oracle_rpc_pb2 as oracle_rpc_pb
30-
from injective.exchange_api import injective_oracle_rpc_pb2_grpc as oracle_rpc_grpc
31-
from injective.exchange_api import injective_spot_exchange_rpc_pb2 as spot_exchange_rpc_pb
32-
from injective.exchange_api import injective_spot_exchange_rpc_pb2_grpc as spot_exchange_rpc_grpc
33-
20+
import injective.exchange_api.injective_accounts_rpc_pb2 as accounts_rpc_pb
21+
import injective.exchange_api.injective_accounts_rpc_pb2_grpc as accounts_rpc_grpc
3422

3523
async def main() -> None:
36-
async with grpc.aio.insecure_channel('localhost:9910') as channel:
37-
accounts_rpc = accounts_rpc_grpc.InjectiveAccountsRPCStub(channel)
24+
async with grpc.aio.insecure_channel('testnet-sentry0.injective.network:9910') as channel:
3825
accounts_exchange_rpc = accounts_rpc_grpc.InjectiveAccountsRPCStub(channel)
3926

40-
acct_id = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000"
27+
subacc_id = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000"
28+
dnm="peggy0x69efCB62D98f4a6ff5a0b0CFaa4AAbB122e85e08"
4129

42-
stream_req = accounts_rpc_pb.StreamSubaccountBalanceRequest(subaccount_id=acct_id) #Request
43-
44-
account_stream = accounts_exchange_rpc.StreamSubaccountBalance(stream_req)
45-
async for acc in account_stream:
46-
print("\n\033[1;34;40m API Response \n")
47-
print("\033[0;37;40m\n-- Order Update:", acc)
48-
30+
stream_req = accounts_rpc_pb.StreamSubaccountBalanceRequest(subaccount_id=subacc_id)
31+
stream_resp = accounts_exchange_rpc.StreamSubaccountBalance(stream_req)
32+
async for subacc in stream_resp:
33+
print("\n-- Subaccount Balance Update:\n", subacc)
4934

5035
if __name__ == '__main__':
5136
logging.basicConfig(level=logging.INFO)

examples/exchange_api_examples/accounts_rpc/2_SubaccountBalanceRequest.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,18 @@
1717
import logging
1818
import grpc
1919

20-
21-
from injective.exchange_api import injective_accounts_rpc_pb2 as accounts_rpc_pb
22-
from injective.exchange_api import injective_accounts_rpc_pb2_grpc as accounts_rpc_grpc
23-
from injective.exchange_api import injective_derivative_exchange_rpc_pb2 as derivative_exchange_rpc_pb
24-
from injective.exchange_api import injective_derivative_exchange_rpc_pb2_grpc as derivative_exchange_rpc_grpc
25-
from injective.exchange_api import injective_exchange_rpc_pb2 as exchange_rpc_pb
26-
from injective.exchange_api import injective_exchange_rpc_pb2_grpc as exchange_rpc_grpc
27-
from injective.exchange_api import injective_insurance_rpc_pb2 as insurance_rpc_pb
28-
from injective.exchange_api import injective_insurance_rpc_pb2_grpc as insurance_rpc_grpc
29-
from injective.exchange_api import injective_oracle_rpc_pb2 as oracle_rpc_pb
30-
from injective.exchange_api import injective_oracle_rpc_pb2_grpc as oracle_rpc_grpc
31-
from injective.exchange_api import injective_spot_exchange_rpc_pb2 as spot_exchange_rpc_pb
32-
from injective.exchange_api import injective_spot_exchange_rpc_pb2_grpc as spot_exchange_rpc_grpc
33-
20+
import injective.exchange_api.injective_accounts_rpc_pb2 as accounts_rpc_pb
21+
import injective.exchange_api.injective_accounts_rpc_pb2_grpc as accounts_rpc_grpc
3422

3523
async def main() -> None:
36-
async with grpc.aio.insecure_channel('localhost:9910') as channel:
37-
accounts_rpc = accounts_rpc_grpc.InjectiveAccountsRPCStub(channel)
24+
async with grpc.aio.insecure_channel('testnet-sentry0.injective.network:9910') as channel:
3825
accounts_exchange_rpc = accounts_rpc_grpc.InjectiveAccountsRPCStub(channel)
3926

40-
acct_id = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000"
27+
subacc_id = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000"
4128
dnm ="inj"
4229

43-
acc = await accounts_exchange_rpc.SubaccountBalanceEndpoint(accounts_rpc_pb.SubaccountBalanceRequest(subaccount_id=acct_id, denom=dnm))
44-
print("\n\033[1;34;40m API Response \n")
45-
print("\033[0;37;40m\n-- Order Update:", acc)
46-
30+
subacc_balance = await accounts_exchange_rpc.SubaccountBalanceEndpoint(accounts_rpc_pb.SubaccountBalanceRequest(subaccount_id=subacc_id, denom=dnm))
31+
print("\n-- Subaccount Balance Update:\n", subacc_balance)
4732

4833
if __name__ == '__main__':
4934
logging.basicConfig(level=logging.INFO)

examples/exchange_api_examples/accounts_rpc/3_SubaccountsListRequest.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,17 @@
1717
import logging
1818
import grpc
1919

20-
21-
from injective.exchange_api import injective_accounts_rpc_pb2 as accounts_rpc_pb
22-
from injective.exchange_api import injective_accounts_rpc_pb2_grpc as accounts_rpc_grpc
23-
from injective.exchange_api import injective_derivative_exchange_rpc_pb2 as derivative_exchange_rpc_pb
24-
from injective.exchange_api import injective_derivative_exchange_rpc_pb2_grpc as derivative_exchange_rpc_grpc
25-
from injective.exchange_api import injective_exchange_rpc_pb2 as exchange_rpc_pb
26-
from injective.exchange_api import injective_exchange_rpc_pb2_grpc as exchange_rpc_grpc
27-
from injective.exchange_api import injective_insurance_rpc_pb2 as insurance_rpc_pb
28-
from injective.exchange_api import injective_insurance_rpc_pb2_grpc as insurance_rpc_grpc
29-
from injective.exchange_api import injective_oracle_rpc_pb2 as oracle_rpc_pb
30-
from injective.exchange_api import injective_oracle_rpc_pb2_grpc as oracle_rpc_grpc
31-
from injective.exchange_api import injective_spot_exchange_rpc_pb2 as spot_exchange_rpc_pb
32-
from injective.exchange_api import injective_spot_exchange_rpc_pb2_grpc as spot_exchange_rpc_grpc
33-
20+
import injective.exchange_api.injective_accounts_rpc_pb2 as accounts_rpc_pb
21+
import injective.exchange_api.injective_accounts_rpc_pb2_grpc as accounts_rpc_grpc
3422

3523
async def main() -> None:
36-
async with grpc.aio.insecure_channel('localhost:9910') as channel:
37-
accounts_rpc = accounts_rpc_grpc.InjectiveAccountsRPCStub(channel)
24+
async with grpc.aio.insecure_channel('testnet-sentry0.injective.network:9910') as channel:
3825
accounts_exchange_rpc = accounts_rpc_grpc.InjectiveAccountsRPCStub(channel)
3926

40-
account_addr = "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku"
27+
addr = "inj14au322k9munkmx5wrchz9q30juf5wjgz2cfqku"
4128

42-
acc = await accounts_exchange_rpc.SubaccountsList(accounts_rpc_pb.SubaccountsListRequest(account_address=account_addr))
43-
print("\n\033[1;34;40m API Response \n")
44-
print("\033[0;37;40m\n-- Order Update:", acc)
45-
29+
subacc_list = await accounts_exchange_rpc.SubaccountsList(accounts_rpc_pb.SubaccountsListRequest(account_address=addr))
30+
print("\n-- Subaccount List Update:\n", subacc_list)
4631

4732
if __name__ == '__main__':
4833
logging.basicConfig(level=logging.INFO)

examples/exchange_api_examples/accounts_rpc/4_SubaccountBalancesListRequest.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,17 @@
1717
import logging
1818
import grpc
1919

20-
21-
from injective.exchange_api import injective_accounts_rpc_pb2 as accounts_rpc_pb
22-
from injective.exchange_api import injective_accounts_rpc_pb2_grpc as accounts_rpc_grpc
23-
from injective.exchange_api import injective_derivative_exchange_rpc_pb2 as derivative_exchange_rpc_pb
24-
from injective.exchange_api import injective_derivative_exchange_rpc_pb2_grpc as derivative_exchange_rpc_grpc
25-
from injective.exchange_api import injective_exchange_rpc_pb2 as exchange_rpc_pb
26-
from injective.exchange_api import injective_exchange_rpc_pb2_grpc as exchange_rpc_grpc
27-
from injective.exchange_api import injective_insurance_rpc_pb2 as insurance_rpc_pb
28-
from injective.exchange_api import injective_insurance_rpc_pb2_grpc as insurance_rpc_grpc
29-
from injective.exchange_api import injective_oracle_rpc_pb2 as oracle_rpc_pb
30-
from injective.exchange_api import injective_oracle_rpc_pb2_grpc as oracle_rpc_grpc
31-
from injective.exchange_api import injective_spot_exchange_rpc_pb2 as spot_exchange_rpc_pb
32-
from injective.exchange_api import injective_spot_exchange_rpc_pb2_grpc as spot_exchange_rpc_grpc
33-
20+
import injective.exchange_api.injective_accounts_rpc_pb2 as accounts_rpc_pb
21+
import injective.exchange_api.injective_accounts_rpc_pb2_grpc as accounts_rpc_grpc
3422

3523
async def main() -> None:
36-
async with grpc.aio.insecure_channel('localhost:9910') as channel:
37-
accounts_rpc = accounts_rpc_grpc.InjectiveAccountsRPCStub(channel)
24+
async with grpc.aio.insecure_channel('testnet-sentry0.injective.network:9910') as channel:
3825
accounts_exchange_rpc = accounts_rpc_grpc.InjectiveAccountsRPCStub(channel)
3926

40-
acct_id = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000"
27+
subacc_id = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000"
4128

42-
acc = await accounts_exchange_rpc.SubaccountBalancesList(accounts_rpc_pb.SubaccountBalancesListRequest(subaccount_id=acct_id))
43-
print("\n\033[1;34;40m API Response \n")
44-
print("\033[0;37;40m\n-- Order Update:", acc)
29+
subacc_list = await accounts_exchange_rpc.SubaccountBalancesList(accounts_rpc_pb.SubaccountBalancesListRequest(subaccount_id=subacc_id))
30+
print("\n-- Subaccount Balances List Update:\n", subacc_list)
4531

4632

4733
if __name__ == '__main__':
@@ -53,4 +39,3 @@ async def main() -> None:
5339

5440

5541

56-

examples/exchange_api_examples/accounts_rpc/5_SubaccountHistoryRequest.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,18 @@
1717
import logging
1818
import grpc
1919

20-
21-
from injective.exchange_api import injective_accounts_rpc_pb2 as accounts_rpc_pb
22-
from injective.exchange_api import injective_accounts_rpc_pb2_grpc as accounts_rpc_grpc
23-
from injective.exchange_api import injective_derivative_exchange_rpc_pb2 as derivative_exchange_rpc_pb
24-
from injective.exchange_api import injective_derivative_exchange_rpc_pb2_grpc as derivative_exchange_rpc_grpc
25-
from injective.exchange_api import injective_exchange_rpc_pb2 as exchange_rpc_pb
26-
from injective.exchange_api import injective_exchange_rpc_pb2_grpc as exchange_rpc_grpc
27-
from injective.exchange_api import injective_insurance_rpc_pb2 as insurance_rpc_pb
28-
from injective.exchange_api import injective_insurance_rpc_pb2_grpc as insurance_rpc_grpc
29-
from injective.exchange_api import injective_oracle_rpc_pb2 as oracle_rpc_pb
30-
from injective.exchange_api import injective_oracle_rpc_pb2_grpc as oracle_rpc_grpc
31-
from injective.exchange_api import injective_spot_exchange_rpc_pb2 as spot_exchange_rpc_pb
32-
from injective.exchange_api import injective_spot_exchange_rpc_pb2_grpc as spot_exchange_rpc_grpc
20+
import injective.exchange_api.injective_accounts_rpc_pb2 as accounts_rpc_pb
21+
import injective.exchange_api.injective_accounts_rpc_pb2_grpc as accounts_rpc_grpc
3322

3423
async def main() -> None:
35-
async with grpc.aio.insecure_channel('localhost:9910') as channel:
36-
accounts_rpc = accounts_rpc_grpc.InjectiveAccountsRPCStub(channel)
24+
async with grpc.aio.insecure_channel('testnet-sentry0.injective.network:9910') as channel:
3725
accounts_exchange_rpc = accounts_rpc_grpc.InjectiveAccountsRPCStub(channel)
3826

39-
acct_id = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000"
27+
subacc_id = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000"
28+
dnm= "peggy0x69efCB62D98f4a6ff5a0b0CFaa4AAbB122e85e08"
4029

41-
acc = await accounts_exchange_rpc.SubaccountHistory(accounts_rpc_pb.SubaccountHistoryRequest(subaccount_id=acct_id))
42-
print("\n\033[1;34;40m API Response \n")
43-
print("\033[0;37;40m\n-- Order Update:", acc)
30+
subacc_history = await accounts_exchange_rpc.SubaccountHistory(accounts_rpc_pb.SubaccountHistoryRequest(subaccount_id=subacc_id, denom=dnm))
31+
print("\n-- Subaccount History Update:\n", subacc_history)
4432

4533

4634
if __name__ == '__main__':

examples/exchange_api_examples/accounts_rpc/6_SubaccountOrderSummaryRequest.py

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,18 @@
1717
import logging
1818
import grpc
1919

20-
21-
from injective.exchange_api import injective_accounts_rpc_pb2 as accounts_rpc_pb
22-
from injective.exchange_api import injective_accounts_rpc_pb2_grpc as accounts_rpc_grpc
23-
from injective.exchange_api import injective_derivative_exchange_rpc_pb2 as derivative_exchange_rpc_pb
24-
from injective.exchange_api import injective_derivative_exchange_rpc_pb2_grpc as derivative_exchange_rpc_grpc
25-
from injective.exchange_api import injective_exchange_rpc_pb2 as exchange_rpc_pb
26-
from injective.exchange_api import injective_exchange_rpc_pb2_grpc as exchange_rpc_grpc
27-
from injective.exchange_api import injective_insurance_rpc_pb2 as insurance_rpc_pb
28-
from injective.exchange_api import injective_insurance_rpc_pb2_grpc as insurance_rpc_grpc
29-
from injective.exchange_api import injective_oracle_rpc_pb2 as oracle_rpc_pb
30-
from injective.exchange_api import injective_oracle_rpc_pb2_grpc as oracle_rpc_grpc
31-
from injective.exchange_api import injective_spot_exchange_rpc_pb2 as spot_exchange_rpc_pb
32-
from injective.exchange_api import injective_spot_exchange_rpc_pb2_grpc as spot_exchange_rpc_grpc
33-
20+
import injective.exchange_api.injective_accounts_rpc_pb2 as accounts_rpc_pb
21+
import injective.exchange_api.injective_accounts_rpc_pb2_grpc as accounts_rpc_grpc
3422

3523
async def main() -> None:
36-
async with grpc.aio.insecure_channel('localhost:9910') as channel:
37-
accounts_rpc = accounts_rpc_grpc.InjectiveAccountsRPCStub(channel)
24+
async with grpc.aio.insecure_channel('testnet-sentry0.injective.network:9910') as channel:
3825
accounts_exchange_rpc = accounts_rpc_grpc.InjectiveAccountsRPCStub(channel)
3926

40-
acct_id = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000"
41-
ord_direction = "buy"
27+
subacc_id = "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000"
28+
direction = "buy"
4229

43-
acc = await accounts_exchange_rpc.SubaccountOrderSummary(accounts_rpc_pb.SubaccountOrderSummaryRequest(subaccount_id=acct_id, order_direction=ord_direction))
44-
print("\n\033[1;34;40m API Response \n")
45-
print("\033[0;37;40m\n-- Order Update:", acc)
46-
30+
subacc_orders = await accounts_exchange_rpc.SubaccountOrderSummary(accounts_rpc_pb.SubaccountOrderSummaryRequest(subaccount_id=subacc_id, order_direction=direction))
31+
print("\n-- Subaccount Total Orders Update:\n", subacc_orders)
4732

4833
if __name__ == '__main__':
4934
logging.basicConfig(level=logging.INFO)
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
import grpc
19+
20+
import injective.exchange_api.injective_derivative_exchange_rpc_pb2 as derivative_exchange_rpc_pb
21+
import injective.exchange_api.injective_derivative_exchange_rpc_pb2_grpc as derivative_exchange_rpc_grpc
22+
23+
async def main() -> None:
24+
async with grpc.aio.insecure_channel('testnet-sentry0.injective.network:9910') as channel:
25+
derivative_exchange_rpc = derivative_exchange_rpc_grpc.InjectiveDerivativeExchangeRPCStub(channel)
26+
27+
mkt_id = "0xd0f46edfba58827fe692aab7c8d46395d1696239fdf6aeddfa668b73ca82ea30"
28+
29+
stream_req = derivative_exchange_rpc_pb.StreamOrdersRequest(market_id=mkt_id)
30+
stream_resp = derivative_exchange_rpc.StreamOrders(stream_req)
31+
async for order in stream_resp:
32+
print("\n-- Orders Update:\n", order)
33+
34+
35+
if __name__ == '__main__':
36+
logging.basicConfig(level=logging.INFO)
37+
asyncio.get_event_loop().run_until_complete(main())
38+
39+
40+
41+
42+
43+
44+
45+
46+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
import grpc
19+
20+
import injective.exchange_api.injective_derivative_exchange_rpc_pb2 as derivative_exchange_rpc_pb
21+
import injective.exchange_api.injective_derivative_exchange_rpc_pb2_grpc as derivative_exchange_rpc_grpc
22+
23+
async def main() -> None:
24+
async with grpc.aio.insecure_channel('testnet-sentry0.injective.network:9910') as channel:
25+
derivative_exchange_rpc = derivative_exchange_rpc_grpc.InjectiveDerivativeExchangeRPCStub(channel)
26+
27+
mkt_id = "0xd0f46edfba58827fe692aab7c8d46395d1696239fdf6aeddfa668b73ca82ea30"
28+
29+
tresp = await derivative_exchange_rpc.Trades(derivative_exchange_rpc_pb.TradesRequest(market_id=mkt_id))
30+
print("\n-- Trades Update:\n", tresp)
31+
32+
if __name__ == '__main__':
33+
logging.basicConfig(level=logging.INFO)
34+
asyncio.get_event_loop().run_until_complete(main())
35+
36+
37+
38+
39+
40+
41+
42+
43+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
import grpc
19+
20+
import injective.exchange_api.injective_derivative_exchange_rpc_pb2 as derivative_exchange_rpc_pb
21+
import injective.exchange_api.injective_derivative_exchange_rpc_pb2_grpc as derivative_exchange_rpc_grpc
22+
23+
async def main() -> None:
24+
async with grpc.aio.insecure_channel('testnet-sentry0.injective.network:9910') as channel:
25+
derivative_exchange_rpc = derivative_exchange_rpc_grpc.InjectiveDerivativeExchangeRPCStub(channel)
26+
27+
mkt_id = "0xd0f46edfba58827fe692aab7c8d46395d1696239fdf6aeddfa668b73ca82ea30"
28+
29+
stream_req = derivative_exchange_rpc_pb.StreamTradesRequest(market_id=mkt_id)
30+
stream_resp = derivative_exchange_rpc.StreamTrades(stream_req)
31+
async for trade in stream_resp:
32+
print("\n-- Trades Update:\n", trade)
33+
34+
if __name__ == '__main__':
35+
logging.basicConfig(level=logging.INFO)
36+
asyncio.get_event_loop().run_until_complete(main())
37+
38+
39+
40+
41+
42+
43+
44+
45+

0 commit comments

Comments
 (0)