Ejemplo n.º 1
0
        public int GetLastUpdatedKLineData(string code, KLinePeriod klinePeriod)
        {
            UpdatedKLineDataKey key = new UpdatedKLineDataKey();

            key.code   = code.ToUpper();
            key.period = klinePeriod;

            if (dic_CodePeriod_LastUpdatedKLine.ContainsKey(key))
            {
                return(dic_CodePeriod_LastUpdatedKLine[key]);
            }
            return(-1);
        }
Ejemplo n.º 2
0
        public override bool Equals(object obj)
        {
            if (!(obj is UpdatedKLineDataKey))
            {
                return(false);
            }
            UpdatedKLineDataKey key = (UpdatedKLineDataKey)obj;

            if (this.period.Equals(key.period) && this.code == key.code)
            {
                return(true);
            }
            return(base.Equals(obj));
        }
Ejemplo n.º 3
0
        private void SaveKLine_Code(string code, StringBuilder sb)
        {
            for (int i = 0; i < storedKLinePeriods.Count; i++)
            {
                KLinePeriod         klinePeriod = storedKLinePeriods[i];
                UpdatedKLineDataKey key         = new UpdatedKLineDataKey();
                key.code   = code;
                key.period = klinePeriod;

                if (dic_CodePeriod_LastUpdatedKLine.ContainsKey(key))
                {
                    int lastUpdateDate = dic_CodePeriod_LastUpdatedKLine[key];
                    sb.Append(code).Append(",").Append((int)klinePeriod.PeriodType)
                    .Append(",").Append(klinePeriod.Period)
                    .Append(",").Append(lastUpdateDate).Append("\r\n");
                }
            }
        }
Ejemplo n.º 4
0
        public void WriteUpdateInfo_KLine(string code, KLinePeriod klinePeriod, int lastUpdatedDate)
        {
            code = code.ToUpper();
            if (!codes_kline.Contains(code))
            {
                codes_kline.Add(code);
            }
            UpdatedKLineDataKey key = new UpdatedKLineDataKey();

            key.code   = code;
            key.period = klinePeriod;
            if (!storedKLinePeriods.Contains(klinePeriod))
            {
                storedKLinePeriods.Add(klinePeriod);
            }

            if (dic_CodePeriod_LastUpdatedKLine.ContainsKey(key))
            {
                dic_CodePeriod_LastUpdatedKLine.Remove(key);
            }
            dic_CodePeriod_LastUpdatedKLine.Add(key, lastUpdatedDate);
        }
Ejemplo n.º 5
0
        private void LoadKLineUpdateInfo()
        {
            this.codes_kline.Clear();
            this.storedKLinePeriods.Clear();
            //this.dic_Id_KLinePeriod_LastUpdatedKLine.Clear();
            this.dic_CodePeriod_LastUpdatedKLine.Clear();
            string path_kline = GetPath_UpdatedKLineDataInfo();

            if (!File.Exists(path_kline))
            {
                return;
            }
            string[] lines_kline = File.ReadAllLines(path_kline);
            for (int i = 0; i < lines_kline.Length; i++)
            {
                string line = lines_kline[i];
                if (StringUtils.IsEmpty(line))
                {
                    continue;
                }
                string[]            content = line.Split(',');
                string              code    = content[0].Trim();
                UpdatedKLineDataKey key     = new UpdatedKLineDataKey();
                key.code   = code;
                key.period = new KLinePeriod((KLineTimeType)int.Parse(content[1]), int.Parse(content[2]));
                this.dic_CodePeriod_LastUpdatedKLine.Add(key, int.Parse(content[3]));
                if (!this.storedKLinePeriods.Contains(key.period))
                {
                    this.storedKLinePeriods.Add(key.period);
                }
                if (!this.codes_kline.Contains(code))
                {
                    this.codes_kline.Add(code);
                }
            }
        }