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

curiousjeff

Active Member
This will not work with the latest BETA version of ONE:

It works with this version:
1573656945210.png

How to use:

1) Download and place in your folder of choice these two files:

ONE_GRAB.exe file
Scriptconfig.txt

2) You must set the utility to run in admin mode, or not it will not work.
Right click on the file -> properties -> Compatibility

1573642592481.png

3) With OptionNet explorer open, run ONE_GRAB.exe
You will be first asked to configure the mouse position. Follow the instructions:
When asked, place the mouse here:

1573642716446.png

And click return on the keyboard

Then place the mouse here when asked:

1573642769143.png

And click return on the keyboard.

Only redo these steps above if you change the position of ONE's window.
The mouse positions are stored in the Scriptconfig.txt file and will be reused.

4) Answer the others questions:

Give a name to the CSV file
How many days to backtest
Do you want to hear a sound at the end.

Let the script run.

5) The result file will be in the same folder as the utility.

Once opened in Excel, it will look like this:

1573643045519.png


Important: Once the script is running, you must not use your computer for something else.

The delimiter for the CSV is a comma.
If the ONE server is too slow, the data could be wrong.
If that is the case, edit the last line (the 5th) of the Scriptconfig.txt file and make the number bigger then 600.

Start by backesting 2 days. Make sure the data is getting captured correctly and that the day is changing in ONE.
If the day is not changing, make sure you have configured "Run as admininistrator"
 

Attachments

Last edited:

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​
 

curiousjeff

Active Member
Hi Dave,

In the example you posted, I don't see a relation with the PnL being greater than 1000 and this problem. It looks like the same issue Ron had when he showed it in the MM session.

Some column data are being shift to the right.

Have you tried this:

"If the ONE server is too slow, the data could be wrong.
If that is the case, edit the last line (the 5th) of the Scriptconfig.txt file and make the number bigger then 600. "

The four first lines are the mouse coordinates.
The last line is a pause timer between each day. Replace 600 by 1200. Please try it on the same backtest.
If that does not resolve the issue, I can add specific delays within the script or some other error checking routine.
Let me know how it goes.
 
Top