public MarketData(commonClass.BaseAnalysisData data) { DateTime startDate = DateTime.Today, endDate = DateTime.Today; AppTypes.GetDate(data.DataTimeRange, out startDate, out endDate); this.Init(startDate, endDate, data.DataTimeScale, null); }
public MarketData(commonClass.BaseAnalysisData data, StringCollection stockCodes) { DateTime startDate = DateTime.Today, endDate = DateTime.Today; AppTypes.GetDate(data.DataTimeRange, out startDate, out endDate); this.Init(startDate, endDate, data.DataTimeScale, stockCodes); }
//Create from analysis data for all enable stocks private MarketData Create1() { commonClass.BaseAnalysisData stockData = new commonClass.BaseAnalysisData(commonClass.AppTypes.TimeRanges.Y1, commonClass.AppTypes.TimeScaleFromCode("D1"), "SSI", DataAccessMode.WebService); return(new MarketData(stockData)); }
//Create from analysis data for stocks : ACB, FPT private MarketData Create2() { StringCollection list = new StringCollection(); list.AddRange(new string[] { "ACB", "FPT" }); commonClass.BaseAnalysisData stockData = new commonClass.BaseAnalysisData(commonClass.AppTypes.TimeRanges.Y1, commonClass.AppTypes.TimeScaleFromCode("D1"), "SSI", DataAccessMode.WebService); return(new MarketData(stockData)); }
/// <summary> /// Make 2 data the same lenght and DateTime Index /// </summary> /// <param name="ds"> Changed data that will be the same lenght and date tme index) with this data</param> /// <returns></returns> public void Sync(BaseAnalysisData checkData) { int tmpIdx; double[] newClose = new double[this.DateTime.Count]; double[] newOpen = new double[this.DateTime.Count]; double[] newHigh = new double[this.DateTime.Count]; double[] newLow = new double[this.DateTime.Count]; double[] newVolume = new double[this.DateTime.Count]; double[] newDateTime = new double[this.DateTime.Count]; for (int idx = 0; idx < this.DateTime.Count; idx++) { tmpIdx = checkData.FindDate(this.DateTime[idx], idx); if (tmpIdx < 0) { newClose[idx] = 0; newOpen[idx] = 0; newHigh[idx] = 0; newLow[idx] = 0; newVolume[idx] = 0; newDateTime[idx] = this.DateTime[idx]; } else { newClose[idx] = checkData.Close[tmpIdx]; newOpen[idx] = checkData.Open[tmpIdx]; newHigh[idx] = checkData.High[tmpIdx]; newLow[idx] = checkData.Low[tmpIdx]; newVolume[idx] = checkData.Volume[tmpIdx]; newDateTime[idx] = checkData.DateTime[tmpIdx]; } } checkData.Close.Values = newClose; checkData.Open.Values = newOpen; checkData.High.Values = newHigh; checkData.Low.Values = newLow; checkData.Volume.Values = newVolume; checkData.DateTime.Values = newDateTime; checkData.Bars.Close.Values = newClose; checkData.Bars.Open.Values = newOpen; checkData.Bars.High.Values = newHigh; checkData.Bars.Low.Values = newLow; checkData.Bars.Volume.Values = newVolume; }
//Updated data from the last read/update point public static int UpdateAnalysisData(commonClass.BaseAnalysisData dataObj) { int lastDataIdx = dataObj.priceDataTbl.Count - 1; DateTime lastDateTime; if (lastDataIdx < 0) { lastDateTime = commonClass.Settings.sysStartDataDate; } else { lastDateTime = dataObj.priceDataTbl[lastDataIdx].onDate; } data.baseDS.priceDataDataTable tbl = GetData_ByTimeScale_Code_FrDate(dataObj.DataTimeScale.Code, dataObj.DataStockCode, lastDateTime); if (tbl.Count > 0) { //Delete the last data because the updated data will include this one. if (lastDataIdx >= 0) { dataObj.priceDataTbl[lastDataIdx].ItemArray = tbl[0].ItemArray; commonClass.AppLibs.DataConcat(tbl, 1, dataObj.priceDataTbl); } else { commonClass.AppLibs.DataConcat(tbl, 0, dataObj.priceDataTbl); } } //Update cache AnalysisDataCache data = new AnalysisDataCache(); data.dataTbl = (data.baseDS.priceDataDataTable)dataObj.priceDataTbl.Copy(); data.firstData = dataObj.FirstDataStartAt; AddCache(MakeAnalysisDataCacheKey(dataObj), data); return(dataObj.priceDataTbl.Count - 1 - lastDataIdx); }
public static bool LoadAnalysisData(commonClass.BaseAnalysisData dataObj) { AnalysisDataCache data; string cacheKey = MakeAnalysisDataCacheKey(dataObj); object obj = GetCache(cacheKey); if (obj != null) { data = (AnalysisDataCache)obj; dataObj.priceDataTbl = (data.baseDS.priceDataDataTable)data.dataTbl.Copy(); return(true); } using (new PleaseWait()) { data = new AnalysisDataCache(); int firstData = 0; data.dataTbl = myClient.GetAnalysis_Data(out firstData, dataObj.DataTimeRange, dataObj.DataTimeScale.Code, dataObj.DataStockCode); data.firstData = firstData; AddCache(cacheKey, data); dataObj.priceDataTbl = (data.baseDS.priceDataDataTable)data.dataTbl.Copy(); dataObj.FirstDataStartAt = firstData; } return(true); }
public static void ClearAnalysisDataCache(commonClass.BaseAnalysisData dataObj) { cacheData.Remove(MakeAnalysisDataCacheKey(dataObj)); }
private static string MakeAnalysisDataCacheKey(commonClass.BaseAnalysisData dataObj) { return("AnalysisData" + "-" + dataObj.DataStockCode + "-" + dataObj.DataTimeRange.ToString() + "-" + dataObj.DataTimeScale.Code); }
//Create from analysis data for stocks : ACB, FPT private MarketData Create2() { StringCollection list = new StringCollection(); list.AddRange(new string[] { "ACB", "FPT" }); commonClass.BaseAnalysisData stockData = new commonClass.BaseAnalysisData(commonClass.AppTypes.TimeRanges.Y1, commonClass.AppTypes.TimeScaleFromCode("D1"), "SSI", DataAccessMode.WebService); return new MarketData(stockData); }
//Create from analysis data for all enable stocks private MarketData Create1() { commonClass.BaseAnalysisData stockData = new commonClass.BaseAnalysisData(commonClass.AppTypes.TimeRanges.Y1, commonClass.AppTypes.TimeScaleFromCode("D1"), "SSI", DataAccessMode.WebService); return new MarketData(stockData); }