Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting Bid and Ask data for option chains. #53

Open
alpinevm opened this issue Dec 28, 2020 · 4 comments
Open

Getting Bid and Ask data for option chains. #53

alpinevm opened this issue Dec 28, 2020 · 4 comments

Comments

@alpinevm
Copy link

I've gone through the source code and I can't seem to find anything that references finding bid and ask data for options.
Is there something I'm blatantly missing or is this feature not available.

Thanks!

@TheRealNiBi
Copy link

Same issue. For me this is worthless without that

@bandwiches
Copy link
Contributor

Are you looking for the bid/ask for a position or a symbol? This isn't very clear.

There are ways to pull bid/ask for options and options chains as well as symbol metrics. If you want something more simple without all the additional metrics and whatnot, that's on you. Here's a closed issue that shows a response that includes bid/ask.

@adamsherman
Copy link

Easiest way is to probably edit example.py and grab an underlying stock you are familiar with, i.e. 'GOOG' and find the associated option ticker for each strike/expiry you want by using something akin to:

    # get a list of option expirations for a given underlying
    undl = underlying.Underlying('GOOG')
    expiration = date(2021,4,1) 
    chain = await option_chain.get_option_chain(session, undl, expiration)
    for option in  chain.options:
        LOGGER.info('Strike: {}\t Ticker {}'.format(option.strike, option.get_dxfeed_symbol()))

    # choose ticker(s) and get the data via the streamer by subscribing
    sub_values = {
        "Quote": [".GOOG210401P2150", ".GOOG210401P2160"]
    }
    await streamer.add_data_sub(sub_values)

    # print the bid/ask
    async for item in streamer.listen():
      for data in item.data:
          LOGGER.info(data)   

or create an Option object and get the dxfeed_symbol manually and subscribe. Hope that helps

@perigvennetier
Copy link

Here is another example I was able to make.

undl = underlying.Underlying('SPY')
chain = await option_chain.get_option_chain(session, undl)
exp = chain.get_all_expirations()
# for expiration_date in exp:
#     print(expiration_date)

# Choose the next expiration for example:
next_exp = exp[0]
chain_next_exp = await option_chain.get_option_chain(session, undl, next_exp)
options_tickers = []
for option in chain_next_exp.options:
    # LOGGER.info('Exp: {}\t Strike: {}\t {} \tTicker {}'.format(option.expiration_date, option.strike, option.option_type.value, option.get_dxfeed_symbol()))
    options_tickers.append(option.get_dxfeed_symbol())

# Form the option chain name and get the data via the streamer by subscribing
sub_values = {
    #"Quote": [".SPY210419P410"]
    "Quote": options_tickers
}
await streamer.add_data_sub(sub_values)

# print the bid/ask
async for item in streamer.listen():
    for data in item.data:
        LOGGER.info('Symbol: {}\tBid: {}\tAsk {}'.format(data['eventSymbol'], data['bidPrice'], data['askPrice']))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants