Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
-0.749
Tracking Error
0.28
Treynor Ratio
0
Total Fees
$0.00
namespace QuantConnect.Algorithm.CSharp
{
    public class UncoupledNadionCoil : QCAlgorithm
    {

        public override void Initialize()
        {
            SetStartDate(2019, 1, 20);  //Set Start Date
            SetCash(100000);             //Set Strategy Cash
            
            // AddEquity("SPY", Resolution.Minute);
			AddData<DividendData>("Div_Data", Resolution.Daily);
			

        }

        public void OnData(DividendData data)
        {
            if (data.Symbol == "IBM" || data.Symbol == "ABBV") {
            	Plot("Dividend", data.Symbol, data.Dividend);
            }
        }

    }
    public class DividendData : BaseData
    {
    	public DateTime ExDate;
    	public DateTime RecDate;
    	public DateTime PayDate;
    	public decimal Dividend = 0;
    	public string Frequency = "";
    	public int OnDate = 1;
    	
    	public override SubscriptionDataSource GetSource(
	        SubscriptionDataConfig config,
	        DateTime date,
	        bool isLive)
	    {
	        var source = "https://raw.githubusercontent.com/shilewenuw/FileHost/master/DividendDataFixed.csv";
	
	          return new SubscriptionDataSource(source,
	              SubscriptionTransportMedium.RemoteFile);
	    }
	    
	    
	    public override BaseData Reader(
	        SubscriptionDataConfig config,
	        string line,
	        DateTime date,
	        bool isLive)
	    {
	        if (string.IsNullOrWhiteSpace(line))
	            return null;
	
	        var data = line.Split(',');
	        //var data = line.Split('\t');
	       
	    	var i = 0.0;
	        if (!Double.TryParse(data[1], out i))
	        	return null;
	
	        return new DividendData()
	        {
	            // Make sure we only get this data AFTER trading day - don't want forward bias.
	            Symbol = data[0].Trim(),
	            Time = ParseDate(data[2]),  // we choose the ex-date to be the time
	            Dividend = Convert.ToDecimal(data[1]),
	            RecDate = ParseDate(data[3]),
	            PayDate = ParseDate(data[4]),
	            Frequency = data[5],
	            OnDate = 1,
	        };
	    }
	    
	    public static DateTime ParseDate(string date)
	    {
	    	var data = date.Split('/');
	    	return new DateTime(Convert.ToInt16(data[2]), 
	    		Convert.ToInt16(data[0]),
	    		Convert.ToInt16(data[1]));
	    }
	    
    }
}