External signal data about different stocks

Hi everyone!

I have a question about using external data (specifically a csv from dropbox). I have data about events that happen that impact different stocks. The format for my CSV file is:

 "date", "symbol", "value"

While using the GetSource/Reader method it's apparent I can't have multiple symbols in my csv. Is there a way to use GetSource with a csv that has multiple symbols? Should I abandon this approach and use the `` method? Where should I call this method if I want the file to be downloaded once for backtesting and everyday for live trading?


Update Backtest

I woudl've thought you could have got the symbol through this?

var index = new Custom();
string[] data = line.Split(',');
index.Time = DateTime.Parse(data[0]);
index.Symbol = Convert.ToString(data[1]);
index.Value = Convert.ToDecimal(data[2]);
catch { }

return index;

Using the GetSource and Reader methods while having multiple symbols is possible. This example below shows an example of overriding the GetSource and Reader methods and returning a list of stocks. The StockDataSource(PythonData) should be similar to the implementation needed in this case. A new list of stocks is read from the .csv file and returned every day to be traded. The dropbox links in the sample code above can still be accessed as a resource to see how the data is properly parsed.

Thanks guys! I will try the AddUniverse method! That looks promising! 

William, in python you cannot set the symbol of the data source based on a value in the csv. I don't know why but it has to be set to `config.symbol`.


Thanks for the reply Gurumeher Sawhney. I've been playing with the algo and I have a question. My csv contains dates that occur on non-trading days. When this happens, the data is fed to the algo on the next trading day. I'm sure this is reasonable in many cases but not in mine.

How can I make the algo only trade the symbols in the csv on the date listed (and if the date listed is not a trading day, then skip it). 

Ive tried this but it didn't work:

def stockDataSource(self, data):
list = []
for item in data:
if ==
for symbol in item["Symbols"]:
return list


Here I attempt to only add the symbols if the current date is equal to the date in the csv. This results in no symbols ever being added. How can I keep the symbols from being added if the simulation date is not the date in the CSV? Or how can I skip trading if the simulation date isn't the date the symbols were meant to be traded on?



Update Backtest


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.


This discussion is closed