-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
#1462 Added: Initial support for Ivolatility equity data import #1527
Conversation
ToolBox support for converting Ivolatility equity data to Lean TradeBar format for min,hour,day resolutions. Also adds Gzip stream reader to list of supported zip formats.
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.
Nice first PR @feribg! I've made some comments about minor changes but the structure and code looks clean overall. I can't test this without a IV data can you confirm it works with some sample data they provide through the website?
/// Closes the specified source file stream | ||
/// </summary> | ||
/// <param name="source">The source file to be closed</param> | ||
public void Close(string source) |
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.
Will you need to close the stream above?
using ikvm.extensions; | ||
using QuantConnect.Data.Market; | ||
|
||
namespace QuantConnect.ToolBox.IvolatilityEquityConverter |
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.
Guessing this should be capital V? (+plus the file name)
{ | ||
var splits = fileName.Split('_'); | ||
var ticker = splits[2].toLowerCase(); | ||
return Symbol.Create(ticker, SecurityType.Equity, Market.USA); |
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.
👍
var priceBid = Decimal.Parse(linearray[PriceBidField]); | ||
var sizeBid = Decimal.Parse(linearray[SizeBidField]); | ||
var priceAsk = Decimal.Parse(linearray[PriceAskField]); | ||
var sizeAsk = Decimal.Parse(linearray[SizeAskField]); |
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.
The quote bar information will be lost in the trade bar file. Maybe there's enough information to write QuoteBars for equity as well?
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.
We can write both QuoteBar
and TradeBar
, but for quotes all 4 OHLC values will be identical as mentioned in the ticket. I will add support for both.
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.
@mchandschuh There's a problem writing Quote bars due to invalid cast when writing equity quotes for minute resolution. Issue is, it tries to cast to TradeBar
even though im providing it quote bars. So for this current PR I will ignore and comment on it in the code.
case SecurityType.Equity:
switch (resolution)
{
case Resolution.Tick:
var tick = (Tick) data;
return ToCsv(milliseconds, Scale(tick.LastPrice), tick.Quantity, tick.Exchange, tick.SaleCondition, tick.Suspicious ? "1" : "0");
case Resolution.Minute:
case Resolution.Second:
var bar = (TradeBar) data;
return ToCsv(milliseconds, Scale(bar.Open), Scale(bar.High), Scale(bar.Low), Scale(bar.Close), bar.Volume);
case Resolution.Hour:
case Resolution.Daily:
var bigBar = (TradeBar) data;
return ToCsv(longTime, Scale(bigBar.Open), Scale(bigBar.High), Scale(bigBar.Low), Scale(bigBar.Close), bigBar.Volume);
}
break;
@feribg - friendly reminder that this is awaiting your action. |
@mchandschuh |
@feribg -- is it possible to separate the pull requests so we can merge them individually? Does the IVolatility equity import require the factor file generator changes? |
Close opened streams, re-name namespace and add initial support for factor file generation.
@mchandschuh This should be good to go, I did the suggested changes and I will add the factors as a separate PR although there's preliminary support in the program here. Here is a sample Ivol file that you can test with: |
ToolBox/QuantConnect.ToolBox.csproj
Outdated
@@ -155,6 +155,8 @@ | |||
<ItemGroup> | |||
<Compile Include="GDAXDownloader\GDAXDownloader.cs" /> | |||
<Compile Include="GDAXDownloader\Program.cs" /> | |||
<Compile Include="GzipStreamProvider.cs" /> | |||
<Compile Include="IvolatilityEquityConverter\Program.cs" /> |
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.
It looks like the actual file on disk uses IVolatilityEquityConverter
(capital V) -- while this will go unnoticed on windows, on any case sensitive file system (such as used in unix systems) it will cause an error.
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.
Sorry Im actually working in Rider on Mac, so this was running fine and wen't unnoticed. Im guessing VS support for those files is much better.
Fix filename typo in the .csproj file
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.
Thank you!
ToolBox support for converting Ivolatility equity data to
Lean TradeBar format for min,hour,day resolutions.
Also adds Gzip stream reader to list of supported zip formats.