| 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 Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees $0.00 |
using NodaTime;
namespace QuantConnect
{
/*
* Demonstration of Problem on data timing when plotting in the "cloud" Vs
* desktop
*/
public class DataTimingProblem : QCAlgorithm
{
//Initialize the data and resolution you require for your strategy:
public override void Initialize()
{
string _co = "CO";
//Start and End Date range for the backtest:
SetStartDate(2016, 07, 26);
SetEndDate(2016, 07, 28);
//Cash allocation
SetCash(25000);
//Add as many securities as you like. All the data will be passed into the event handler:
AddData<RCL>(_co);
// AddData<RCL>(_co, Resolution.Minute); // no effect
var stockPlot = new Chart("Market Price Plot");
var assetPrice = new Series("Price", SeriesType.Line, 0);
var rcCA1 = new Series("C1");
stockPlot.AddSeries(assetPrice);
AddChart(stockPlot);
}
//
public void OnData(TradeBars data)
{
//
}
// Event handler
public void OnData(RCL data)
{
Plot("Market Price Plot", "Price", data.Value);
Log(string.Format("{0} -> {1}: ${2}", data.Time, data.Symbol, data.Value));
}
public class RCL : BaseData
{
public decimal CL = 0; // only one field
public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLive)
{
var url = "https://dl.dropboxusercontent.com/u/1049831/For_QC/rcoil20160727to28.csv";
return new SubscriptionDataSource(url, SubscriptionTransportMedium.RemoteFile);
}
public override BaseData Reader(SubscriptionDataConfig config, string line, System.DateTime date, bool isLive)
{
var rcBar = new RCL() { Symbol = config.Symbol };
try
{
var data = line.Split(',');
/*
* Date/time of imported custom data is in UTC with offset format,
* some minor change made here to turn the parse output into UTC,
* before feeding to ConvertFromUtc()
*/
// rcBar.Time = DateTime.ParseExact(data[0], "yyyy-MM-dd HH:mm:sszz", CultureInfo.InvariantCulture)
// .ConvertFromUtc(TimeZones.Chicao);
rcBar.Time = DateTime.ParseExact(data[0], "yyyy-MM-dd HH:mm:sszz", CultureInfo.InvariantCulture,
DateTimeStyles.AdjustToUniversal)
.ConvertFromUtc(TimeZones.Chicao);
// Parse data
// For simplicity, only parse one column of data as example
rcBar.CL = Convert.ToDecimal(data[4], CultureInfo.InvariantCulture);
// rcBar.CL = Convert.ToDecimal(data[4]); // no effect
rcBar.Value = rcBar.CL;
}
catch
{ }
return rcBar;
}
}
}
}