//设置缓存数据对象
        public virtual bool SetData(Data_Quote pData, typeTimeFrequency timeFrequency)
        {
            StockInfo stockInfo = pData.GetStockInfo();

            if (stockInfo == null)
            {
                return(false);
            }

            //默认只设置最底级数据,
            bool   bResult = true;
            string exType  = stockInfo.StockExchange.ToString();

            //Data_Quote dataCheck = this.SetData_ValueCheck(stockInfo, pData, timeFrequency);
            if (pData != null)
            {
                bResult = bResult && _managerCaches.SetData <Data_Quote>(exType, stockInfo.StockID_Tag, "", pData.DateTime, pData, timeFrequency);
            }
            //foreach (var item in _setsDataCache)
            //{
            //    Data_Quote dataCheck = this.SetDataCache_ValueCheck(pData, item.Key);
            //    if (dataCheck != null)
            //    {
            //        bResult = bResult && _managerCaches.SetData<Data_Quote>(exType, stockInfo.StockID_Tag, "", dataCheck.DateTime, dataCheck, item.Key);
            //    }
            //}
            return(bResult);
        }
Beispiel #2
0
 public bool InitTime(DateTime dtBase, typeTimeFrequency typeTimeFrequency)
 {
     _dtEnd   = CheckTime(dtBase);;
     _dtStart = _dtEnd.AddSeconds(-_dtStep * (_sumStep - 1));
     _indStep = this.GetInd(_dtEnd);
     return(true);
 }
 protected internal Dictionary <string, DataTrend_KeyLine> _dataKeyLines = null;      //关键点位线集
 public DataAnalyse_Trend(string tag = "", typeTimeFrequency valueTimeType = typeTimeFrequency.none)
 {
     _tag                  = string.IsNullOrEmpty(tag) ? "DataAnalyse_Trend" : tag;
     _ValueTimeType        = valueTimeType;
     this._dataIndexCaches = new List <DataTrend_Index>();
     this._dataKeyLines    = new Dictionary <string, DataTrend_KeyLine>();
 }
Beispiel #4
0
        public string GetTagName(typeTimeFrequency typeTimeFrequency, string strTag = "")
        {
            _tagName = strTag;
            string tag = _Info_Factor.ID + "_" + typeTimeFrequency + (_tagName == "" ? "" : "_" + _tagName);

            return(tag);
        }
Beispiel #5
0
 public DataCache(string tagName, typeTimeFrequency typeTimeFrequency, int cacheNums, IDataCache_Set srcDataCache_Set)
 {
     _DataCaches    = new List <T>();
     _DataCache_Set = new DataCache_Set(tagName, srcDataCache_Set.Time_Base, typeTimeFrequency, cacheNums, srcDataCache_Set.Info_Factor);
     _id            = _DataCache_Set.ID;
     this.Init(DateTime.Now);
 }
Beispiel #6
0
        /// <summary>提取数据日志信息对象
        /// </summary>
        /// <param name="stockID_Tag">标的标签</param>
        /// <param name="quoteTimeType">时间频率类型</param>
        /// <param name="quotePlat">行情来源平台</param>
        /// <param name="autoInit">自动初始</param>
        /// <returns></returns>
        public virtual T Get_LogQuote(string stockID_Tag, typeTimeFrequency quoteTimeType, typeQuotePlat quotePlat = typeQuotePlat.JQDataAPI_zxc, bool autoInit = true)
        {
            //查询
            List <T> lstLogs = this.FindAll(e => e.StockID_Tag == stockID_Tag && e.QuoteTimeType == quoteTimeType && e.QuotePlat == quotePlat);

            if (lstLogs.Count != 1)
            {
                if (!autoInit)
                {
                    return(default(T));
                }

                //初始新对象
                T pLog = (T) new LogData_Quote()
                {
                    StockID_Tag   = stockID_Tag,
                    QuoteTimeType = quoteTimeType,
                    QuotePlat     = quotePlat,
                    DateTime_Min  = DateTime.Now,
                    DateTime_Max  = DateTime.Now
                };
                this.Add(pLog);     //添加记录
                return(pLog);
            }
            return(lstLogs[0]);
        }
Beispiel #7
0
        //对象转换-由json对象
        public override bool FromJsonObj(JObject jsonData, typeTimeFrequency quoteTime)
        {
            if (base.FromJsonObj(jsonData, quoteTime))
            {
                this.Volume_Buy1 = (int)zxcTransHelper.ToDouble(jsonData["buy1Volume"]);
                this.Price_Buy1  = zxcTransHelper.ToDouble(jsonData["buy1Price"]) * _valueTimes;
                this.Volume_Buy2 = (int)zxcTransHelper.ToDouble(jsonData["buy2Volume"]);
                this.Price_Buy2  = zxcTransHelper.ToDouble(jsonData["buy2Price"]) * _valueTimes;
                this.Volume_Buy3 = (int)zxcTransHelper.ToDouble(jsonData["buy3Volume"]);
                this.Price_Buy3  = zxcTransHelper.ToDouble(jsonData["buy3Price"]) * _valueTimes;
                this.Volume_Buy4 = (int)zxcTransHelper.ToDouble(jsonData["buy4Volume"]);
                this.Price_Buy4  = zxcTransHelper.ToDouble(jsonData["buy4Price"]) * _valueTimes;
                this.Volume_Buy5 = (int)zxcTransHelper.ToDouble(jsonData["buy5Volume"]);
                this.Price_Buy5  = zxcTransHelper.ToDouble(jsonData["buy5Price"]) * _valueTimes;

                this.Volume_Sell1 = (int)zxcTransHelper.ToDouble(jsonData["sell1Volume"]);
                this.Price_Sell1  = zxcTransHelper.ToDouble(jsonData["sell1Price"]) * _valueTimes;
                this.Volume_Sell2 = (int)zxcTransHelper.ToDouble(jsonData["sell2Volume"]);
                this.Price_Sell2  = zxcTransHelper.ToDouble(jsonData["sell2Price"]) * _valueTimes;
                this.Volume_Sell3 = (int)zxcTransHelper.ToDouble(jsonData["sell3Volume"]);
                this.Price_Sell3  = zxcTransHelper.ToDouble(jsonData["sell3Price"]) * _valueTimes;
                this.Volume_Sell4 = (int)zxcTransHelper.ToDouble(jsonData["sell4Volume"]);
                this.Price_Sell4  = zxcTransHelper.ToDouble(jsonData["sell4Price"]) * _valueTimes;
                this.Volume_Sell5 = (int)zxcTransHelper.ToDouble(jsonData["sell5Volume"]);
                this.Price_Sell5  = zxcTransHelper.ToDouble(jsonData["sell5Price"]);
                this.DateTime     = Convert.ToDateTime(jsonData["datetime"]);
                return(true);
            }
            return(false);
        }
Beispiel #8
0
        /// <summary>查询行情(历史)
        /// </summary>
        /// <param name="startTime">开始时间</param>
        /// <param name="endTime">结束时间</param>
        /// <param name="quoteTime">行情时间类型</param>
        /// <param name="autoUpdate">是否自动更新本地库表</param>
        /// <returns></returns>
        public List <Data_Quote> Query(DateTime startTime, DateTime endTime, typeTimeFrequency quoteTime = typeTimeFrequency.day, bool autoUpdate = true)
        {
            //修正时间
            if (endTime == DateTime.MinValue)
            {
                endTime = DateTime.Now;
            }
            if (startTime == DateTime.MinValue)
            {
                return(Query(endTime, 1, quoteTime, autoUpdate));
            }

            //自动更新修正数据
            if (autoUpdate)
            {
                if (!this.Query_Check(startTime, endTime, 0, quoteTime, true))
                {
                    return(null);
                }
            }


            //查询库表
            List <Data_Quote> lstQuote = _dtQuote.FindAll(e => e.DateTime <= endTime && e.DateTime >= startTime && e.QuoteTimeType == quoteTime && e.IsDel == false).OrderBy(t => t.DateTime).ToList();

            return(lstQuote);
        }
Beispiel #9
0
        //设置正数据对象-修正为同时间频率数据
        public virtual bool SetData(CacheInfo <Data_Quote> pCacheInfo, typeTimeFrequency timeFrequency, typeTimeFrequency timeFrequency2)
        {
            Data_Quote pData = pCacheInfo.Data;

            if (pData == null)
            {
                return(false);
            }
            StockInfo pStockInfo = pData.GetStockInfo();

            if (pStockInfo == null)
            {
                return(false);
            }

            //获取当前时间频率数据
            DateTime   dtEnd    = zxcTimeHelper.CheckTime(pData.DateTime, typeTimeFrequency.m1, true);
            Data_Quote pDataNew = QuoteQuery._Query.Query(pStockInfo, pData.DateTime, timeFrequency, null);

            if (pDataNew == null)
            {
                return(false);
            }
            bool bResult = this.SetData(pDataNew, timeFrequency);

            return(bResult);


            //非时间频率数据,重新修正
            if (pData.QuoteTimeType != timeFrequency)
            {
                string        exType   = pStockInfo.StockExchange.ToString();
                IData_Factors pFactors = _managerCaches._GetFactors(exType);
                if (pFactors != null)
                {
                    IData_Factor           pFactor    = pFactors.GetData_Factor(pStockInfo.StockID_Tag);
                    DataCache <Data_Quote> pDataCache = (DataCache <Data_Quote>)_managerCaches.GetDataCache <Data_Quote>(pFactors, pFactor, "", timeFrequency);

                    //查询最后有效步长数据总数
                    int nCount = pDataCache.DataCaches.Values.Count(e => e.Data.IsDel == true);

                    //获取最数据
                    List <Data_Quote> lstQuotes = QuoteQuery._Query.Query(pStockInfo.StockID_Tag, pDataNew.DateTime, nCount, timeFrequency, true);
                    if (lstQuotes != null)
                    {
                        foreach (var item in lstQuotes)
                        {
                            int nSum = pDataCache.DataCaches.Values.Count(e => e.DateTime == item.DateTime && e.Data.IsDel != true);
                            if (nSum == 0)
                            {
                                item.SetStockInfo(pStockInfo);
                                bResult = bResult && this.SetData(item, timeFrequency);
                            }
                        }
                    }
                }
            }
            return(bResult);
        }
Beispiel #10
0
        //List<T> _DataCaches = null;
        //public List<T> DataCaches
        //{
        //    get { return _DataCaches; }
        //}

        public DataCache(string tagName, typeTimeFrequency typeTimeFrequency, int cacheNums, IDataCache_Set srcDataCache_Set, IDataChecks dataChecks = null)
        {
            _DataCaches    = new Dictionary <DateTime, T>();
            _DataCache_Set = new DataCache_Set(tagName, srcDataCache_Set.Time_Base, typeTimeFrequency, cacheNums, srcDataCache_Set.Info_Factor, srcDataCache_Set);
            _id            = _DataCache_Set.ID;
            _DataChecks    = dataChecks;
            this.Init(DateTime.Now);
        }
Beispiel #11
0
        /// <summary>转换json行情数据为行情对象集
        /// </summary>
        /// <param name="jsonRes">json行情数据对象</param>
        /// <returns></returns>
        protected internal List <Data_Quote> TransTo_Data_Quotes(JObject jsonRes, typeTimeFrequency quoteTime, StockInfo pStockInfo = null)
        {
            //数据检查
            if (jsonRes == null)
            {
                return(null);
            }
            if (jsonRes["result"].ToString() == "False")
            {
                return(null);
            }

            //循环解析文件json数据
            List <Data_Quote> lstDataQuote = new List <Data_Quote>();
            JArray            jsonDatas    = (JArray)jsonRes["datas"];

            if (jsonDatas != null)
            {
                //循环生成数据对象
                string platSrc = jsonRes["datasPlat"] + "";
                foreach (var jsonData in jsonDatas)
                {
                    Data_Quote pDataQuote = null;
                    switch (quoteTime)
                    {
                    case typeTimeFrequency.none:
                        break;

                    case typeTimeFrequency.real:
                        pDataQuote = new Data_Quote_Realtime_5Stalls(pStockInfo);
                        break;

                    default:
                        pDataQuote = new Data_Quote(pStockInfo);
                        break;
                    }
                    if (pDataQuote == null)
                    {
                        continue;
                    }

                    //转换为行情数据对象
                    //if (platSrc == typeQuotePlat.JQDataAPI_zxc.ToString())
                    //{
                    //    pDataQuote = JsonConvert.DeserializeObject<Data_Quote_Info>(JsonConvert.SerializeObject(jsonData));
                    //    pDataQuote.QuoteTimeType = quoteTime;
                    //    lstDataQuote.Add(pDataQuote);
                    //}
                    if (pDataQuote.FromJson(jsonData))
                    {
                        pDataQuote.QuoteTimeType = quoteTime;
                        pDataQuote.Check_DateTime();
                        lstDataQuote.Add(pDataQuote);
                    }
                }
            }
            return(lstDataQuote);
        }
Beispiel #12
0
 //对象转换-由json对象
 public override bool FromJsonObj(JObject jsonData, typeTimeFrequency quoteTime)
 {
     this.StockID   = Convert.ToString(jsonData["id"]);
     this.StockName = Convert.ToString(jsonData["name"]);
     if (this.Check_StockInfo())
     {
         return(base.FromJsonObj(jsonData, quoteTime));
     }
     return(false);
 }
Beispiel #13
0
 //对象转换-由json对象
 public override bool FromJsonObj(JObject jsonData, typeTimeFrequency quoteTime)
 {
     if (base.FromJsonObj(jsonData, quoteTime))
     {
         this.Price_Buy  = zxcTransHelper.ToDouble(jsonData["buyPrice"]) * _valueTimes;
         this.Price_Sell = zxcTransHelper.ToDouble(jsonData["sellPrice"]) * _valueTimes;
         return(true);
     }
     return(false);
 }
Beispiel #14
0
        /// <summary>按时间频率修正时间
        /// </summary>
        /// <param name="dtBase"></param>
        /// <param name="timeFrequency"></param>
        /// <returns></returns>
        public static DateTime CheckTime(DateTime dtBase, typeTimeFrequency timeFrequency, bool bFirst = true)
        {
            DateTime dtTime = dtBase;

            switch (timeFrequency)
            {
            case typeTimeFrequency.day:
                dtTime = new DateTime(dtBase.Year, dtBase.Month, dtBase.Day, 0, 0, 0);
                break;

            case typeTimeFrequency.m1:
                dtTime = new DateTime(dtBase.Year, dtBase.Month, dtBase.Day, dtBase.Hour, dtBase.Minute, 0);
                break;

            case typeTimeFrequency.m5:
                dtTime = new DateTime(dtBase.Year, dtBase.Month, dtBase.Day, dtBase.Hour, (int)Math.Floor(dtBase.Minute / 5.0) * 5, 0);
                break;

            case typeTimeFrequency.m10:
                dtTime = new DateTime(dtBase.Year, dtBase.Month, dtBase.Day, dtBase.Hour, (int)Math.Floor(dtBase.Minute / 10.0) * 10, 0);
                break;

            case typeTimeFrequency.m15:
                dtTime = new DateTime(dtBase.Year, dtBase.Month, dtBase.Day, dtBase.Hour, (int)Math.Floor(dtBase.Minute / 15.0) * 15, 0);
                break;

            case typeTimeFrequency.m30:
                dtTime = new DateTime(dtBase.Year, dtBase.Month, dtBase.Day, dtBase.Hour, (int)Math.Floor(dtBase.Minute / 30.0) * 30, 0);
                break;

            case typeTimeFrequency.m60:
                dtTime = new DateTime(dtBase.Year, dtBase.Month, dtBase.Day, dtBase.Hour, 0, 0);
                break;

            case typeTimeFrequency.m120:
                dtTime = new DateTime(dtBase.Year, dtBase.Month, dtBase.Day, dtBase.Hour, 0, 0);
                break;

            //case typeTimeFrequency.Week:
            //    dtTime = new DateTime(dtBase.Year, dtBase.Month, dtBase.Day, 0, 0, 0);
            //    break;
            //case typeTimeFrequency.Second_30:
            //    dtTime = new DateTime(dtBase.Year, dtBase.Month, dtBase.Day, dtBase.Hour, dtBase.Minute, (int)Math.Floor(dtBase.Second / 30.0) * 30);
            //    break;
            default:
                break;
            }

            //向后修正
            if (!bFirst)
            {
                dtTime = dtTime.AddSeconds((int)timeFrequency.Get_Value());
            }
            return(dtTime);
        }
Beispiel #15
0
        public bool InitTime(DateTime dtBase, typeTimeFrequency typeTimeFrequency)
        {
            _dtEnd   = CheckTime(dtBase);;
            _dtStart = _dtEnd.AddSeconds(-_dtStep * (_sumStep - 1));
            _indStep = this.GetInd(_dtEnd);

            //DateTime dtNow = DateTime.Now.AddDays(-1);
            //_dtLast = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, 0, 0, 0);
            _dtDataNow = _dtEnd;
            return(this.SetLastTime(_dtEnd));
        }
Beispiel #16
0
        public bool InitDataCache <T>(string tagName, typeTimeFrequency typeTimeFrequency, int cacheNums)
        {
            string tag = this.GetTagName(typeTimeFrequency, tagName);

            if (this.GetDataCache <T>(tag) == null)
            {
                DataCache <T> data = new DataCache <T>(tag, typeTimeFrequency, cacheNums, _DataCache_Set);
                _DataCaches[data.ID] = data;
                return(true);
            }
            return(false);
        }
Beispiel #17
0
        //对象转换-由json对象
        public override bool FromJsonObj(JObject jsonData, typeTimeFrequency quoteTime)
        {
            //基类初始
            bool bResult = base.FromJsonObj(jsonData, quoteTime);

            if (bResult)
            {
                this.QuoteTimeType = typeTimeFrequency.real;                //标识为实时数据
                this._exType       = this.StockExchange.ToString();
            }
            return(bResult);
        }
Beispiel #18
0
 public DataCache_Set(string tagName, DateTime dtBase, typeTimeFrequency typeTimeFrequency, int cacheNums, IData_Factor infoFactor, IDataCache_Set srcDataCache_Set = null) : base(tagName)
 {
     if (tagName == "")
     {
         tagName = infoFactor.ID;
     }
     _id             = tagName;
     _Info_Factor    = infoFactor;
     _tagName        = tagName;
     _Time_Frequency = typeTimeFrequency;
     _sumStep        = cacheNums;
     _dtStep         = (int)_Time_Frequency;
     _dtBase         = dtBase;
     _Parent         = srcDataCache_Set;
     this.InitTime(dtBase, typeTimeFrequency);
 }
Beispiel #19
0
        //对象转换-由json对象
        public virtual bool FromJsonObj(JObject jsonData, typeTimeFrequency quoteTime)
        {
            //修正倍数
            if (_stockInfo != null && _stockInfo.StockType == typeStock.Option)
            {
                _valueTimes = 10000;
            }

            //this.StockID_Tag = Convert.ToString(jsonData["idTag"]);
            this.Price_Open  = zxcTransHelper.ToDouble(jsonData["openPrice"]) * _valueTimes;
            this.Price_Per   = zxcTransHelper.ToDouble(jsonData["preClose"]) * _valueTimes;
            this.Price_Close = zxcTransHelper.ToDouble(jsonData["lastPrice"]) * _valueTimes;

            this.Price_Limit_H = zxcTransHelper.ToDouble(jsonData["high_limit"]) * _valueTimes;
            this.Price_Limit_L = zxcTransHelper.ToDouble(jsonData["low_limit"]) * _valueTimes;

            this.Price_High    = zxcTransHelper.ToDouble(jsonData["highPrice"]) * _valueTimes;
            this.Price_Low     = zxcTransHelper.ToDouble(jsonData["lowPrice"]) * _valueTimes;
            this.Price_Avg     = zxcTransHelper.ToDouble(jsonData["avg"]) * _valueTimes;
            this.TradeValume   = (int)zxcTransHelper.ToDouble(jsonData["tradeValume"]);
            this.TradeTurnover = zxcTransHelper.ToDouble(jsonData["tradeTurnover"]);

            this.DateTime    = Convert.ToDateTime(jsonData["datetime"]);
            this.IsSuspended = zxcTransHelper.ToBoolean(jsonData["paused"]);

            this.QuoteTimeType = quoteTime;
            if (quoteTime == typeTimeFrequency.none)
            {
                string strQuoteTimeType = jsonData["quoteTimeType"] + "";
                if (strQuoteTimeType != "")
                {
                    this.QuoteTimeType = (typeTimeFrequency)Enum.Parse(typeof(typeTimeFrequency), strQuoteTimeType);
                }
            }

            string strQuotePlat = jsonData["quotePlat"] + "";

            if (strQuotePlat != "")
            {
                this.QuotePlat = (typeQuotePlat)Enum.Parse(typeof(typeQuotePlat), strQuotePlat);
            }

            //同步标的信息,初始全部值
            this.Init_ValueAll();
            return(true);
        }
Beispiel #20
0
        public bool InitDataCache <T>(IData_Factor infoFactor, string tagName, typeTimeFrequency typeTimeFrequency, int cacheNums)
        {
            IDataCaches dataCaches = this.GetDataCaches(infoFactor);

            if (dataCaches == null)
            {
                if (InitDataCaches(infoFactor))
                {
                    dataCaches = this.GetDataCaches(infoFactor);
                    if (dataCaches == null)
                    {
                        return(false);
                    }
                }
            }
            return(dataCaches.InitDataCache <T>(tagName, typeTimeFrequency, cacheNums));
        }
Beispiel #21
0
        //初始数据检查对象集合-分钟级别
        public override bool InitDataCheck(IDataChecks pDataChecks, typeTimeFrequency timeFrequency)
        {
            //集成基类实现
            if (!base.InitDataCheck(pDataChecks, timeFrequency))
            {
                return(false);
            }

            //按时间频率分类设置
            switch (timeFrequency)
            {
            case typeTimeFrequency.none:
                break;

            case typeTimeFrequency.real:
                this.InitDataCheck_Instance(pDataChecks, typeof(QuoteCheck_RiseFall_Fixed <Data_Quote>));
                this.InitDataCheck_Instance(pDataChecks, typeof(QuoteCheck_Risk <Data_Quote>));
                this.InitDataCheck_Instance(pDataChecks, typeof(QuoteCheck_Hourly <Data_Quote>));
                break;

            case typeTimeFrequency.s30:
                break;

            case typeTimeFrequency.m1:
                break;

            case typeTimeFrequency.m10:
                break;

            case typeTimeFrequency.m5:
            case typeTimeFrequency.m15:
            case typeTimeFrequency.m30:
            case typeTimeFrequency.m60:
            case typeTimeFrequency.m120:
            case typeTimeFrequency.day:
                if (pDataChecks.DataCache.DataCache_Set.Info_Factor.Name == "50ETF")
                {
                    this.InitDataCheck_Instance(pDataChecks, typeof(QuoteCheck_Risk_Quantify <Data_Quote>));
                }
                break;

            default:
                break;
            }
            return(true);
        }
Beispiel #22
0
        //缓存数据初始装载数据
        public virtual int DataCacheLoad(IDataCache pDataCache, DateTime dtEnd, int nCaches = -1)
        {
            typeTimeFrequency      timeFrequency = pDataCache.DataCache_Set.Time_Frequency;
            DataCache <Data_Quote> dataCache     = (DataCache <Data_Quote>)pDataCache;

            if (dataCache == null)
            {
                return(0);
            }
            if (timeFrequency == typeTimeFrequency.real)
            {
                dataCache.InitDatas(null, false, true);
                return(0);
            }
            if (pDataCache.DataCache_Set.Info_Factor.Name != "50ETF")
            {
                return(0);
            }

            //校正行情标的
            IDataCache_Set pSet       = dataCache.DataCache_Set;
            StockInfo      pStockInfo = Quote_Manager._Manager.Stocks.Get_StockInfo(pSet.Info_Factor.ID);

            if (pStockInfo == null)
            {
                return(0);
            }

            //查询数据
            dtEnd   = dtEnd == DateTime.MinValue ? pSet.Time_End : dtEnd;
            nCaches = nCaches < 0 ? pSet.Sum_Step : nCaches;
            List <Data_Quote> lstQuotes = QuoteQuery._Query.Query(pStockInfo.StockID_Tag, dtEnd, nCaches, timeFrequency, true);

            if (lstQuotes.Count == pSet.Sum_Step)
            {
                //重新初始数据
                Dictionary <DateTime, Data_Quote> poData_Quotes = new Dictionary <DateTime, Data_Quote>();
                foreach (var item in lstQuotes)
                {
                    poData_Quotes[item.DateTime] = item;
                }
                return(dataCache.InitDatas(poData_Quotes, true, true));
            }
            return(0);
        }
Beispiel #23
0
        public IDataCache <T> GetDataCache <T>(string tagName, typeTimeFrequency typeTimeFrequency = typeTimeFrequency.None, bool autoInit = false, int cacheNums = 1)
        {
            IDataCache data = null;
            string     tag  = this.GetTagName(typeTimeFrequency, tagName);

            if (_DataCaches.TryGetValue(tag, out data))
            {
                //What ever you gonna do next...
            }
            if (autoInit && data == null)
            {
                if (InitDataCache <T>(tagName, typeTimeFrequency, cacheNums))
                {
                    return(GetDataCache <T>(tagName, typeTimeFrequency));
                }
            }
            return((IDataCache <T>)data);
        }
        //初始规则信息集合-指定时间级别-弃用
        private bool InitDataChecks_Check(IDataCaches dataCaches, typeTimeFrequency timeFrequency)
        {
            //数据缓存集检查
            if (dataCaches == null)
            {
                return(false);
            }

            //提取数据缓存对象、及检查对象集
            IDataCache <Data_Quote> poDataCache        = dataCaches.GetDataCache <Data_Quote>("", timeFrequency);
            IDataChecks             poDataChecks_Cache = new DataChecks_Quote(poDataCache.ID, poDataCache, null, _msger);

            //初始检查集
            bool bResult = poDataCache.InitDataChecks(poDataChecks_Cache);

            bResult = bResult && this.InitDataCheck(poDataChecks_Cache, timeFrequency);
            return(bResult);
        }
        //初始数据检查对象集合-分钟级别
        public virtual bool InitDataCheck(IDataChecks pDataChecks, typeTimeFrequency timeFrequency)
        {
            switch (timeFrequency)
            {
            case typeTimeFrequency.none:
                break;

            case typeTimeFrequency.real:
                this.InitDataCheck_Instance(pDataChecks, typeof(DataCheck_Print <Data_Quote>));
                break;

            case typeTimeFrequency.s30:
                break;

            case typeTimeFrequency.m1:
                break;

            case typeTimeFrequency.m5:
                break;

            case typeTimeFrequency.m10:
                break;

            case typeTimeFrequency.m15:
                break;

            case typeTimeFrequency.m30:
                break;

            case typeTimeFrequency.m60:
                break;

            case typeTimeFrequency.m120:
                break;

            case typeTimeFrequency.day:
                break;

            default:
                break;
            }
            return(true);
        }
Beispiel #26
0
        /// <summary>更新对象集
        /// </summary>
        /// <param name="collection"></param>
        protected internal virtual bool UpdateRange(List <Data_Quote> collection, typeTimeFrequency quoteTime)
        {
            List <Data_Quote> lstTemp = new List <Data_Quote>();

            foreach (var item in collection)
            {
                //校正时间频率进行添加
                DateTime dtTime = this._infoExchange.CheckTime(item.DateTime, quoteTime);
                if (dtTime == item.DateTime)
                {
                    lstTemp.Add(item);
                }
                else
                {
                }
            }
            if (lstTemp.Count > 0)
            {
                return(this._dtQuote.AddRange(lstTemp, true, true));
            }
            return(true);
        }
Beispiel #27
0
        /// <summary>查询行情(历史)
        /// </summary>
        /// <param name="endTime">结束时间</param>
        /// <param name="quoteBars">标的行情数</param>
        /// <param name="quoteTime">行情时间类型</param>
        /// <param name="autoUpdate">是否自动更新本地库表</param>
        /// <returns></returns>
        public List <Data_Quote> Query(DateTime endTime, int quoteBars = 1, typeTimeFrequency quoteTime = typeTimeFrequency.day, bool autoUpdate = true)
        {
            //修正时间
            if (endTime == DateTime.MinValue)
            {
                endTime = DateTime.Now;
            }

            //自动更新修正数据
            if (autoUpdate)
            {
                if (!this.Query_Check(endTime.AddSeconds(-quoteBars * (int)quoteTime.Get_Value()), endTime, quoteBars, quoteTime, true))
                {
                    return(null);
                }
            }


            //查询库表
            List <Data_Quote> lstQuote = _dtQuote.FindAll(e => e.DateTime <= endTime && e.QuoteTimeType == quoteTime && e.IsDel == false).OrderByDescending(t => t.DateTime).Take(quoteBars).ToList();

            return(lstQuote);
        }
Beispiel #28
0
        public T GetData <T>(IData_Factor infoFactor, string strTag, DateTime dtTime, typeTimeFrequency typeTimeFrequency = typeTimeFrequency.None)
        {
            IDataCache <T> dataCache = GetDataCache <T>(infoFactor, strTag, typeTimeFrequency);

            if (dataCache == null)
            {
                return(default(T));
            }

            return(dataCache.GetData(dtTime));
        }
Beispiel #29
0
        public bool SetData <T>(IData_Factor infoFactor, string strTag, DateTime dtTime, T data, typeTimeFrequency typeTimeFrequency = typeTimeFrequency.None)
        {
            IDataCache <T> dataCache = GetDataCache <T>(infoFactor, strTag, typeTimeFrequency);

            if (dataCache == null)
            {
                return(false);
            }

            return(dataCache.SetData(dtTime, data));
        }
Beispiel #30
0
        public IDataCache <T> GetDataCache <T>(IData_Factor infoFactor, string strTag = "", typeTimeFrequency typeTimeFrequency = typeTimeFrequency.None, bool autoInit = false, int cacheNums = 1)
        {
            IDataCaches dataCaches = GetDataCaches(infoFactor, autoInit);

            if (dataCaches == null)
            {
                return(null);
            }

            IDataCache <T> data = dataCaches.GetDataCache <T>(strTag, typeTimeFrequency, autoInit, cacheNums);

            return(data);
        }