Back

Secondary offerings

I'd like to test a strategy on stocks that are out with a secondary offering. I have the list in csv going back 3 years. How would I go about importing it into QC? I don't see anyway to upload files. 

Update Backtest








Please checkout the docs under the Importing Custom Data section:

// In Initialize method:
AddData<Yahoo>("SPY", Resolution.Daily);

/* ... */


// Custom data end-point
public void OnData(Yahoo data)
{
//
}

public class Yahoo : BaseData
{
public decimal Open, High, Low, Close, AdjustedClose, Volume;

// Return the URL external source for the data:
public override SubscriptionDataSource GetSource(
SubscriptionDataConfig config,
DateTime date,
bool isLive)
{
// Using Quandl Wrapper on Yahoo Finance API to Sort Data:
var url = "https://www.quandl.com/api/v1/datasets/YAHOO/" +
config.Symbol +
".csv?sort_order=asc&exclude_headers=true";
return new SubscriptionDataSource(
url,
SubscriptionTransportMedium.RemoteFile);
}

// Convert each line of the file above into an object.
public override BaseData Reader(
SubscriptionDataConfig config,
string line,
DateTime date,
bool isLive)
{
Yahoo yBar = new Yahoo();
try
{
string[] data = line.Split(',');
yBar.Symbol = config.Symbol; // Required.
yBar.Time = DateTime.ParseExact(data[0],
"yyyy-MM-dd", CultureInfo.InvariantCulture);
yBar.Open = Convert.ToDecimal(data[1]);
yBar.High = Convert.ToDecimal(data[2]);
yBar.Low = Convert.ToDecimal(data[3]);
yBar.Close = Convert.ToDecimal(data[4]);
yBar.Volume = Convert.ToDecimal(data[5]);
yBar.AdjustedClose = Convert.ToDecimal(data[6]);
// Required for portfolio calculations
yBar.Value = yBar.AdjustedClose;
}
catch
{
//
}
return yBar;
}
}

If you save your files in a Dropbox folder and create a public link that would be used in the GetSource method, you will be able to run your algorithm locally and in the cloud.

Below, you can find a working example.
 

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed