-
Notifications
You must be signed in to change notification settings - Fork 170
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
Add new tutorial for multi-currencies arbitrage using Bellman-Ford Algorithm #48
base: master
Are you sure you want to change the base?
Conversation
Add files via upload
## Description Replying to this issue Related Issue How to extract Implied volatility from Quantconnect QuantConnect#47 Types of changes -[ ] Bug fix (non-breaking change which fixes an issue) -[ ] Refactor (non-breaking change which improves implementation) -[ ] New feature (non-breaking change which adds functionality) -[ x] Non-functional change (xml comments/documentation/etc) Checklist: -[ x] My code follows the code style of this project. -[ x] I have read the CONTRIBUTING [document](https://github.com/QuantConnect/Lean/blob/master/CONTRIBUTING.md). -[ x] My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>
## Description Adding nee tutorial Types of changes -[ ] Bug fix (non-breaking change which fixes an issue) -[ ] Refactor (non-breaking change which improves implementation) -[ ] New feature (non-breaking change which adds functionality) -[ x] Non-functional change (xml comments/documentation/etc) Checklist: -[ x] My code follows the code style of this project. -[ x] I have read the CONTRIBUTING [document](https://github.com/QuantConnect/Lean/blob/master/CONTRIBUTING.md). -[ x] My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>
Capital Structure Arbitrage ## Description Adding nee tutorial Types of changes -[ ] Bug fix (non-breaking change which fixes an issue) -[ ] Refactor (non-breaking change which improves implementation) -[ ] New feature (non-breaking change which adds functionality) -[ x] Non-functional change (xml comments/documentation/etc) Checklist: -[ x] My code follows the code style of this project. -[ x] I have read the CONTRIBUTING [document](https://github.com/QuantConnect/Lean/blob/master/CONTRIBUTING.md). -[ x] My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>
Thank you for the commits! Looks great and technical. Leaving a few comments above. |
For capital_structure_arbitrage.ipynb, it is a piece of information with math formula development right? So maybe you can change it into a |
Hey Louis,
I really appreciate your feedback! I’ll fix in the upcoming days!
Regards,
Attilio
Il giorno mer 10 apr 2024 alle 09:37 Louis Szeto ***@***.***>
ha scritto:
… For capital_structure_arbitrage.ipynb
<https://github.com/QuantConnect/Research/pull/48/files#diff-08b49dd48eccf2d3c59f3964a4d76f594d1a630a7c0065c885e8a133e00c5e1a>,
it is a piece of information with math formula development right? So maybe
you can change it into a .md file with latex to type in the formula.
—
Reply to this email directly, view it on GitHub
<#48 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQXFNSPPXX5KLJWF44BTRF3Y4TT27AVCNFSM6AAAAAAYRISIHGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBWG42DKNZZHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Hey,
capital_structure_arbitrage.ipynb
<https://github.com/QuantConnect/Research/pull/48/files#diff-08b49dd48eccf2d3c59f3964a4d76f594d1a630a7c0065c885e8a133e00c5e1a>
is
actually a notebook with python code and math formula, so it's not possible
to make a single .md file.
Regards,
Attilio
Il giorno mer 10 apr 2024 alle ore 09:37 Louis Szeto <
***@***.***> ha scritto:
… For capital_structure_arbitrage.ipynb
<https://github.com/QuantConnect/Research/pull/48/files#diff-08b49dd48eccf2d3c59f3964a4d76f594d1a630a7c0065c885e8a133e00c5e1a>,
it is a piece of information with math formula development right? So maybe
you can change it into a .md file with latex to type in the formula.
—
Reply to this email directly, view it on GitHub
<#48 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQXFNSPPXX5KLJWF44BTRF3Y4TT27AVCNFSM6AAAAAAYRISIHGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBWG42DKNZZHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Hey Louis,
what's the correct folder?
Regards,
Attilio
Il giorno mer 10 apr 2024 alle ore 09:35 Louis Szeto <
***@***.***> ha scritto:
… Thank you for the commits! Looks great and technical. Leaving a few
comments above.
BTW I think Local_Stochastic_Volatility_Model.ipynb
<https://github.com/QuantConnect/Research/pull/48/files/33eaadb7717742e7ad3df123d561c0be4ea85900#diff-b621b661217f0674a1c2e11a56f70a8b1465dc8e2a4e4fc63e4b4528f462a109>
is in a wrong location. Please put it into the folder like the others.
—
Reply to this email directly, view it on GitHub
<#48 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AQXFNSIQPTS562CNJS4QUPLY4TTVHAVCNFSM6AAAAAAYRISIHGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBWG42DCMZTGA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
@leo-ai-for-trading Local_Stochastic_Volatility_Model.ipynb This notebook should be placed in the same folder as the others. |
" price2 = qb.History(ticker2, start_time, end_time, Resolution.Tick)['lastprice']\n", | ||
" price3 = qb.History(ticker3, start_time, end_time, Resolution.Tick)['lastprice']\n", | ||
"\n", | ||
" df = pd.DataFrame({'symbol':list(),'price':list()})\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May add a comment on why using negative log price (for minimum distance and eliminate compounding effect...)
" @start_time: date to start getting data\n", | ||
" @end_time: last day of getting data\n", | ||
" \"\"\"\n", | ||
"\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is some restrictions on how do you choose the crypto. Say if we choose BTCUSD, ETHUSD & BTCETH, there will be 4 currencies and 3 directional edges that always get positive results. If we're doing arbitrage, we should do BTCUSD, USDETH & ETHBTC to force a long-short balance in each currency. It will be good to add description above.
" price1 = qb.History(ticker1, start_time, end_time, Resolution.Tick)['lastprice']\n", | ||
" price2 = qb.History(ticker2, start_time, end_time, Resolution.Tick)['lastprice']\n", | ||
" price3 = qb.History(ticker3, start_time, end_time, Resolution.Tick)['lastprice']\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tick resolution might not align with time, recommend to use second instead. Also, there might not be trading information some illiquid currencies, it maybe better to use History[QuoteBar]
.
"\\begin{aligned}\n", | ||
"&\\begin{aligned}\n", | ||
"\\sigma_{l o c}^2(K, T, S) & =\\sigma^2-\\lambda \\frac{K \\frac{\\partial C}{\\partial K}}{\\frac{1}{2} K^2 \\frac{\\partial^2 C}{\\partial K^2}} \\\\\n", | ||
"& =\\sigma^2+2 \\lambda \\sigma \\sqrt{T} \\frac{N\\left(d_2\\right)}{N^{\\prime}\\left(d_2\\right)}\n", | ||
"\\end{aligned}\\\\\n", | ||
"&d_2=\\frac{\\log S / K+\\lambda T}{\\sigma \\sqrt{T}}-\\frac{\\sigma \\sqrt{T}}{2}\n", | ||
"\\end{aligned}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Display issue
"source": [ | ||
"\n", | ||
" \n", | ||
"def get_data(sym1:str,sym2:str, sym3:str , start_time: datetime, end_time: datetime):\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit - we use (self, arg1: type1 = a, arg2: type2 = b, arg3: type3 = c) -> type4:
. Please fix the nit
" def __getitem__(self,v):\n", | ||
" return self.neighbors[v]\n", | ||
" \n", | ||
" def add_node(self,name):\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
" self.weight.append({})\n", | ||
" return self.name2node[name]\n", | ||
" \n", | ||
" def add_edge(self,name_u,name_v,weight_uv=None):\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
" self.add_arc(name_u, name_v, weight_uv) \n", | ||
" self.add_arc(name_v, name_u, weight_uv)\n", | ||
"\n", | ||
" def add_arc(self,name_u,name_v,weight_uv=None):\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit
"r = 0.0341 \n", | ||
"D = 0.0\n", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can use Lean's InterestRateProvider
InterestRateProvider().GetInterestRate(goog_df.index[...]) # sub in the time
DividendYieldProvider(goog).GetDividendYield(goog_df.index[...]) # sub in the time
Description
Adding docs for the calculation of local volatility model
Related Issue
N/A
Motivation and Context
tutorial for new members (in particular with heavy Math background)
Types of changes
Checklist: