Open alpinevm opened 3 years ago
Same issue. For me this is worthless without that
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.
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
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']))
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!