|
Andrew Thomas
2022-04-23 18:51:04
|
|
My question involves using the advanced money management system to access future price data for a stock. I'm currently using AMM to set the number of shares to buy/sell using the close price of the previous day. However if there is a big jump/drop on the open of the next day (trading day) it leads to big errors. I would like to use the open of the actual trading day to set the number of shares to buy/sell.
Here is a section of existing code (in the OnEndPeriod section)
for(int i=0;i<sorders.Length;i++)
{
TimeSeries open = Data.GetPriceSeries(sorders[i].Symbol, "open");
double newopen = open[0] ; // I think -1 gives the open of the next day - the day the trade will happen
int size = (int)Math.Floor(samount / newopen); // determines shares to buy/sell using the amount of funds per stock (samount) divided by the price of the stock
sorders[i].NbShares = size;
sorders[i].SubmitChanges();
}
I know that [0] is current day and [1] is previous day, and usually [-1] is next day, but it does not seem to work here. Is using an index of [-1] not allowed for a timeseries and if so is there another way to access a future open price in the AMM system to set orders for the day?
Thanks! This seems like a simple question - but I couldn't find the information online.
Best - Andy
|
|