andrewm
-Interested User-
Posts: 52
Joined: Feb 23, 2015
|
Posted: May 4, 2021 05:33 PM
Msg. 1 of 11
A command to get a current snapshot of the full options chain for one expiration date like yahoo shows would be nice: https://finance.yahoo.com/quote/AAPL/options?p=AAPLThey give: Contract Name Last Trade Date Strike Last Price Bid Ask Change % Change Volume Open Interest implied vol <- probably not needed Currently with IQ Feed I think you have to query the whole chain, then iterate over it, subscribing and unsubscribing to each symbol. Right?
|
mk
-Interested User-
Posts: 9
Joined: Jan 1, 2022
|
Posted: Jan 1, 2022 08:50 AM
Msg. 2 of 11
No responses since May. Did you figure out how to do this? I have the same exact question.
|
andrewm
-Interested User-
Posts: 52
Joined: Feb 23, 2015
|
Posted: Jan 1, 2022 09:33 AM
Msg. 3 of 11
No reply. I believe it's not supported
|
stargrazer
-DTN Guru-
Posts: 302
Joined: Jun 13, 2005
Right Here & Now
|
Posted: Jan 1, 2022 03:26 PM
Msg. 4 of 11
Quote: Currently with IQ Feed I think you have to query the whole chain, then iterate over it, subscribing and unsubscribing to each symbol. Right? That is what I do. Edited by stargrazer on Jan 1, 2022 at 03:27 PM
|
DTN_Gary_Stephen
-DTN Guru-
Posts: 403
Joined: Jul 3, 2019
|
Posted: Jan 3, 2022 01:51 PM
Msg. 5 of 11
Quote: Currently with IQ Feed I think you have to query the whole chain, then iterate over it, subscribing and unsubscribing to each symbol. Right? What you can do is request one of the market summary reports. There are three different reports which will give you two different sets of data, for all symbols of a certain type on a certain exchange. You can't limit it to just one root symbol, but you can get a comprehensive report and then pick out the symbols you want. This is a lot faster and more efficient than the process you described it. 5MS, (symbol type), (exchange ID) or EDS, (symbol type), (exchange ID), (date in YYYYMMDD format) Symbol,Exchange,Type,Last,TradeSize,TradedMarket,TradeDate,TradeTime, Open,High,Low,Close,Bid,BidMarket,BidSize,Ask,AskMarket,AskSize,Volume, PDayVolume,UpVolume,DownVolume,NeutralVolume,TradeCount,UpTrades, DownTrades,NeutralTrades,VWAP,MutualDiv,SevenDayYield,OpenInterest, Settlement,SettlementDate,ExpirationDate,Strike 5MS Is a 5-minute report, while EDS is an end-of-day report. So pick the one that matches the scope you want. There is also an end of day fundamental data report: FDS, (symbol type), (exchange ID), (date in YYYYMMDD format) Symbol,Description,PeRatio,AvgVolume,DivYield,DivAmount,DivRate,PayDate, ExDivDate,CurrentEps,EstEps,SIC,Precision,Display,GrowthPercent,FiscalYearEnd, Volatility,ListedMarket,MaturityDate,OptionRoots,CouponRate,InstitutionalPercent, YearEndClose,Beta,LEAPs,WRAPs,Assets,Liabilities,BalanceSheetDate, LongTermDebt,CommonSharesOutstanding,MarketCap,52WeekHigh, 52WeekHighDate,52WeekLow,52WeekLowDate,CalHigh,CalHighDate,CalLow, CalLowDate,Expiration,LastSplit,LastSplitDate,PrevSplit,PrevSplitDate,NAICS,ShortInterest I believe all the fields you asked about will be in one of those two reports. The commands SST and SLM, respectively, will give you a list of all the symbol types and exchange ideas you would want to use. The exchange ID, make sure you use the Group ID, Not the number of the beginning of the line: 1,NGM,Nasdaq Global Market,5,NASDAQ, For NGM you would use 5, because it's a part of the NASDAQ group of exchanges. You can also get the symbol type and exchange codes from a specific symbol via the SBF command (note reversed order): SBF,s,QQQ2216I383 QQQ2216I383,14,2,QQQ SEP 2022 C 383.00, I hope that helps with your performance. Let me know if this does not answer your question or if you have any other questions on this! Sincerely, Gary Stephen DTN IQFeed Implementation Support Specialist
|
ChainsawDR
-Interested User-
Posts: 29
Joined: Jan 4, 2019
|
Posted: Nov 22, 2022 09:46 AM
Msg. 6 of 11
Hi Gary,
I came across this thread while trying to obtain latest bid/ask offers on equity options (ideally a snapshot of latest bid/ask on all option chains for all S&P500 component stocks). I've tried looking into the 5MS report but haven't been able to retrieve equity options data - do you have an example 5MS request please that would return a list of options with bid/ask?
Currently a request for "5MS,2,5" (which is I think '2,IEOPTION,Index/Equity Option,' & '5,NASDAQ,Nasdaq,5,NASDAQ') is returning a 'E,50007,No file available' error.
Otherwise, if there isn't an overall report that shows option chains I'll likely proceed down the OP's original path of retrieving the whole chain for various stock tickers, then iterate over them - subscribing and unsubscribing to each option.
Many thanks in advance
ChainsawDR
|
DTN_Gary_Stephen
-DTN Guru-
Posts: 403
Joined: Jul 3, 2019
|
Posted: Nov 22, 2022 10:21 AM
Msg. 7 of 11
Equity options are listed on the OPRA exchange, not NASDAQ (even if the root equity symbol is NASDAQ). The command you're looking for is:
5MS,2,14
14 being the OPRA exchange group ID. But you must also be subscribed to the OPRA exchange, and have the "RT Options" product, or you will get "E,50007,No file available" reply again.
"E,50007,No file available" can mean either "this combination of symbol type and exchange group don't exist", or "you do not have the necessary subscriptions to view this report." 5MS,2,5 is the former; 5MS,2,14 would be the latter if you are not subscribed to OPRA.
Sincerely, Gary Stephen DTN IQFeed Implementation Support Specialist
|
andrewm
-Interested User-
Posts: 52
Joined: Feb 23, 2015
|
Posted: Nov 22, 2022 11:02 AM
Msg. 8 of 11
Here's a couple python files that will collect the OPRA snapshots and compress them to 7z format. I put this in a windows scheduled task. You can replace opra.py values with other markets. I collect several. opra.py: from main import start from datetime import datetime
print('starting opra at ' + str(datetime.now())) DATA_PATH = 'c:\\data\\opra' TEMP_FILE = 'c:\\temp\\opra.csv' COMPRESSED_FILE = "opra.7z" SECURITY_TYPE = 2 # equity options MARKET = 14 # OPRA start(DATA_PATH, TEMP_FILE, COMPRESSED_FILE, SECURITY_TYPE, MARKET)
main.py: import shutil import socket from datetime import datetime from pathlib import Path import subprocess from os import makedirs
ZIP_EXE = 'c:\\util\\7z\\7z.exe' HOST = '127.0.0.1' PORT = 9100
def getDirectory(data_path): today = datetime.today().strftime('%Y-%m-%d') todaysPath = data_path + '\\' + today Path(todaysPath).mkdir(parents=True, exist_ok=True) return todaysPath
def get7zFilename(): now = datetime.now() print("now =", now) today = datetime.today().strftime('%Y-%m-%d') dt_string = today + "_" + now.strftime("%H%M") print("date and time =", dt_string) filename = dt_string + ".7z"; print("filename = "+filename); return filename
def start(data_path, temp_file, compressed_file, security_type, market): print('start sec type ' + str(security_type) + ' market ' + str(market)) with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.connect((HOST, PORT)) s.sendall(b'S,SET PROTOCOL,6.2\n') s.sendall(bytes('5MS,' + str(security_type) + "," + str(market) + '\n', 'ascii')) f = s.makefile() line = f.readline() # for line in f.readline(): print("line="+repr(line)) line = '' outfile = open(temp_file, "w"); while not line.startswith('!ENDMSG!'): line = f.readline() outfile.write(line) #print("line=" + repr(line)) outfile.close() f.close() dir = getDirectory(data_path) fn = dir + "\\" + get7zFilename() subprocess.call([ZIP_EXE, 'a', fn, temp_file]) # shutil.copy2(fn, dir + "\\" + compressed_file) print("done") # print('Received', repr(data))
|
ChainsawDR
-Interested User-
Posts: 29
Joined: Jan 4, 2019
|
Posted: Nov 22, 2022 01:31 PM
Msg. 9 of 11
Wow! Thank you both very much for your help!
@AndrewM - I was expecting to spend the next ~2 days chewing through this problem and you generously posting your code has just solved it completely. Thank you so much
|
andrewm
-Interested User-
Posts: 52
Joined: Feb 23, 2015
|
Posted: Nov 22, 2022 02:38 PM
Msg. 10 of 11
You're welcome. Glad it helps. It's a little rough around the edges. getDirectory should be made functional instead of having the side effect of also creating the dir. Some logging would be nice, etc. But it works...
|
andrewm
-Interested User-
Posts: 52
Joined: Feb 23, 2015
|
Posted: Nov 22, 2022 03:18 PM
Msg. 11 of 11
Here's the others I collect: cboe_index.py: from main import start from datetime import datetime
print('starting cboe index at ' + str(datetime.now())) DATA_PATH = 'c:\\data\\cboe_index' TEMP_FILE = 'c:\\temp\\cboe_index.csv' COMPRESSED_FILE = "cboe_index.7z" SECURITY_TYPE = 6 # CBOE MARKET = 13 # index start(DATA_PATH, TEMP_FILE, COMPRESSED_FILE, SECURITY_TYPE, MARKET)
cbot_futures.py from main import start from datetime import datetime
print('starting cbot futures at ' + str(datetime.now())) DATA_PATH = 'c:\\data\\cbot_futures' TEMP_FILE = 'c:\\temp\\cbot_futures.csv' COMPRESSED_FILE = "cbot_futures.7z" SECURITY_TYPE = 8 # futures MARKET = 30 # CBOT start(DATA_PATH, TEMP_FILE, COMPRESSED_FILE, SECURITY_TYPE, MARKET)
cme_futures.py from main import start from datetime import datetime
print('starting cme futures at ' + str(datetime.now())) DATA_PATH = 'c:\\data\\cme_futures' TEMP_FILE = 'c:\\temp\\cme_futures.csv' COMPRESSED_FILE = "cme_futures.7z" SECURITY_TYPE = 8 # futures MARKET = 34 # CME start(DATA_PATH, TEMP_FILE, COMPRESSED_FILE, SECURITY_TYPE, MARKET)
cme_options.py from main import start from datetime import datetime
print('starting cme options at ' + str(datetime.now())) DATA_PATH = 'c:\\data\\cme_options' TEMP_FILE = 'c:\\temp\\cme_options.csv' COMPRESSED_FILE = "cme_options.7z" SECURITY_TYPE = 9 # options MARKET = 34 # CME start(DATA_PATH, TEMP_FILE, COMPRESSED_FILE, SECURITY_TYPE, MARKET)
nasdaq_equities.py from main import start from datetime import datetime
print('starting nasdaq at ' + str(datetime.now())) DATA_PATH = 'c:\\data\\nasdaq' TEMP_FILE = 'c:\\temp\\nasdaq.csv' COMPRESSED_FILE = "nasdaq.7z" SECURITY_TYPE = 1 # equities MARKET = 5 # NASDAQ start(DATA_PATH, TEMP_FILE, COMPRESSED_FILE, SECURITY_TYPE, MARKET)
nyse_equities.py from main import start from datetime import datetime
print('starting nyse at ' + str(datetime.now())) DATA_PATH = 'c:\\data\\nyse' TEMP_FILE = 'c:\\temp\\nyse.csv' COMPRESSED_FILE = "nyse.7z" SECURITY_TYPE = 1 # stock MARKET = 7 # NYSE start(DATA_PATH, TEMP_FILE, COMPRESSED_FILE, SECURITY_TYPE, MARKET)
|
|
|
|