NexusFi: Find Your Edge


Home Menu

 





PC-SPAN


Discussion in Options

Updated
      Top Posters
    1. looks_one Dudetooth with 218 posts (213 thanks)
    2. looks_two ron99 with 116 posts (55 thanks)
    3. looks_3 CafeGrande with 30 posts (4 thanks)
    4. looks_4 BlueRoo with 24 posts (5 thanks)
      Best Posters
    1. looks_one Dudetooth with 1 thanks per post
    2. looks_two SMCJB with 1 thanks per post
    3. looks_3 ron99 with 0.5 thanks per post
    4. looks_4 BlueRoo with 0.2 thanks per post
    1. trending_up 188,781 views
    2. thumb_up 317 thanks given
    3. group 75 followers
    1. forum 610 posts
    2. attach_file 159 attachments




 
Search this Thread

PC-SPAN

  #291 (permalink)
 enderqa 
Chicago, IL
 
Experience: Beginner
Platform: RTrader
Trading: CL
Posts: 15 since Apr 2013
Thanks Given: 9
Thanks Received: 1

@Dudetooth,

Do you have an way to calculate the days to expiration (DTE) for a given open? In the SPAN files CME disseminates, they give the options year and month, very similar to an options symbol. For example: Natural Gas, 201501. This is obviously NGF15 (with some strike price).

I tried looking at the Type records on CME's Web page and nothing jumped out.

Is there a DTE in the SPAN files somewhere? Or do you have to calculate it yourself? Or is there an elegant way to find this information?

Thanks in advance.

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
Exit Strategy
NinjaTrader
Futures True Range Report
The Elite Circle
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
The Program
18 thanks
GFIs1 1 DAX trade per day journal
18 thanks
  #292 (permalink)
 Dudetooth 
Steubenville Ohio
 
Experience: Intermediate
Platform: OX, OEC, RJO
Trading: Options on Futures
Posts: 266 since Sep 2012
Thanks Given: 30
Thanks Received: 274


enderqa View Post
@Dudetooth,

Do you have an way to calculate the days to expiration (DTE) for a given open? In the SPAN files CME disseminates, they give the options year and month, very similar to an options symbol. For example: Natural Gas, 201501. This is obviously NGF15 (with some strike price).

I tried looking at the Type records on CME's Web page and nothing jumped out.

Is there a DTE in the SPAN files somewhere? Or do you have to calculate it yourself? Or is there an elegant way to find this information?

Thanks in advance.

The line you are looking for is the Type B line in the CME SPAN file.

The Type B for NG would look something like this:
B NYMON OOF201402 201402 003124330005000002000030000330000000014520500000001000020140128NG

CME maps out what is found in the span files found here:
https://www.cmegroup.com/confluence/display/pubspan/Type+B+-+Expanded

From that you will find that there is a 7 digit string (characters 73-79) that is the Time to Expiration (in years). In the above example that would be 0145205 ... multiply by 0.000365 and you get the DTE.

Also, there is a 8 digit string (characters 92-99) which is the Expiration Date as YYYYMMDD (20140128 in the example above).

Hope this helps.

Reply With Quote
Thanked by:
  #293 (permalink)
 enderqa 
Chicago, IL
 
Experience: Beginner
Platform: RTrader
Trading: CL
Posts: 15 since Apr 2013
Thanks Given: 9
Thanks Received: 1



Dudetooth View Post
The line you are looking for is the Type B line in the CME SPAN file.

The Type B for NG would look something like this:
B NYMON OOF201402 201402 003124330005000002000030000330000000014520500000001000020140128NG

CME maps out what is found in the span files found here:
https://www.cmegroup.com/confluence/display/pubspan/Type+B+-+Expanded

From that you will find that there is a 7 digit string (characters 73-79) that is the Time to Expiration (in years). In the above example that would be 0145205 ... multiply by 0.000365 and you get the DTE.

Also, there is a 8 digit string (characters 92-99) which is the Expiration Date as YYYYMMDD (20140128 in the example above).

Hope this helps.

Thank you, I missed this when I was looking through their Web page! I really appreciate all the time you've given me.

-enderqa

Reply With Quote
  #294 (permalink)
 volemont 
Zurich, Switzerland
 
Trading: Futures
Posts: 55 since Dec 2013
Thanks Given: 105
Thanks Received: 75

Hi,

Does anyone have historical SPAN files and would be willing to kindly share those? The files on the CME FTP ftp.cmegroup.com only go back to January 2013.

Thanks

Reply With Quote
  #295 (permalink)
 Dudetooth 
Steubenville Ohio
 
Experience: Intermediate
Platform: OX, OEC, RJO
Trading: Options on Futures
Posts: 266 since Sep 2012
Thanks Given: 30
Thanks Received: 274


volemont View Post
Hi,

Does anyone have historical SPAN files and would be willing to kindly share those? The files on the CME FTP ftp.cmegroup.com only go back to January 2013.

Thanks

CME temporarily posted 2012 data at one time, though the formatting was different. It was only there for a short period of time, and unfortunately I did not grab it.

I don't know of anyone on the thread who did grab the data. Sorry.

Reply With Quote
  #296 (permalink)
Cdanitius
Singapore
 
Posts: 3 since Apr 2015
Thanks Given: 2
Thanks Received: 0

Hi everyone!

I read through the forum pages, thank you for the information all of you have provided - you lot are really awesome to share all of this ^^

I am currently figuring out how to pull the data for the SGX (Singapore Ex.) and CME for the TSI Iron Ore.
Was playing around with your excel - XLS SPan 04b3 - it works perfectly, but does your excel support the SGX pa2 files?


It seems like I can only scan for positions for NYB and CME only for now :/

Cheers!
Cdan

Reply With Quote
  #297 (permalink)
 Dudetooth 
Steubenville Ohio
 
Experience: Intermediate
Platform: OX, OEC, RJO
Trading: Options on Futures
Posts: 266 since Sep 2012
Thanks Given: 30
Thanks Received: 274


Cdanitius View Post
It seems like I can only scan for positions for NYB and CME only for now :/

Each commodity has to be coded into the spreadsheet so that the correct lines of data can be found. You can, however, add as many as you would like. You just need to know the product code and a little about VBA to modify the file. If you want to know how, give me an example of a commodity you'd like to track and I can walk you through the process.

Reply With Quote
  #298 (permalink)
Cdanitius
Singapore
 
Posts: 3 since Apr 2015
Thanks Given: 2
Thanks Received: 0

Hi Dudetooth!

Thanks for the really prompt reply.

I am currently trying to track the FE and FEF (Iron Ore CFR China (62% Fe Fines) Swaps & Futures respectively) and also the TIO (Iron Ore as well) from the NYMEX exchange.

The SGX parameter files can be found here. (I can't post it here, its under the SGX main website, under Clearing,Span Download PM Cycle)

I tried playing around with the automated download for the SGX files but they change the urls every day.(not just the date)

How did you manage to extract data from the pa2 files?

Really appreciate if you could give me a mini walkthrough =)

Cheers!

Reply With Quote
  #299 (permalink)
 Dudetooth 
Steubenville Ohio
 
Experience: Intermediate
Platform: OX, OEC, RJO
Trading: Options on Futures
Posts: 266 since Sep 2012
Thanks Given: 30
Thanks Received: 274


Cdanitius View Post
Really appreciate if you could give me a mini walkthrough

So, I have good news and bad news.

The bad: Adding the SGX exchange and commodities should have been fairly easy, but as I started to look at their pa2 files I noticed that they are missing the Type P line of data. The Type P data has info on where to place the decimals in the prices and if the data is missing it will throw an error in the spreadsheet. I will check, but I don't think that is an easy fix for this in the spreadsheet.

The good: Adding TIO and any other CME or NYB commodities is fairly easy.
1) In Visual Basic Editor, open the Function P34Bstring in the Functions module.
2) Find Case "ZB" and right above that line insert this:
Case "TIO"
strS(0) = "P NYMICT OOF"
strS(1) = "3 NY-TIO1001"
strS(2) = "4 NY-TIO01"
strS(3) = "B NYMICT OOF"
strS(4) = "82NYMTIO TIO FUT"

Final code with TIO inserted should look like this:
Case "SI"
strS(0) = "P CMXSO OOF"
strS(1) = "3 CX-SI 1001"
strS(2) = "4 CX-SI 01"
strS(3) = "B CMXSO OOF"
strS(4) = "82CMXSI SI FUT"
Case "TIO"
strS(0) = "P NYMICT OOF"
strS(1) = "3 NY-TIO1001"
strS(2) = "4 NY-TIO01"
strS(3) = "B NYMICT OOF"
strS(4) = "82NYMTIO TIO FUT"
Case "ZB"
strS(0) = "P CBT17 OOF"
strS(1) = "3 17 1001"
strS(2) = "4 17 01"
strS(3) = "B CBT17 OOF"
strS(4) = "82CBT17 17 FUT"

3) Go to the Function T8string
4) Find Case "ZB" and right above that line insert this:
Case "TIO"
str5 = "82NYMICT TIO OOF"

Final code with TIO inserted should look like this:
Case "SI"
str5 = "82CMXSO SI OOF"
Case "TIO"
str5 = "82NYMICT TIO OOF"
Case "ZB"
str5 = "82CBT17 17 OOF"

Where did I find these lines of code? All it takes is a little footwork to find the info in the pa2 file. Open a CME pa2 file in Notepad.exe. The first line to look for is the Type P line of data. You know that TIO is traded on NYMEX, so do a search for "p nymtio". You'll find "P NYMTIO FUTIRON ORE FUTURE002000 000050000000000000000001USD$STD 00 IRON ORE FUTURES", but that line if for the futures. The next line down is what you need: "P NYMICT OOFIRON ORE 62% FE002002 000050000000000000000001USD$STD 00EUROIRON ORE 62% FE,(TSI) CHINA APO". If you noticed, you don't need all of it for the code just the first characters through "OOF". Right underneath that are the Type 3, Type 4 and Type B lines. There are a lot of Type B lines, one for every futures and options contract. You have to go down quite a bit until you see "B NYMTIO FUT" which is a futures contract turn into "B NYMICT OOF" which is the first options contract. Notice that the Type B is "B NYMICT" not "B NYMTIO". Many commodities use a different code for the options than for the futures. That's what gave me the clue to search for "ICT" when finding the Type 82 line of data.

Confused yet? It sounds a lot worse than it really is. Compare the initial strings you see in the code to the lines of data you see in the pa2 file and after a while it should make sense.

With those two modifications in the spreadsheet I ran the numbers for an option and it match what CME Core was showing for it.


I attached a text file with the two modified modules so you can see the proper formatting because some of the spaces are removed in the lines of code when I post them in the reply.

Attached Files
Elite Membership required to download: Modified Code.txt
Reply With Quote
Thanked by:
  #300 (permalink)
Cdanitius
Singapore
 
Posts: 3 since Apr 2015
Thanks Given: 2
Thanks Received: 0


Hey Dudetooth,

Really appreciate your long and detailed post - I apologize for the really late reply.

I had played around with what you had mentioned, but I didn't make much progress. It was eating quite a bit of my time so I had decided to pass what you had said over to my colleagues who understood more about programming so they could tackle it in their free time. They were pretty amazed to see what you had come up with.

Instead, I had customized a spreadsheet that had links to my current position files (in the format they are recorded) - it converts and exports all of them as CSV files, and runs them through PC - Span to gather the margins I require. Not the most efficient way, but it currently works for me.

Thank you for your time! Awesome forum and people =)

Reply With Quote




Last Updated on September 23, 2021


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts