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

#1462 Added: Initial support for Ivolatility equity data import #1527

Merged
merged 4 commits into from
Mar 1, 2018
Merged

#1462 Added: Initial support for Ivolatility equity data import #1527

merged 4 commits into from
Mar 1, 2018

Conversation

feribg
Copy link
Contributor

@feribg feribg commented Feb 2, 2018

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.

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.
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.

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)
Copy link
Member

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
Copy link
Member

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);
Copy link
Member

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]);
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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;

@mchandschuh
Copy link
Contributor

@feribg - friendly reminder that this is awaiting your action.

@feribg
Copy link
Contributor Author

feribg commented Feb 22, 2018

@mchandschuh
I've made those changes, but haven't pushed since I started integrating the FactorFileGenerator as well and got stuck at one point, so awaiting a reply on QuantConnect/Lean.DataSource.SDK#19
in order to finalize and push. Thanks!

@mchandschuh
Copy link
Contributor

@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.
@feribg
Copy link
Contributor Author

feribg commented Feb 26, 2018

@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:
https://www.dropbox.com/s/m76x7arusrqix01/stocks_qqq_555_20170426.csv.gz?dl=0

@@ -155,6 +155,8 @@
<ItemGroup>
<Compile Include="GDAXDownloader\GDAXDownloader.cs" />
<Compile Include="GDAXDownloader\Program.cs" />
<Compile Include="GzipStreamProvider.cs" />
<Compile Include="IvolatilityEquityConverter\Program.cs" />
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@mchandschuh mchandschuh left a comment

Choose a reason for hiding this comment

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

Thank you!

@jaredbroad jaredbroad dismissed their stale review March 1, 2018 17:01

Reviewed old code

@mchandschuh mchandschuh merged commit 0d1d14e into QuantConnect:master Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants