OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

How do I get the JPY futures options chain with python and ib_insync?

  • Thread starter Thread starter NeroTulip
  • Start date Start date
N

NeroTulip

Guest
This gives me historical data for a single JPY future option. I want to get the same data, but for all available expiries/strikes.

Code:
from ib_insync import *
util.startLoop()
ib = IB()
ib.connect('127.0.0.1', 7497, clientId=1)

contract = Contract(
    secType='FOP',
    symbol='JPY',
    lastTradeDateOrContractMonth='20240906',
    strike=0.0064,
    right='P',
    exchange='CME',
)

bars = ib.reqHistoricalData(
    contract,
    endDateTime='20240621-22:00:00',
    durationStr='2 D',
    barSizeSetting='1 hour',
    whatToShow='MIDPOINT',
    useRTH=True
)

df = util.df(bars)
print(df)

If I omit the expiry and use reqContractDetails, I can get a list of contracts details that contains the expiries

Code:
contracts = Contract(
    secType='FOP',
    symbol='JPY',
    #lastTradeDateOrContractMonth='20240906',
    strike=0.0064,
    right='P',
    exchange='CME',
)

contract_details = ib.reqContractDetails(contracts)
contract_details

But how do I extract the expiries from that?

The other thing I have tried is to follow the ib_insync documentation and do something like

Code:
chains = ib.reqSecDefOptParams(contract.symbol, '', contract.secType, contract.conId)

util.df(chains)

But couldn't get this to work...
<p>This gives me historical data for a single JPY future option. I want to get the same data, but for all available expiries/strikes.</p>
<pre><code>from ib_insync import *
util.startLoop()
ib = IB()
ib.connect('127.0.0.1', 7497, clientId=1)

contract = Contract(
secType='FOP',
symbol='JPY',
lastTradeDateOrContractMonth='20240906',
strike=0.0064,
right='P',
exchange='CME',
)

bars = ib.reqHistoricalData(
contract,
endDateTime='20240621-22:00:00',
durationStr='2 D',
barSizeSetting='1 hour',
whatToShow='MIDPOINT',
useRTH=True
)

df = util.df(bars)
print(df)
</code></pre>
<p>If I omit the expiry and use reqContractDetails, I can get a list of contracts details that contains the expiries</p>
<pre><code>contracts = Contract(
secType='FOP',
symbol='JPY',
#lastTradeDateOrContractMonth='20240906',
strike=0.0064,
right='P',
exchange='CME',
)

contract_details = ib.reqContractDetails(contracts)
contract_details
</code></pre>
<p>But how do I extract the expiries from that?</p>
<p>The other thing I have tried is to follow the ib_insync documentation and do something like</p>
<pre><code>chains = ib.reqSecDefOptParams(contract.symbol, '', contract.secType, contract.conId)

util.df(chains)
</code></pre>
<p>But couldn't get this to work...</p>
 

Latest posts

Top