public static void ProductListUpdate(object obj) { RealTimeData realTimeData = (RealTimeData)obj; // TODO -- Add delegate method DataService.UpdateListView(DataService.priceListDelegate, realTimeData); }
public void DataUpdate() { RealTimeData[] rtds; lock (realTimeDatas) { if (this.realTimeDatas.Count == 0) { return; } rtds = new RealTimeData[realTimeDatas.Count]; realTimeDatas.CopyTo(rtds); realTimeDatas.Clear(); } if (isInitialized) { foreach (RealTimeData rtd in rtds) { Console.WriteLine(" RTD " + rtd.symbol + " time " + rtd.dateTime + " price " + rtd.datas[0]); LogUtil.Info(" RTD " + rtd.ToString()); UpdateDataSource(rtd); UpdateDataProvider(rtd); } } }
public static void DataProviderUpdate(object obj) { RealTimeData realTimeData = (RealTimeData)obj; if (DataService.symList.Contains(realTimeData.symbol)) { Console.WriteLine(" Symbol " + realTimeData.symbol + " time " + realTimeData.dateTime + " Price ::" + realTimeData.datas[0]); DataService.isUpdated = true; //FXDataSource.UpdateGraphicUI(FXDataSource.sourceHandler, realTimeData); } }
public static void UpdatePriceList(RealTimeData rtd) { RealTimeData = rtd; //MethodInvoker mi = new MethodInvoker(UpdateRealTimeListView); if (priceList != null && priceList.IsHandleCreated) { //priceList.BeginInvoke(mi); //priceChangedtDelegate.Invoke(rtd); priceList.BeginInvoke(priceChangedtDelegate, rtd); } }
public static List <RealTimeData> ParseRtdMsg(string realTimeMsg) { List <RealTimeData> list = new List <RealTimeData>(); try { string[] rmsgs = Regex.Split((string)realTimeMsg, @"\r\n", RegexOptions.IgnoreCase); foreach (string msg in rmsgs) { if (msg.Trim().Length > 0) { try { string[] msgs = msg.Split(','); //Symbol symbol = (Symbol)Enum.Parse(typeof(Symbol), msgs[0].Trim()); Symbol symbol = ParseSymbol(msgs[0].Trim()); if (symbol == Symbol.UNKNOWN) { Console.WriteLine(" UNKNOWN symbol " + msgs[0]); continue; } DateTime dateTime = BarDataHelper.ParseCSVDateTime(msgs[1].Trim(), msgs[2].Trim()); double[] datas = new double[msgs.Length - 3]; for (int i = 3; i < msgs.Length; i++) { if (msgs[i].Trim().Length > 0) { datas[i - 3] = Double.Parse(msgs[i]); } } RealTimeData realTimeData = new RealTimeData(symbol, dateTime, datas); list.Add(realTimeData); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); continue; } } } } catch (Exception e) { Console.WriteLine(e.StackTrace); } return(list); }
public bool LoadFile(string fileName, int startingRow, int rowsLimit, out List <RealTimeData> datas, bool isDecrypt) { datas = new List <RealTimeData>(); int i = 0; using (System.IO.TextReader tr = new System.IO.StreamReader(fileName)) { try { DateTime time = new DateTime(); RealTimeData rtd = new RealTimeData(); for (i = 0; i < startingRow + rowsLimit || rowsLimit == 0; i++) { string lineStr = tr.ReadLine(); if (lineStr == null) { break; } if (i >= startingRow) {// Parse. //if (isDecrypt) //{ // lineStr = crypta.decrypt(lineStr); //} string[] lineSplit = Regex.Split(lineStr, ","); time = BarDataHelper.ParseCSVDateTime(lineSplit[1], lineSplit[2]); double [] prices = new double[] { Double.Parse(lineSplit[3]) }; rtd.symbol = (Symbol)Enum.Parse(typeof(Symbol), lineSplit[0]); rtd.dateTime = time; rtd.datas = prices; datas.Add(rtd); } } } catch (Exception exception) { Console.WriteLine(exception.ToString()); datas.Clear(); return(false); } } return(true); }
public void UpdateDataSource(RealTimeData rtd) { Symbol symbol = rtd.symbol; double[] prices = rtd.datas; DateTime time = rtd.dateTime; if (prices != null) { Dictionary <Interval, IntervalData> currentlData = currentDatas; lock (this) { foreach (Interval intv in AppSetting.INTEVALS) { IntervalData intvData; if (currentlData.ContainsKey(intv)) { intvData = currentlData[intv]; } else { intvData = new IntervalData(0); } UpdateIntervalData(intv, ref intvData, prices, time, provider); tmpIntervDatas[intv] = intvData; if (currentlData.ContainsKey(intv)) { currentlData[intv] = intvData; // tmpIntervDatas[intv]; } else { currentlData.Add(intv, intvData); } LogUtil.Info(" intvData " + intvData.ToString()); } } } }
public static void UpdateRealTimeListView(object obj) { if (obj != null) { RealTimeData rtd = (RealTimeData)obj; double oldPrice = 0, newPrice = 0; newPrice = rtd.datas[rtd.datas.Length - 1]; for (int i = 0; i < priceList.Items.Count; i++) { string strSymbol = priceList.Items[i].SubItems[0].Text; Symbol symbol = rtd.symbol; string cnSymbol = AppConst.AppCnSymbols[symbol]; if (cnSymbol != null && strSymbol != null && cnSymbol.Trim() == strSymbol.Trim()) { lock (AppConst.PriceListLocker) { string p = priceList.Items[i].SubItems[1].Text; oldPrice = !string.IsNullOrEmpty(p) ? Convert.ToDouble(p) : 0; //Console.WriteLine(" Symbol := " + strSymbol + " Time:= " + rtd.dateTime + " OldPrice := " + oldPrice + " NewPrice := " + newPrice); if ((oldPrice - newPrice) < zero) { priceList.Items[i].SubItems[1].Text = newPrice.ToString(); priceList.Items[i].SubItems[1].ForeColor = Color.Red; priceList.Items[i].ImageIndex = 0; } else if ((oldPrice - newPrice) > zero) { priceList.Items[i].SubItems[1].Text = newPrice.ToString(); priceList.Items[i].SubItems[1].ForeColor = Color.Green; priceList.Items[i].ImageIndex = 1; } //Console.WriteLine(" Symbol ==== " + symbol); break; } } } } }
public void UpdateDataProvider(RealTimeData rtd) { Console.WriteLine(" provider.IsPause >>>>>>>>>: " + provider.IsPause); //if(!provider.IsPause) provider.Process(null, null); }
public void UpdateDataSource(RealTimeData rtd) { Symbol symbol = rtd.symbol; double[] prices = rtd.datas; DateTime time = rtd.dateTime; if (prices != null) { Dictionary<Interval, IntervalData> currentlData = currentDatas; lock (this) { foreach (Interval intv in AppSetting.INTEVALS) { IntervalData intvData; if (currentlData.ContainsKey(intv)) intvData = currentlData[intv]; else intvData = new IntervalData(0); UpdateIntervalData(intv, ref intvData, prices, time, provider); tmpIntervDatas[intv] = intvData; if (currentlData.ContainsKey(intv)) currentlData[intv] = intvData; // tmpIntervDatas[intv]; else currentlData.Add(intv, intvData); LogUtil.Info(" intvData " + intvData.ToString()); } } } }
public void DataUpdate() { RealTimeData[] rtds; lock (realTimeDatas) { if (this.realTimeDatas.Count == 0) return; rtds = new RealTimeData[realTimeDatas.Count]; realTimeDatas.CopyTo(rtds); realTimeDatas.Clear(); } if (isInitialized) { foreach (RealTimeData rtd in rtds) { Console.WriteLine(" RTD " + rtd.symbol + " time " + rtd.dateTime + " price " + rtd.datas[0]); LogUtil.Info(" RTD " + rtd.ToString()); UpdateDataSource(rtd); UpdateDataProvider(rtd); } } }
public static List<RealTimeData> ParseRtdMsg(string realTimeMsg) { List<RealTimeData> list = new List<RealTimeData>(); try { string[] rmsgs = Regex.Split((string)realTimeMsg, @"\r\n", RegexOptions.IgnoreCase); foreach (string msg in rmsgs) { if (msg.Trim().Length > 0) { try { string[] msgs = msg.Split(','); //Symbol symbol = (Symbol)Enum.Parse(typeof(Symbol), msgs[0].Trim()); Symbol symbol = ParseSymbol(msgs[0].Trim()); if (symbol == Symbol.UNKNOWN) { Console.WriteLine(" UNKNOWN symbol " + msgs[0]); continue; } DateTime dateTime = BarDataHelper.ParseCSVDateTime(msgs[1].Trim(), msgs[2].Trim()); double[] datas = new double[msgs.Length - 3]; for (int i = 3; i < msgs.Length; i++) { if (msgs[i].Trim().Length > 0) datas[i - 3] = Double.Parse(msgs[i]); } RealTimeData realTimeData = new RealTimeData(symbol, dateTime, datas); list.Add(realTimeData); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); continue; } } } } catch (Exception e) { Console.WriteLine(e.StackTrace); } return list; }
public static void UpdateListView(DataChangedDelegate dataHandler, RealTimeData realTimeData) { dataHandler(realTimeData); }
public void CheckInitStatus(object obj, System.Timers.ElapsedEventArgs e) { if (!Initializing) { lock (this) { if (!Initialized && initCdlStatus == DataInitStatus.Initialized && initRtdStatus == DataInitStatus.Initialized && initSigStatus == DataInitStatus.Initialized ) { Initializing = true; if( handler !=null ) handler.IsProcessing = false; if (initRtdStatus == DataInitStatus.Initialized) { Console.WriteLine(" LatesRtds count ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; " + LatesRtds.Count); LogUtil.Info(" LatesRtds count ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; " + LatesRtds.Count); if (LatesRtds.Count > 0) { if (dataCache.DataUnits.ContainsKey(CurrentTInterval)) { dataCache.DataUnits[CurrentTInterval].AddRange(LatesRtds); } else { dataCache.DataUnits.Add(CurrentTInterval, LatesRtds); } Console.WriteLine(" dataCache.DataUnits[CurrentTInterval].Count ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; " + dataCache.DataUnits[CurrentTInterval].Count); LogUtil.Info(" dataCache.DataUnits[CurrentTInterval].Count ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; " + dataCache.DataUnits[CurrentTInterval].Count); } } RealTimeData[] rtds = null; lock (dataCache.RealTimeDatas) { if (dataCache.RealTimeDatas.Count > 0) { rtds = new RealTimeData[dataCache.RealTimeDatas.Count]; dataCache.RealTimeDatas.CopyTo(rtds); dataCache.RealTimeDatas.Clear(); } } if (dataCache.DataUnits[CurrentTInterval].Count > 0) { List<BarData> datas = dataCache.DataUnits[CurrentTInterval]; BarData lastBar = dataCache.DataUnits[CurrentTInterval][datas.Count - 1]; dataCache.RefreshCurrentTime(currentTInterval, lastBar.DateTime); IntervalData data = new IntervalData(lastBar.Open, lastBar.Close, lastBar.Low, lastBar.High); dataCache.InitCurrentData(currentTInterval, data); Console.WriteLine(" Last BAR ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; " + lastBar ); LogUtil.Info(" Last BAR ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; " + lastBar); if (rtds != null && rtds.Length > 0) { Console.WriteLine(" dataCache.RealTimeDatas. count ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; " + rtds.Length); LogUtil.Info(" dataCache.RealTimeDatas. count ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; " + rtds.Length); Console.WriteLine(lastBar); if (lastBar.IsCompleted) { foreach (RealTimeData rtd in rtds) { dataCache.UpdateDataSource(rtd); } } else { bool isCompleted = false; double max = lastBar.High; double min = lastBar.Low; List<double> prices = new List<double>(); prices.Add(lastBar.Open); prices.Add(lastBar.Close); prices.Add(lastBar.Low); prices.Add(lastBar.High); for (int k = 0; k < rtds.Length; k++) { RealTimeData rtd = rtds[k]; Console.WriteLine(" RealTimeData ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; " + rtd); LogUtil.Info(" RealTimeData ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; " + rtd); if (rtd.dateTime.CompareTo(lastBar.DateTime) < 0) continue; if (rtd.dateTime.Subtract(AppConst.AppTimeSpans[CurrentTInterval]) < lastBar.DateTime) { foreach (double price in rtd.datas) { prices.Add(price); max = Math.Max(max, price); min = Math.Min(min, price); } if (k == rtds.Length - 1 && prices.Count > 0) { lastBar.Close = prices[prices.Count - 1]; lastBar.High = max; lastBar.Low = min; IntervalData newdata = new IntervalData(lastBar.Open, lastBar.Close, lastBar.Low, lastBar.High); dataCache.InitCurrentData(currentTInterval, newdata); dataCache.DataUnits[CurrentTInterval][datas.Count - 1] = lastBar; } } else if (rtd.dateTime.Subtract(AppConst.AppTimeSpans[CurrentTInterval]) >= lastBar.DateTime) { if (!isCompleted) { if (prices != null && prices.Count > 0) { lastBar.Close = prices[prices.Count - 1]; lastBar.High = max; lastBar.Low = min; prices.Clear(); } lastBar.IsCompleted = true; dataCache.DataUnits[CurrentTInterval][datas.Count - 1] = lastBar; IntervalData newdata = new IntervalData(lastBar.Open, lastBar.Close, lastBar.Low, lastBar.High); dataCache.InitCurrentData(currentTInterval, newdata); isCompleted = true; dataCache.UpdateDataSource(rtd); } else { dataCache.UpdateDataSource(rtd); } } } } } SAR sar = new SAR(symbol.ToString(), currentTInterval); RSI rsi = new RSI(symbol.ToString(), int.Parse(AppUtil.IntervalToString(currentTInterval)),6); RSI rsi2 = new RSI(symbol.ToString(), int.Parse(AppUtil.IntervalToString(currentTInterval)),42); RSI rsi3 = new RSI(symbol.ToString(), int.Parse(AppUtil.IntervalToString(currentTInterval)),14); RSI rsi4 = new RSI(symbol.ToString(), int.Parse(AppUtil.IntervalToString(currentTInterval)),22); CR cr = new CR(symbol.ToString(), int.Parse(AppUtil.IntervalToString(currentTInterval))); ARBR arbr = new ARBR(symbol.ToString(), int.Parse(AppUtil.IntervalToString(currentTInterval)), 26); ARBR arbr2 = new ARBR(symbol.ToString(), int.Parse(AppUtil.IntervalToString(currentTInterval)),42); CCI cci = new CCI(symbol.ToString(), int.Parse(AppUtil.IntervalToString(currentTInterval)), 14); //CCI cci2 = new CCI(symbol.ToString(), int.Parse(AppUtil.IntervalToString(currentTInterval)), 42); CCI cci2 = new CCI(symbol.ToString(), int.Parse(AppUtil.IntervalToString(currentTInterval)), 24); CCI cci3 = new CCI(symbol.ToString(), int.Parse(AppUtil.IntervalToString(currentTInterval)), 42); WR wr=new WR(symbol.ToString(), int.Parse(AppUtil.IntervalToString(currentTInterval)),14); WR wr2 = new WR(symbol.ToString(), int.Parse(AppUtil.IntervalToString(currentTInterval)), 24); LWR lwr=new LWR(symbol.ToString(), int.Parse(AppUtil.IntervalToString(currentTInterval)), 14, 3, 3); BOLL boll = new BOLL(symbol.ToString(), int.Parse(AppUtil.IntervalToString(currentTInterval)), 20); for (int i = 0; i < datas.Count; i++) { BarData bar = datas[i]; if (bar.IsCompleted) { sar.handleFullCandle(ref bar); rsi.handleFullCandle(ref bar, true, 1); rsi2.handleFullCandle(ref bar, true,2); rsi3.handleFullCandle(ref bar, true,3); rsi4.handleFullCandle(ref bar, true,4); cr.handleFullCandle(ref bar); arbr.handleFullCandle(ref bar, 1); arbr2.handleFullCandle(ref bar,2); cci.handleFullCandle(ref bar,1); cci2.handleFullCandle(ref bar,2); cci3.handleFullCandle(ref bar, 3); wr.handleFullCandle(ref bar, 1); wr2.handleFullCandle(ref bar,2); lwr.handleFullCandle(ref bar, 0); boll.handleFullCandle(ref bar, 0); datas[i] = bar; } } dataCache.SARs[currentTInterval] = sar; dataCache.RISs[currentTInterval] = rsi; dataCache.RISs2[currentTInterval] = rsi2; dataCache.RISs3[currentTInterval] = rsi3; dataCache.RISs4[currentTInterval] = rsi4; dataCache.CRs[currentTInterval] = cr; dataCache.ARBRs[currentTInterval] = arbr; dataCache.ARBRs2[currentTInterval] = arbr2; dataCache.CCIs[currentTInterval] = cci; dataCache.CCIs2[currentTInterval] = cci2; dataCache.CCIs3[currentTInterval] = cci3; dataCache.WRs[currentTInterval] = wr; dataCache.WRs2[currentTInterval] = wr2; dataCache.LWRs[currentTInterval] = lwr; dataCache.BOLLs[currentTInterval] = boll; List<Signal> signalList = dataCache.SignalUnits[currentTInterval]; LogUtil.Info(" SignalList count ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; " + signalList.Count); if (signalList.Count > 0) { Signal[] signals = new Signal[signalList.Count]; signalList.CopyTo(signals, 0); Array.Sort(signals); Array.Reverse(signals); DateTime currentTime = dataCache.CurrentTimes[currentTInterval]; int startIndex = 0; foreach (Signal signal in signals) { DateTime actTime = signal.ActTime; for (int i = startIndex; i < dataCache.DataUnits[currentTInterval].Count; i++) { bool isUpdate = false; List<CandleSignal> sigList = new List<CandleSignal>(); BarData candle = dataCache.DataUnits[currentTInterval][i]; if (actTime.CompareTo(candle.DateTime) > 0) { continue; } else if (actTime.CompareTo(candle.DateTime) == 0) { startIndex = i; isUpdate = true; LogUtil.Info(" Signal " + signal ); LogUtil.Info(" Candle " + candle); // LogUtil.Info(" bf1st " + dataCache.DataUnits[currentTInterval][i-1]); //LogUtil.Info(" bf2nd " + dataCache.DataUnits[currentTInterval][i-2]); CandleSignal cs = new CandleSignal(signal, 1); sigList.Add(cs); } if (signal.GainTip!=0 && signal.GainTipPrice > 0 && candle.DateTime.CompareTo(signal.GainTipTime) == 0) { CandleSignal cs = new CandleSignal(signal, 2); sigList.Add(cs); isUpdate = true; } if (signal.StopLoss != 0 && signal.StopLossBidPrice > 0 && candle.DateTime.CompareTo(signal.StopLossTime) == 0) { CandleSignal cs = new CandleSignal(signal, 3); sigList.Add(cs); isUpdate = true; } if (signal.StopGain != 0 && signal.StopGainPrice > 0 && candle.DateTime.CompareTo(signal.StopGainTime) == 0) { CandleSignal cs = new CandleSignal(signal, 4); sigList.Add(cs); isUpdate = true; } if (isUpdate) { if (candle.SignalList != null) candle.SignalList.AddRange(sigList); else candle.SignalList = sigList; candle.RefreshExValues(); dataCache.DataUnits[currentTInterval][i] = candle; } } List<CandleSignal> sList = new List<CandleSignal>(); if (signal.ActTime.CompareTo(currentTime) <= 0) { if (signal.ActTime.CompareTo(currentTime) == 0) { CandleSignal cs = new CandleSignal(signal, 1); sList.Add(cs); } if (signal.GainTipPrice > 0 && signal.GainTipTime.CompareTo(currentTime) == 0) { CandleSignal cs = new CandleSignal(signal, 2); sList.Add(cs); } if (signal.StopLossBidPrice > 0 && signal.StopLossTime.CompareTo(currentTime) == 0) { CandleSignal cs = new CandleSignal(signal, 3); sList.Add(cs); } if (signal.StopGainPrice > 0 && signal.StopGainTime.CompareTo(currentTime) == 0) { CandleSignal cs = new CandleSignal(signal, 4); sList.Add(cs); } dataCache.CurrentDatas[currentTInterval].SignalList.AddRange(sList); } } } Console.WriteLine(" LAST ###### "+lastBar); LogUtil.Info(" LAST ###### " + lastBar); dataCache.RefreshDataUnits(datas); } //dataCache.Start(); if (AppContext.IsLoading) { AppContext.IsFirstProviderInit = true; isAddCandle = true; Initialized = true; Initializing = false; ProviderHelper.CleanInitDirs(this); } else { isAddCandle = true; Initialized = true; Process(null, null); timerInit.Stop(); timerAuto.Start(); Initializing = false; ProviderHelper.CleanInitDirs(this); Console.WriteLine(" End Now ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; " + DateTime.Now.ToLongTimeString()); } } } } }
public void SignalUpdate(Dictionary<Protocol, Signal> protocolSignal) { isUpdateSignal = false; isUpdateCandleSignal = false; Protocol protocol = protocolSignal.Keys.First(); Signal signal = (Signal)protocolSignal.Values.First(); Console.WriteLine(" signal " + signal); LogUtil.Info(" signal " + signal); if (dataCache.DataUnits.ContainsKey(currentTInterval)) { lock (dataCache.DataUnits[currentTInterval]) { if (timerAuto != null) { timerAuto.Stop(); } for (int i = dataCache.DataUnits[currentTInterval].Count - 1; i >= 0; i--) { BarData data = dataCache.DataUnits[currentTInterval][i]; if (data.SignalList == null) data.SignalList = new List<CandleSignal>(); if (protocol==Protocol.K0004_1 && signal.Arrow != 0 && data.DateTime.CompareTo(signal.ActTime) == 0) { isUpdateCandleSignal = true; CandleSignal cs = new CandleSignal(signal, 1); data.SignalList.Add(cs); dataCache.DataUnits[currentTInterval][i] = data; break; } if (protocol == Protocol.K0004_3 && signal.GainTip != 0 && data.DateTime.CompareTo(signal.GainTipTime) == 0) { isUpdateCandleSignal = true; CandleSignal cs = new CandleSignal(signal, 2); data.SignalList.Add(cs); dataCache.DataUnits[currentTInterval][i] = data; break; } if (protocol == Protocol.K0004_2 && signal.StopLoss != 0 && data.DateTime.CompareTo(signal.StopLossTime) == 0) { isUpdateCandleSignal = true; CandleSignal cs = new CandleSignal(signal, 3); data.SignalList.Add(cs); dataCache.DataUnits[currentTInterval][i] = data; break; } if (protocol == Protocol.K0004_4 && signal.StopGain != 0 && data.DateTime.CompareTo(signal.StopGainTime) == 0) { isUpdateCandleSignal = true; CandleSignal cs = new CandleSignal(signal, 4); data.SignalList.Add(cs); dataCache.DataUnits[currentTInterval][i] = data; break; } if (data.DateTime.CompareTo(signal.ActTime) < 0) { break; } } } } if (isUpdateCandleSignal) { Process(null, null); } else { RealTimeData rtd = new RealTimeData(); rtd.symbol = symbol; if (protocol == Protocol.K0004_1) { rtd.dateTime = signal.ActTime; rtd.datas = new double[] { signal.ActPrice }; } else if (protocol == Protocol.K0004_2) { rtd.dateTime = signal.StopLossTime; rtd.datas = new double[] { signal.StopLossBidPrice }; } else if (protocol == Protocol.K0004_3) { rtd.dateTime = signal.GainTipTime; rtd.datas = new double[] { signal.GainTipPrice }; } else if (protocol == Protocol.K0004_4) { rtd.dateTime = signal.StopGainTime; rtd.datas = new double[] { signal.StopGainPrice }; } dataCache.UpdateDataSource(rtd); isUpdateCandleSignal = true; } LogUtil.Info(" dataCache.CurrentTimes[currentTInterval] " + dataCache.CurrentTimes[currentTInterval]); if (dataCache.CurrentTimes[currentTInterval].CompareTo(signal.ActTime) == 0) { lock (dataCache.CurrentDatas[currentTInterval]) { if (protocol == Protocol.K0004_1 && signal.Arrow != 0) { CandleSignal cs = new CandleSignal(signal, 1); if (!dataCache.CurrentDatas[currentTInterval].SignalList.Contains(cs)) dataCache.CurrentDatas[currentTInterval].SignalList.Add(cs); isUpdateSignal = true; } } } if (dataCache.CurrentTimes[currentTInterval].CompareTo(signal.GainTipTime) == 0) { lock ( dataCache.CurrentDatas[currentTInterval]) { if (protocol == Protocol.K0004_3 && signal.GainTip != 0) { CandleSignal cs = new CandleSignal(signal, 2); if (!dataCache.CurrentDatas[currentTInterval].SignalList.Contains(cs)) dataCache.CurrentDatas[currentTInterval].SignalList.Add(cs); isUpdateSignal = true; } } } if (dataCache.CurrentTimes[currentTInterval].CompareTo(signal.StopLossTime) == 0) { lock (dataCache.CurrentDatas[currentTInterval]) { if (protocol == Protocol.K0004_2 && signal.StopLoss != 0) { CandleSignal cs = new CandleSignal(signal, 3); if (!dataCache.CurrentDatas[currentTInterval].SignalList.Contains(cs)) dataCache.CurrentDatas[currentTInterval].SignalList.Add(cs); isUpdateSignal = true; } } } if (dataCache.CurrentTimes[currentTInterval].CompareTo(signal.StopGainTime) == 0) { lock (dataCache.CurrentDatas[currentTInterval]) { if (protocol==Protocol.K0004_1 &&signal.StopGain != 0) { CandleSignal cs = new CandleSignal(signal, 4); if (!dataCache.CurrentDatas[currentTInterval].SignalList.Contains(cs)) dataCache.CurrentDatas[currentTInterval].SignalList.Add(cs); isUpdateSignal = true; } } } LogUtil.Info(" isUpdateSignal " + isUpdateSignal); if (isUpdateSignal || isUpdateCandleSignal) { AppContext.TradeAnalyzerControl.AddSignalSymbol(signal.Symbol); AppContext.TradeAnalyzerControl.ActiveTimer(); if (AppContext.IsOpenSpeaker) { System.Media.SoundPlayer player = new SoundPlayer(Properties.Resources.chimes); player.LoadAsync(); player.Play(); } } Process(null, null); isUpdateSignal = false; isUpdateCandleSignal = false; if (timerAuto != null) { timerAuto.Start(); } }
public bool LoadFile(string fileName, int startingRow, int rowsLimit, out List<RealTimeData> datas, bool isDecrypt) { datas = new List<RealTimeData>(); int i = 0; using (System.IO.TextReader tr = new System.IO.StreamReader(fileName)) { try { DateTime time = new DateTime(); RealTimeData rtd = new RealTimeData(); for (i = 0; i < startingRow + rowsLimit || rowsLimit == 0; i++) { string lineStr = tr.ReadLine(); if (lineStr == null) { break; } if (i >= startingRow) {// Parse. //if (isDecrypt) //{ // lineStr = crypta.decrypt(lineStr); //} string[] lineSplit = Regex.Split(lineStr, ","); time = BarDataHelper.ParseCSVDateTime(lineSplit[1], lineSplit[2]); double [] prices= new double[]{ Double.Parse(lineSplit[3]) }; rtd.symbol = (Symbol)Enum.Parse(typeof(Symbol), lineSplit[0]); rtd.dateTime = time; rtd.datas = prices; datas.Add(rtd); } } } catch (Exception exception) { Console.WriteLine(exception.ToString()); datas.Clear(); return false; } } return true; }