namespace QuantConnect
{
/*
* Test members of data
*
* SPY not found in data if daily and minute data
* are mixed
*/
public class BasicTemplateAlgorithm : QCAlgorithm
{
public override void Initialize()
{
// backtest parameters
SetStartDate(2017, 8, 22);
SetEndDate(2017, 8, 23);
// cash allocation
SetCash(25000);
// request specific equities
// including forex. Options and futures in beta.
AddEquity("VXX", Resolution.Daily);
UniverseSettings.Resolution = Resolution.Minute;
AddUniverse(Universe.DollarVolume.Top(5));
}
/*
* New data arrives here.
* The "Slice" data represents a slice of time, it has all the data you need for a moment.
*/
public void OnData(TradeBars data)
{
int i=0;
decimal orderSize = 0;
decimal tradeCashAllocation= 6000;
orderSize = Math.Floor(tradeCashAllocation / Securities["VXX"].Price);
Debug("Buy x " + Time.Date.ToShortDateString() + " orderSize=" + orderSize + " Portfolio.Cash=" + Portfolio.Cash ) ;
//MarketTicket = StopMarketOrder(Stock.Symbol, orderSize, price * 0.97m); // 0.95m);
if (! Portfolio.Invested)
SetHoldings("VXX", orderSize);
}
}
}