Skip to content

Commit 7f416ef

Browse files
committed
feat: add BinaryOptionsMarket(s)Request
1 parent 0e82bcf commit 7f416ef

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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_status = "active" # active, paused, suspended, demolished or expired
26+
quote_denom = "peggy0xdAC17F958D2ee523a2206206994597C13D831ec7"
27+
market = await client.get_binary_options_markets(
28+
market_status=market_status,
29+
quote_denom=quote_denom
30+
)
31+
32+
print(market)
33+
34+
if __name__ == '__main__':
35+
logging.basicConfig(level=logging.INFO)
36+
asyncio.get_event_loop().run_until_complete(main())
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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 = "0x12d35c0b585f21c266b6f11855aea196245d90a49c0d6844e48f1a7049fa629e"
26+
market = await client.get_binary_options_market(market_id=market_id)
27+
print(market)
28+
29+
if __name__ == '__main__':
30+
logging.basicConfig(level=logging.INFO)
31+
asyncio.get_event_loop().run_until_complete(main())

pyinjective/async_client.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,3 +786,15 @@ async def get_funding_rates(self, market_id: str, **kwargs):
786786
limit=kwargs.get("limit"),
787787
)
788788
return await self.stubDerivativeExchange.FundingRates(req)
789+
790+
async def get_binary_options_markets(self, **kwargs):
791+
req = derivative_exchange_rpc_pb.BinaryOptionsMarketsRequest(
792+
market_status=kwargs.get("market_status"),
793+
quote_denom=kwargs.get("quote_denom"),
794+
)
795+
return await self.stubDerivativeExchange.BinaryOptionsMarkets(req)
796+
797+
async def get_binary_options_market(self, market_id: str):
798+
req = derivative_exchange_rpc_pb.BinaryOptionsMarketRequest(market_id=market_id)
799+
return await self.stubDerivativeExchange.BinaryOptionsMarket(req)
800+

0 commit comments

Comments
 (0)