コード例 #1
0
ファイル: dataClass.cs プロジェクト: oghenez/trade-software
        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);
        }
コード例 #2
0
ファイル: dataClass.cs プロジェクト: oghenez/trade-software
        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);
        }
コード例 #3
0
ファイル: dataClass.cs プロジェクト: oghenez/trade-software
 //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));
 }
コード例 #4
0
ファイル: dataClass.cs プロジェクト: oghenez/trade-software
            //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));
            }
コード例 #5
0
ファイル: dataClass.cs プロジェクト: oghenez/trade-software
        /// <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;
        }
コード例 #6
0
ファイル: dataLibs.cs プロジェクト: oghenez/trade-software
        //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);
        }
コード例 #7
0
ファイル: dataLibs.cs プロジェクト: oghenez/trade-software
        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);
        }
コード例 #8
0
        /// <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;
        }
コード例 #9
0
ファイル: dataLibs.cs プロジェクト: oghenez/trade-software
 public static void ClearAnalysisDataCache(commonClass.BaseAnalysisData dataObj)
 {
     cacheData.Remove(MakeAnalysisDataCacheKey(dataObj));
 }
コード例 #10
0
ファイル: dataLibs.cs プロジェクト: oghenez/trade-software
 private static string MakeAnalysisDataCacheKey(commonClass.BaseAnalysisData dataObj)
 {
     return("AnalysisData" + "-" + dataObj.DataStockCode + "-" + dataObj.DataTimeRange.ToString() + "-" +
            dataObj.DataTimeScale.Code);
 }
コード例 #11
0
ファイル: dataClass.cs プロジェクト: oghenez/trade-software
            //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);
            }
コード例 #12
0
ファイル: dataClass.cs プロジェクト: oghenez/trade-software
 //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);
 }