TOS to Python if you need something quick and dirty

garyw

Active member
Gold Member
I had the need to obtain historical daily bar data for "SPVXSP.ID" for some python work, which is available in TOS, but in no other free providers that I am aware of. I wrote a trivial ThinkScript Strategy that can produce a csv file, and then wrote a python script to convert it into a pandas dataframe for use in one my existing python efforts.
I only have interest in daily bars for this, so only address that.

I use Windows 10, so coded for minimal extra effort for that environment.
I capture date, Open, High, Low, Close for the span of the chart being used. (no frills) <-- The symbol referenced is not a tradeable instrument, so does not have volume, fyi.

If interested, reply here or privately, & I provide details. -- Was less effort than expected (a real surprise)!
 
Hi Gary
Please share your thinkscript url. It sounds like I can get end of day data for any symbol or option symbol, correct? I am looking for end of day option symbol for ATM P and C. Sounds interesting
 
Below is snip of python, including the TOS_Strat2df function which parses the csv file from that ThinkScript Strategy and returns a pandas Dataframe. --
 

Attachments

  • Sym2CsvSTRATEGY.zip
    261 bytes · Views: 12
  • code_snip.zip
    1.3 KB · Views: 11
Last edited:
Hi Gary
Please share your thinkscript url. It sounds like I can get end of day data for any symbol or option symbol, correct? I am looking for end of day option symbol for ATM P and C. Sounds interesting
I normally use yahoo finance to pull daily historic data, but many symbols are not supported there, so created this for these cases. The negative rub, is you need to use TOS, select your symbol, then click your mouse a few times to create the CSV file.
But to answer your question, I think so. I typically set up the TOS chart for Daily aggregation and Time Interval to "Max available." For this. Rather than have to coerce TOS to place the file where you can find it (convenient for you), I decided to just use the location it forces each time, to reduce my frustration, and have my Python code know where this is.
 
Hi Gary
Please share your thinkscript url. It sounds like I can get end of day data for any symbol or option symbol, correct? I am looking for end of day option symbol for ATM P and C. Sounds interesting
[/QUOTE
Tony: I have not used it for options, but it seems to work. However, you should note that the information is from Trades, NOT from B/A or Mark! -- For example, if no trades occur on some date, there will be no entries for that date.
 
Top
Contact Us