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 MathNet.Numerics.Statistics; using QuantConnect.Orders.Slippage; using System.Text; namespace QuantConnect { public class MultiFeedTest : QCAlgorithm { const string _symbolVXX = "VXX"; const string _symbolXIV = "XIV"; const string _symbolGSPC = "YAHOO/INDEX_GSPC"; const string _symbolVIX = "YAHOO/INDEX_VIX"; const string _symbolVX1 = "SCF/CBOE_VX1_EW"; const string _symbolVX2 = "SCF/CBOE_VX2_FW"; Dictionary<string, DataObject> _dataobjects = new Dictionary<string, DataObject>(); public override void Initialize() { // Minimum Start Date: 2011-3-1 SetStartDate(2012, 3, 1); SetEndDate(2012, 3, 24); SetCash(5000); SetWarmup(10); AddSecurity(SecurityType.Equity, _symbolXIV, Resolution.Daily); AddSecurity(SecurityType.Equity, _symbolVXX, Resolution.Daily); AddData<Quandl>(_symbolGSPC, Resolution.Daily); AddData<Quandl>(_symbolVIX, Resolution.Daily); AddData<QuandlFuture>(_symbolVX1, Resolution.Daily); AddData<QuandlFuture>(_symbolVX2, Resolution.Daily); DataObject vxxobject = new DataObject(_symbolVXX); DataObject xivobject = new DataObject(_symbolXIV); DataObject gspcobject = new DataObject(_symbolGSPC); DataObject vixobject = new DataObject(_symbolVIX); DataObject vx1object = new DataObject(_symbolVX1); DataObject vx2object = new DataObject(_symbolVX2); _dataobjects.Add(_symbolVXX, vxxobject); _dataobjects.Add(_symbolXIV, xivobject); _dataobjects.Add(_symbolGSPC, gspcobject); _dataobjects.Add(_symbolVIX, vixobject); _dataobjects.Add(_symbolVX1, vx1object); _dataobjects.Add(_symbolVX2, vx2object); Schedule.Event().EveryDay().At(16, 00).Run(() => { PrintData(); }); } public void OnData(TradeBars bars) { foreach (KeyValuePair<Symbol, TradeBar> entry in bars) { string symbolstring = entry.Key; TradeBar bar = entry.Value; switch(bar.Symbol) { case(_symbolVXX): { _dataobjects[_symbolVXX].Price = bar.Value; _dataobjects[_symbolVXX].DateTimePumped = this.Time; _dataobjects[_symbolVXX].DateTimeEnd = bar.EndTime; break; } case(_symbolXIV): { _dataobjects[_symbolXIV].Price = bar.Value; _dataobjects[_symbolXIV].DateTimePumped = this.Time; _dataobjects[_symbolXIV].DateTimeEnd = bar.EndTime; break; } } } } public void OnData(Quandl quandl) { switch(quandl.Symbol) { case(_symbolGSPC): { _dataobjects[_symbolGSPC].Price = quandl.Value; _dataobjects[_symbolGSPC].DateTimePumped = this.Time; _dataobjects[_symbolGSPC].DateTimeEnd = quandl.EndTime; break; } case(_symbolVIX): { _dataobjects[_symbolVIX].Price = quandl.Value; _dataobjects[_symbolVIX].DateTimePumped = this.Time; _dataobjects[_symbolVIX].DateTimeEnd = quandl.EndTime; break; } } } public void OnData(QuandlFuture quandlfuture) { switch(quandlfuture.Symbol) { case(_symbolVX1): { _dataobjects[_symbolVX1].Price = quandlfuture.Value; _dataobjects[_symbolVX1].DateTimePumped = this.Time; _dataobjects[_symbolVX1].DateTimeEnd = quandlfuture.EndTime; break; } case(_symbolVX2): { _dataobjects[_symbolVX2].Price = quandlfuture.Value; _dataobjects[_symbolVX2].DateTimePumped = this.Time; _dataobjects[_symbolVX2].DateTimeEnd = quandlfuture.EndTime; break; } } } public void PrintData() { if (this.Time.Date.DayOfWeek != DayOfWeek.Saturday && this.Time.Date.DayOfWeek != DayOfWeek.Sunday) { if (IsWarmingUp) { Log("(WARMING UP) DATA SNAPSHOT"); } else { Log("DATA SNAPSHOT:"); } foreach(KeyValuePair<string, DataObject> entry in _dataobjects) { string stringsymbol = "Symbol: "+ entry.Value.Symbol.ToString(); string stringprice = "Price: " + entry.Value.Price.ToString("#.##"); string stringtimepumped = "Time Pumped: " + entry.Value.DateTimePumped.ToShortDateString() + " " + entry.Value.DateTimePumped.ToShortTimeString(); string stringtimeend = "Time End: "+ entry.Value.DateTimeEnd.ToShortDateString() + " " + entry.Value.DateTimeEnd.ToShortTimeString(); Log(String.Format("\t{0,-30}{1,-20}{2,-40}{3,-40}", stringsymbol, stringprice, stringtimepumped, stringtimeend)); } } } } }
namespace QuantConnect { public class QuandlFuture : Quandl { public QuandlFuture() : base(valueColumnName: "Settle") { } } }
namespace QuantConnect { public class DataObject { #region Fields private string _symbol; private decimal _price; private DateTime _datetimepumped; private DateTime _datetimeend; #endregion #region Properties public string Symbol { get { return _symbol; } set { _symbol = value; } } public decimal Price { get { return _price; } set { _price = value; } } public DateTime DateTimePumped { get { return _datetimepumped; } set { _datetimepumped = value; } } public DateTime DateTimeEnd { get { return _datetimeend; } set { _datetimeend = value; } } #endregion #region Constructor public DataObject(string symbol) { Symbol = symbol; Price = 0.0m; DateTimePumped = DateTime.MinValue; DateTimeEnd = DateTime.MinValue; } #endregion } }