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 190,372 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

  #441 (permalink)
 ItalianBmT 
Java/IN
 
Experience: Beginner
Platform: TOS
Trading: gold
Posts: 13 since Nov 2013
Thanks Given: 2
Thanks Received: 0

I am not sure whether vba just skips when there is error because i do not get the prompt that the file exists, it just gors strUght to m5 unable to download

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
Trade idea based off three indicators.
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Increase in trading performance by 75%
The Elite Circle
MC PL editor upgrade
MultiCharts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
GFIs1 1 DAX trade per day journal
16 thanks
My NQ Trading Journal
14 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
  #442 (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

I may have an idea of what may be happening. I should have a fix for you to try tomorrow. It may be related to the 64-bit version of Office.

Reply With Quote
  #443 (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


@ItalianBmT

It looks as though Office 64-bit has issues with some functions. The Lib "urlmon" may need to have "PtrSafe" added to the beginning and the Long variables as LongPtr to safely run in 64-bit Office. I don't currently have the 64-bit version of Office, so I am not sure if this will solve the issue.

Try going into the Download module at the top under "Option Explicit" and replacing:

Private Declare Function URLDownloadToFileA Lib "urlmon" (ByVal pCaller As Long, _
ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long


with this:

Private Declare PtrSafe Function URLDownloadToFileA Lib "urlmon" (ByVal pCaller As LongPtr, _
ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As LongPtr, _
ByVal lpfnCB As LongPtr) As LongPtr


Let me know if we need to adjust.

Reply With Quote
  #444 (permalink)
 ItalianBmT 
Java/IN
 
Experience: Beginner
Platform: TOS
Trading: gold
Posts: 13 since Nov 2013
Thanks Given: 2
Thanks Received: 0

When I run, another part of the code sprung an error

Got a mismatch error here.

Private Function SaveWebFile(URL As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFileA(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then SaveWebFile = True
End Function

Reply With Quote
  #445 (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


ItalianBmT View Post
When I run, another part of the code sprung an error

Got a mismatch error here.

Private Function SaveWebFile(URL As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFileA(0, URL, LocalFilename, 0, 0)
If lngRetVal = 0 Then SaveWebFile = True
End Function

You mat need to change:
Private Function SaveWebFile to Private PtrSafe Function SaveWebFile

or perhaps:
Dim lngRetVal As Long to Dim lngRetVal As LongPtr

I'm afraid I won't be of much help with actually troubleshooting the code, but this may help:
https://msdn.microsoft.com/library/gg264421.aspx

It looks like there are a limited number of areas where you may encounter errors running VBA in Office 64-bit according to the article above. It would seem as though if you change the declarations that you should be OK.

Hope this helps.

Reply With Quote
  #446 (permalink)
TFOpts
Los Angeles, CA
 
Posts: 64 since May 2017
Thanks Given: 49
Thanks Received: 136

@Dudetooth,

I'm very impressed by your XLS-Span tool, you did amazing work; thank you so much for taking the time do build this for us.

I have a question related to spread margins. Is this something you calculate in the tool (I couldn't figure out how you got the numbers)? Or is it something you get from the CME data? I couldn't find good references on how to calculate it online and was hoping for your guidance on that.

Thanks again for the excellent tool; and thanks in advance for your help.

Reply With Quote
  #447 (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

Thank you, glad that it is helpful.

Margin on spreads is derived from the data in the risk files from CME & ICE and calculated, based on the SPAN methodology. Check out https://www.cmegroup.com/clearing/files/span-methodology.pdf

Let me know if you have any other questions or want some specific details.

Reply With Quote
  #448 (permalink)
TFOpts
Los Angeles, CA
 
Posts: 64 since May 2017
Thanks Given: 49
Thanks Received: 136

Thanks Dudetooth.

Can you think of a way to extract a few variables for each option that would allow us to calculate spread margins across options?

Your documentation says the following about calculating spread margins: [Position IM for all legs= Net * (Initial to Maintenance Ratio * Max(Risk Scenarios 1-16, Short Option Minimum)); Initial to Maintenance Ratio extracted from PA2].

If I understand correctly, the formula in the VBA code is:
If calcType = 3 Then
'*********** Risk scenarios added together for spreads
dicSprd.Item("R1") = dicSprd.Item("R1") + clsOpt.r1
dicSprd.Item("R2") = dicSprd.Item("R2") + clsOpt.R2
dicSprd.Item("R3") = dicSprd.Item("R3") + clsOpt.R3
dicSprd.Item("R4") = dicSprd.Item("R4") + clsOpt.R4
dicSprd.Item("R5") = dicSprd.Item("R5") + clsOpt.R5
dicSprd.Item("R6") = dicSprd.Item("R6") + clsOpt.R6
dicSprd.Item("R7") = dicSprd.Item("R7") + clsOpt.R7
dicSprd.Item("R8") = dicSprd.Item("R8") + clsOpt.R8
dicSprd.Item("R9") = dicSprd.Item("R9") + clsOpt.R9
dicSprd.Item("R10") = dicSprd.Item("R10") + clsOpt.R10
dicSprd.Item("R11") = dicSprd.Item("R11") + clsOpt.R11
dicSprd.Item("R12") = dicSprd.Item("R12") + clsOpt.R12
dicSprd.Item("R13") = dicSprd.Item("R13") + clsOpt.R13
dicSprd.Item("R14") = dicSprd.Item("R14") + clsOpt.R14
dicSprd.Item("R15") = dicSprd.Item("R15") + clsOpt.R15
dicSprd.Item("R16") = dicSprd.Item("R16") + clsOpt.R16

'*********** Short option minimum added together for spreads
dicSprd.Item("PosSOM") = dicSprd.Item("PosSOM") + clsOpt.PosShortMin

'*********** Write all risk scenarios to array and find max scenario/SOM to define total risk
If iArrPos = totOpt Then
vArrayS = dicSprd.items()
Risk2 = Application.WorksheetFunction.Max(vArrayS)
If Risk2 = 0 Then Risk2 = 1
dicFut(i)("SprdRisk") = Risk2
End If
End If
To make this work I think we would have to extract the initial maintenance ratio, R1-16 and the PosSOM for each option. With that information we should be able to calculate the spread IM in Excel fairly easily. Would you agree?

Thanks

Reply With Quote
  #449 (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

I guess I'm not tracking what you are looking to do. It seems as though you are asking how to get XLS-SPAN to calculate spread IM ... It already does that (extracting all the needed info for each option from the pa2 files). Am I misunderstand?

Reply With Quote
  #450 (permalink)
TFOpts
Los Angeles, CA
 
Posts: 64 since May 2017
Thanks Given: 49
Thanks Received: 136


Sorry, I should've explained.

I'm looking to back test different strategies more quickly. So far I've exported complete ES put data from XLS-Span to a database. I'm now querying the database to back test different strategies.

The problem is I can only get option level data (the standard output from the "Scan" capability of XLS-Span). To allow me to quickly test spread strategies, I would need to load enough information in the database to be able to independently calculate the spread margin.

So that's why I'm wondering if it's possible to export the data necessary to calculate spread margins at the option level. That way I can combine any group of options and get the spread IM requirement with database queries instead of relying on XLS-Span to do the calculation.

Hopefully that clarifies my purpose.

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