public async Task<IndHeikinEntity[]> GetHeikin(string code, int start = 0, int end = 0, string type = "day") { TickerEntity[] tickers = await base.getTickerEntityArray(code, start, end, type); List<IndHeikinEntity> outList = new List<IndHeikinEntity>(); int len = tickers.Length; double[] open = tickers.Select(t => (double)t.O).ToArray(); double[] close = tickers.Select(t => (double)t.C).ToArray(); double[] high = tickers.Select(t => (double)t.H).ToArray(); double[] low = tickers.Select(t => (double)t.L).ToArray(); double?[] outOpen = new double?[len]; double?[] outClose = new double?[len]; double?[] outHigh = new double?[len]; double?[] outLow = new double?[len]; HeikinAshi.Calculate(open, close, high, low, outOpen, outClose, outHigh, outLow); for (int i = 0; i < len; i++) { outList.Add(new IndHeikinEntity { T = tickers[i].T, P = tickers[i].P, Open = outOpen[i], Close = outClose[i], High = outHigh[i], Low = outLow[i] }); } return outList.Where(r => (start == 0 || r.P >= start) && (end == 0 || r.P <= end)).ToArray(); }
public async void TestHeikinAshi() { TickerBLL bll = new TickerBLL(this.s3_bucket_name, this.tempTickerFolder); List <TickerEntity> tList = await bll.GetDailyTickerEntityList("ORG", 20191001, 20191101); double[] o = new double[tList.Count]; double[] h = new double[tList.Count]; double[] l = new double[tList.Count]; double[] c = new double[tList.Count]; double?[] oo = new double?[tList.Count]; double?[] oh = new double?[tList.Count]; double?[] ol = new double?[tList.Count]; double?[] oc = new double?[tList.Count]; var i = 0; foreach (var t in tList) { o[i] = t.O; h[i] = t.H; l[i] = t.L; c[i] = t.C; i++; } Result res = HeikinAshi.Calculate(o, c, h, l, oo, oc, oh, ol); Console.WriteLine(ObjectHelper.ToJson(oo)); }
public void TestCalculate() { TickerBLL tbll = new TickerBLL(_unit); List <Ticker> tList = tbll.GetTickerListByShareDB(1585, 20160401, 21100000); double[] o = new double[tList.Count]; double[] h = new double[tList.Count]; double[] l = new double[tList.Count]; double[] c = new double[tList.Count]; double?[] oo = new double?[tList.Count]; double?[] oh = new double?[tList.Count]; double?[] ol = new double?[tList.Count]; double?[] oc = new double?[tList.Count]; var i = 0; foreach (var t in tList) { o[i] = t.Open; h[i] = t.High; l[i] = t.Low; c[i] = t.Close; i++; } Result res = HeikinAshi.Calculate(o, c, h, l, oo, oc, oh, ol); }