Hi, I wrote code to test UVXY. Here is my code:
it is very simple, but, UVXY is reverse_split as 1:5. When I short it on Friday, I short 100 shares, then when I bought back on Monday, it should be 20 shares cause, it has been rs. But, the log shows that I bought 100. .. this is the log
namespace QuantConnect
{
public class BasicTemplateAlgorithm : QCAlgorithm
{
private string symbol = "UVXY";
private int quantity=100;
private int trigger=0;
//movingaveragealgorithm emafast=new movingaveragealgorithm(10);
//movingaveragealgorithm emaslow=new movingaveragealgorithm(50);
//MovingAverageConvergenceDivergence _macd;
public override void Initialize()
{
SetStartDate(2016, 07, 22);
SetEndDate(2016, 07, 27);
SetCash(30000);
AddSecurity(SecurityType.Equity, symbol, Resolution.Daily);
Securities["UVXY"].SetDataNormalizationMode(DataNormalizationMode.SplitAdjusted);
Schedule.On(DateRules.Every(DayOfWeek.Friday), TimeRules.AfterMarketOpen("UVXY",0), () =>
{
trigger=-1;
Log(Time.ToString()+"");
});
Schedule.On(DateRules.Every(DayOfWeek.Monday), TimeRules.BeforeMarketClose("UVXY",0), () =>
{
trigger=1;
Log(Time.ToString()+"");
});
}
public void OnData(TradeBars data)
{
Log(Time.ToString()+"\t"+Securities["UVXY"].Close);
Log(Portfolio["UVXY"].Quantity+"cdd");
if(trigger==-1&&!Portfolio.HoldStock)
{
Order(symbol, -quantity);
Log(Time.ToString()+"\t"+"short "+quantity);
}
else if(trigger==1&&Portfolio.HoldStock)
{
Log(Portfolio["UVXY"].Quantity+"abb");
Order(symbol,quantity);
Log(Time.ToString()+"\t"+"close "+quantity);
}
}
}
}