Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update futures margins #4479

Merged
merged 7 commits into from
Jun 24, 2020
Merged

Update futures margins #4479

merged 7 commits into from
Jun 24, 2020

Conversation

Jay-Jay-D
Copy link
Contributor

@Jay-Jay-D Jay-Jay-D commented Jun 2, 2020

Kudos to @gsalaz98 for this awesome work!

Description

Update future margins data.

Related Issue

N/A

Motivation and Context

Better and updated margins improves futures backtesting modelling and behavior.

Requires Documentation Change

N/A

How Has This Been Tested?

N/A

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

@Jay-Jay-D Jay-Jay-D requested a review from gsalaz98 June 2, 2020 20:43
@Jay-Jay-D Jay-Jay-D self-assigned this Jun 2, 2020
@Jay-Jay-D Jay-Jay-D added the data-integrity Tickets relating to keeping the LEAN data accurate. label Jun 2, 2020
Copy link
Contributor

@gsalaz98 gsalaz98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to do a bit more work to filter out and isolate some of these issues. Overall, this is pretty good 😃

Data/future/cme/margins/CJY.csv Outdated Show resolved Hide resolved
Data/future/cbot/margins/AW.csv Outdated Show resolved Hide resolved
Data/future/cbot/margins/BCF.csv Outdated Show resolved Hide resolved
# https://www.cmegroup.com/tools-information/lookups/advisories/clearing/Chadv13-594.html
20130410,4180,3800
20131202,2970,2700
20131204,4180,3800
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like some of these old values' initial margins are not 110% of the maintenance.

Data/future/cbot/margins/ZF.csv Show resolved Hide resolved
20140919,715,650
20141017,632.5,575
20140922,176,160
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sporadic, though it seems standard for this contract. If I remember correctly, the Eurodollar contract's margins apply to tiers of contracts. Maybe the changes in tiers causes the value to be very volatile 🤔

20150616,6025,5477
20150617,5834,5303
20150618,5636,5123
20150619,5431,4937
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some thoughts, no changes required:

These margins change every day. Maybe this is the percentage of a single contract that is required as initial margin rather than fixed portfolio values. Either way, this is going to be great for backtesting now that we have all of these margins.

Comment on lines 49 to 50
20170310,1375,1250
# https://www.cmegroup.com/notices/clearing/2017/05/Chadv17-167.html
20170407,13750,12500
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is 10x?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

Data/future/nymex/margins/A9N.csv Outdated Show resolved Hide resolved
Comment on lines 18 to 20
20131015,4950,4500
# https://www.cmegroup.com/notices/clearing/2017/03/Chadv17-108.html
20131016,16500,15000
20131029,27500,25000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong order of magnitude.

Copy link
Member

@jaredbroad jaredbroad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suspect margins

Data/future/cbot/margins/EH.csv Outdated Show resolved Hide resolved
Data/future/cbot/margins/EH.csv Outdated Show resolved Hide resolved
Copy link
Member

@jaredbroad jaredbroad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sanity check these last bits and then should be good to go.

Comment on lines +9 to +12
20130320,550,500
20130404,1430,1300
20130417,550,500
20130502,1430,1300
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one still seems not quite correct. Perhaps can just skip all the mid-month ones.

Copy link
Contributor

@gsalaz98 gsalaz98 Jun 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Despite the back and forth, this is one of the test cases I focused on early to ensure we had proper margins. I took a look closely, and this one is correct.

The margins change frequently because when the front-month contract expires, the new front-month contract still retains its old margin value, but it shifts to a lower margin value once that contract is closer to expiry.

Comment on lines 182 to 186
20170303,385,350
# https://www.cmegroup.com/notices/clearing/2017/05/Chadv17-183.html
20170519,363,330
# https://www.cmegroup.com/notices/clearing/2017/11/Chadv17-467.html
20170306,348,316
20170307,336,305
20170308,324,294
20170309,311,282
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonder if we should increase this to every month minimum. Every 3 days is a little much for this data

# https://www.cmegroup.com/tools-information/lookups/advisories/clearing/Chadv13-268.html
20130611,2475,2250
# https://www.cmegroup.com/tools-information/lookups/advisories/clearing/Chadv13-304.html
20130102,85,77
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems abnormally low

Comment on lines 28 to 29
20130206,72,65
20130207,2200,2000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Front-month roll over?

Comment on lines 179 to 185
20130905,8517,7742
20130906,6387,5806
20130909,61600,56000
20130910,66000,60000
20140421,52800,48000
# https://www.cmegroup.com/tools-information/lookups/advisories/clearing/Chadv14-279.html
20140714,45100,41000
# https://www.cmegroup.com/tools-information/lookups/advisories/clearing/Chadv14-469.html
20141205,55000,50000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you think this shifts from every 3 days to every few months?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is that CME decided to switch from percentage values to a fixed dollar value around the time of the 2013-09-09 entry, but I have no known way to confirm this. CME currently shows fixed margin values on their margins page, but those that have percentage margins tended to behave like this contract did early on.

@jaredbroad
Copy link
Member

Known issues for posterity:

1 - These are the margins of the first contract on-chain - at least a month out. The real margins approaching expiration are much lower. Including every single day's update is a lot of unnecessary data that doesn't improve the platform much.

2 - LEAN margin modeling for these contracts is a large approximation and should actually be per contract not a fixed number for all contracts. Rewrite needed to move these into an algorithm/approximation based on the SPAN risk formula.

That said -- its still a large improvement with many new, previously unmodelled contracts added so will merge as is and plan for rewrite of futures margins at a later date.

@Martin-Molinero Martin-Molinero merged commit c3062e4 into master Jun 24, 2020
@Martin-Molinero Martin-Molinero deleted the update-margins branch August 18, 2020 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
data-integrity Tickets relating to keeping the LEAN data accurate.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants