Hello,

I found this sample C# algorithm Lean/CustionDataBitcoinAlgorithm

and I tried to adapt it to multiple forex pairs that I have in the form of OHLC CSV files. 

The default format of those files is: unix timespamp, open, high, low, close.

I decided to split the custom data class into 2 part: base Forex class that has the methods for importing the data and child classes with their own constructors and source files. One such instance is class NzdUsd in the code below.

Here is my code:

using System;
using System.Globalization;
using Newtonsoft.Json;
using QuantConnect.Data;

namespace QuantConnect.Algorithm.CSharp
{

public class CustomDataForexAlgorithm : QCAlgorithm
{

public override void Initialize()
{
//Weather data we have is within these days:
SetStartDate(2005, 8, 14);
SetEndDate(2005, 8, 14);

//Set the cash for the strategy:
SetCash(100000);

AddData<NzdUsd>("NZDUSD");
}


public void OnData(NzdUsd data)
{
if (!Portfolio.Invested)
{
if (data.close != 0)
{
Order(
"NZDUSD",
(Portfolio.MarginRemaining / Math.Abs(data.close + 1))
);
}
Console.WriteLine("Buying NZDUSD: " + data.close);
}
}

public class Forex : BaseData
{
[JsonProperty("timestamp")]
public DateTime timestamp;
[JsonProperty("Open")]
public decimal open = 0;
[JsonProperty("High")]
public decimal high = 0;
[JsonProperty("Low")]
public decimal low = 0;
[JsonProperty("Close")]
public decimal close = 0;

// default constructor - should exits
public Forex()
{
Symbol = "FX";
}

// reader method: reads one #line at a time
public override BaseData Reader
(
SubscriptionDataConfig config,
string line
DateTime date,
bool isLiveMode
)
{
var fx = new Forex();

try
{
string[] data = line.Split(',');
fx.timestamp = uni_to_dt(Convert.ToDouble(data[0]));
fx.open = Convert.ToDecimal(data[1], CultureInfo.InvariantCulture);
fx.high = Convert.ToDecimal(data[2], CultureInfo.InvariantCulture);
fx.low = Convert.ToDecimal(data[3],CultureInfo.InvariantCulture);
fx.close = Convert.ToDecimal(data[4], CultureInfo.InvariantCulture);
}
catch { /* Do nothing, skip first title row */ }

return fx;
}

public static DateTime uni_to_dt( double unixTimeStamp )
{
// Unix timestamp is seconds past epoch
System.DateTime dtDateTime = new DateTime(1970,1,1,0,0,0,0,System.DateTimeKind.Utc);
dtDateTime = dtDateTime.AddSeconds( unixTimeStamp ).ToLocalTime();
return dtDateTime;
}
}

public class NzdUsd : Forex
{
public NzdUsd()
{
Symbol = "NZDUSD";
}

string source = @"G:\home\marin\tmp\histdata\NZDUSD\new\DAT_ASCII_NZDUSD_M1_2005_test.csv" ;

public override SubscriptionDataSource GetSource
(
SubscriptionDataConfig config,
DateTime date,
bool isLiveMode
)
{
return new SubscriptionDataSource
(
source,
SubscriptionTransportMedium.LocalFile,
FileFormat.Csv
);
}
}
}
}

I am able to compile this as a QC project it doesn't seem to import the custom data. Any ideas?