public void Analyse(StockHistory stock) { LowerBand = new double[stock.Count]; UpperBand = new double[stock.Count]; Volatility = new double[stock.Count]; MaBand = new double[stock.Count]; MaBand[0] = stock.Closes[0]; for (int i = N; i < stock.Count - N; i++) for (int j = -N; j < N; j++) { MaBand[i] += stock.Closes[i + j]; } for (int i = N; i < stock.Count - N; i++) MaBand[i] /= (double)(N * 2); for (int i = N * 2; i < stock.Count - (N * 2); i++) for (int j = -N; j < N; j++) { Volatility[i] += (stock.Closes[i + j] - MaBand[i + j]) * (stock.Closes[i + j] - MaBand[i + j]); } for (int i = N; i < stock.Count - N; i++) Volatility[i] = Math.Sqrt(Volatility[i]); for (int i = N; i < stock.Count - N; i++) Volatility[i] /= (double)(N * 2); for (int i = 0; i < stock.Count; i++) LowerBand[i] = MaBand[i] - (Volatility[i] * K); for (int i = 0; i < stock.Count; i++) UpperBand[i] = MaBand[i] + (Volatility[i] * K); }
public void Analyse(StockHistory stock) { Data = new double[stock.Count]; Data[0] = stock.Closes[0]; for (int i = 1; i < stock.Count; i++) Data[i] = ((1 - Rate) * stock.Closes[i]) + (Rate * Data[i-1]); }
public static List<StockHistory> BuildCollection(string multipleStocksCsv) { List<StockHistory> list = new List<StockHistory>(); string[] lines = multipleStocksCsv.Split('\n'); string currentShare = "XXXXXXX"; StockHistory history = null; int t = 0; for (int i = 0; i < lines.Length; i++) { string[] bits = lines[i].Split(','); if (bits[1] != currentShare) { if (history != null) { history.Name = currentShare; history.Count = t; history.StartDate = ParseDate(bits[0]); history.Closes = history.Datums.Select(x => x.Close).ToArray(); history.Highs = history.Datums.Select(x => x.High).ToArray(); history.Lows = history.Datums.Select(x => x.Low).ToArray(); history.Opens = history.Datums.Select(x => x.Open).ToArray(); history.Volumes = history.Datums.Select(x => x.Volume).ToArray(); history.CalculateATR(); if (history.Count > 230) list.Add(history); } history = new StockHistory(); history.Datums = new List<Datum>(); currentShare = bits[1]; t = 0; } history.EndDate = ParseDate(bits[0]); history.Datums.Add(new Datum(ParseDate(bits[0]), double.Parse(bits[2]), double.Parse(bits[5]), double.Parse(bits[3]), double.Parse(bits[4]), double.Parse(bits[6]))); t++; } // TODO: Load final share return list; }
public abstract double PredictValue(TechnicalNet.RealData.StockHistory stockHistory, int today, int daysInFuture);
public BollingerBandsMetric(StockHistory stock) { Analyse(stock); }
public XemaMetric(StockHistory stock) { Analyse(stock); }
public FemaMetric(StockHistory data) : base(data) { m_Color = Color.RoyalBlue; }
public SemaMetric(StockHistory data) : base(data) { m_Color = Color.SeaGreen; }
private double[] ComputeInputs(StockHistory stock) { double[] outputs = new double[Fns.Length]; for (int i = 0; i < Fns.Length; i++) { Fns[i].Analyse(stock, Today); outputs[i] = Fns[i].Val; } return outputs; }