Hi, JayJay,
thanks for your answer, but I did't understand how you could use the same data class for two custom symbols.
For example, here is the code for reading custom AUDUSD data from my provider:
public class CustomAUD_USD : BaseData
{
public decimal Open = 0;
public decimal High = 0;
public decimal Low = 0;
public decimal Close = 0;
public decimal Volume = 0;
public CustomAUD_USD()
{
this.Symbol = "CustAUDUSD";
}
public override string GetSource(SubscriptionDataConfig config, DateTime date, DataFeedEndpoint datafeed)
{
Assembly asamb = Assembly.GetExecutingAssembly();
string Path = asamb.Location.Substring(0, asamb.Location.LastIndexOf("\\") + 1);
switch (datafeed)
{
//Selecting different source location depending on computer location.
default:
case DataFeedEndpoint.FileSystem:
return "F:\\Visual Studio Projects\\data\\AUDUSD1min.zip";
}
}
public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, DataFeedEndpoint datafeed)
{
//Create a new Bitcoin object that we'll return to Lean.
CustomAUD_USD coin = new CustomAUD_USD();
try
{
string[] a_Data = line.Split(',');
string a_strDate = a_Data[0];
int a_Year = Convert.ToInt32(a_strDate.Substring(0, 4));
int a_Month= Convert.ToInt32(a_strDate.Substring(4, 2));
int a_Day= Convert.ToInt32(a_strDate.Substring(6, 2));
string a_strTime = a_Data[1];
string[] a_strTimeArray = a_strTime.Split(':');
int a_Hour =Convert.ToInt32(a_strTimeArray[0]);
int a_Minute = Convert.ToInt32(a_strTimeArray[1]);
DateTime a_CurDateTime = new DateTime(a_Year, a_Month, a_Day, a_Hour, a_Minute, 0);
coin.Time = a_CurDateTime;
coin.Open = Convert.ToDecimal(a_Data[2]);
coin.High = Convert.ToDecimal(a_Data[3]);
coin.Low = Convert.ToDecimal(a_Data[4]);
coin.Close = Convert.ToDecimal(a_Data[5]);
coin.Volume = Convert.ToDecimal(a_Data[6]);
coin.Symbol = "CustAUDUSD";
coin.Value = coin.Close;
}
catch
{
}
return coin;
}
}
I have the same data (in the same format) for USDRUR. Should I create one more class CustomUSD_RUR, or I can create somehow parent class for both symbol, specify the path to the data?
If I have to create one more class which would be similar to the class above, then I do not understand how to use them both in one strategy. Maybe like this:
public override void Initialize ()
{
SetStartDate (new DateTime (2007, 03, 01)); //Set Start Date
//SetEndDate (2014, 12, 15); //Set End Date
SetEndDate (2015, 12, 01); //Set End Date
SetCash (100000); //Set Strategy Cash
AddData<CustomAUD_USD>("CustAUDUSD");
AddData<CustomUSD_RUR>("CustAUDUSD");
}
public void OnData(CustomAUD_USD data)
{}
public void OnData(CustomUSD_RUR data)
{}
?