Utility to capture greeks,PnL and date to a CSV file from ONE

Steven

New Member
curiousjeff - this is brilliant work.
Any idea if it is possible/reasonable to export all the One Option Chain data into csv (Expiration, Strike, Call/Put, Mid, IV, Delta etc)?
I would like to export futures option data from One as TOS thinkback is not good for exporting futures options data and I don't have optionvue.
I took a look at your code and I see how to use the RIGHT, LEFT, UP and DOWN keys to traverse each cell and copy it and write it to a file.
Any thoughts about how to get the expiration dates, Strike or Put/Call data?
 

curiousjeff

Active Member
@Steven

There has been some post in the # software-dev slack channel these past few days about grabing option prices from different sources. It is beyond my knowledge at this point, but maybe it will do what you want.

Regarding what I am doing with AutoIt, what you want IS possible:
Grabing the strike and the data of the option chain is done in the same way I did with my utility.
Place the mouse on the 1st cell of the column you want to grab and then "Shift+Ctrl+C" to copy the data. Then arrow key down. Rinse and repeat. Store the data where you want.

The one thing you cannot grab through "Shift+Ctrl+C" is the expiration date. But you can find that using another feature of Autoit:

$Text = WinGetText("OptionNET Explorer")

This will grab all other avaible text and luckily, the expiration information is available:1574671171457.png


You can shift the expirations using "Ctrl+Shift+Left arrow" to display the next three expirations.

Between some mouse movements and keyboard mouvements, it should be pretty simple. I don't know how long it would take to grab one timestamp. If you want to give it a try, I'll help if I can.
 
Last edited:

Steven

New Member
@curiousjeff - wow many thanks for your prompt response and for posting your clean code which I learned a lot from.

Is there any way to grab more than 1 cell at a time?

If not I suspect the approach would need to be something like:

1) Dump WinGetText() to a string and parse today's date/time (line 16) and regex (^[0-9][0-9] [a-zA-Z]+ [0-9][0-9] \([0-9]+\)) to find expiration months given format: 18 Nov 19 (0).

2) Click on the first call strike and capture the strike value and strike row number, then send {DOWN} in a loop capturing every strike value and row number until the strike value repeats to end the loop.

3) Click on the first expiration Call Mid cell and capture the Mid value and row number for each strike via: send {DOWN} in a loop while row number <=strike row number.

4) Repeat (3) to capture each subsequent column (IV/Delta) via: Send {CONTROL}{SHIFT}{HOME} followed by {RIGHT} {RIGHT} (i.e. for the 2nd column etc)

5) Click on the first put expiration Mid cell and repeat steps 3-4 for Puts

6) Repeat steps 1-5 in a loop for the next set of expiration dates via {CONTROL}{SHIFT}{LEFT} until the expiration dates repeat.

7) Send {SHIFT}{F4} to advance to the next time interval and repeat steps 1-6.

I am hopeful I over complicated this and there is a simpler/faster approach.

As all these loops and keystrokes will take a prohibitively long time so I may never get to the goal of 9 years of hourly data.

Thanks again for being so helpful and please don't write any code on my behalf.
 

curiousjeff

Active Member
A little warning, I am a tinkerer, not a programmer.

Is there any way to grab more than 1 cell at a time? I don't think so. But since this is not using mouse mouvements, but only keyboard, I think it can go very fast. The biggest problem will be that it is too fast and the Ctrl+Shfit+C will not copy correctly. You will need to slow it down at some points or have a control routine to check that it has copiednew data each time.


1) Dump WinGetText() to a string and parse today's date/time (line 16) and regex (^[0-9][0-9] [a-zA-Z]+ [0-9][0-9] \([0-9]+\)) to find expiration months given format: 18 Nov 19 (0).

Yes, that's the idea.

WinActivate ( "OptionNET Explorer - [SPX]" )
$Text = WinGetText("OptionNET Explorer - [SPX]")
$Value=StringSplit($Text,@CRLF)

For $i=1 To $Value[0]
If $i=???? (something to uniquely identify the 1st expiration or the line just above it) Then
$aText = $Value[$i]
EndIf

# Same thing for the timestamp.

Next


2) Click on the first call strike and capture the strike value and strike row number, then send {DOWN} in a loop capturing every strike value and row number until the strike value repeats to end the loop.

Yes

3) Click on the first expiration Call Mid cell and capture the Mid value and row number for each strike via: send {DOWN} in a loop while row number <=strike row number.

Yes

4) Repeat (3) to capture each subsequent column (IV/Delta) via: Send {CONTROL}{SHIFT}{HOME} followed by {RIGHT} {RIGHT} (i.e. for the 2nd column etc)

If you want to grab more then the Mid and delta, you will need to change the column header. This might need mouse mouvements

5) Click on the first put expiration Mid cell and repeat steps 3-4 for Puts

6) Repeat steps 1-5 in a loop for the next set of expiration dates via {CONTROL}{SHIFT}{LEFT} until the expiration dates repeat.


It will be safer to only have one expiration displayed at a time.

7) Send {SHIFT}{F4} to advance to the next time interval and repeat steps 1-6.

Yes

I am hopeful I over complicated this and there is a simpler/faster approach.

As all these loops and keystrokes will take a prohibitively long time so I may never get to the goal of 9 years of hourly data.

ah, hourly data, that could be ambitious. That's around 18k of timestamps to grab. I have not idea how long it will take for one time stamp.
If 1 minutes per timestamp, that's 300 hours.
 

David Ogden

New Member
Thank you for sharing this. Runs fine but my PnL column merges with the Delta column when PnL is greater than 1000. Is there an easy fix I can run?

DateTimePnLDeltaThetaVegaSPX
6-Jul-18​
16:10​
-0.65​
49.99​
36.31​
-505.52​
2759.82​
9-Jul-18​
16:10​
1.00​
339.35​
43.14​
36.31​
-492.55​
2784.17​
10-Jul-18​
16:10​
1.00​
689.35​
40.53​
36.85​
-484.17​
2793.84​
 
Top