Beispiel #1
0
        public static void AddAndMax100(this List <Ohlc> l, Ohlc o)
        {
            try
            {
                lock (l)
                {
                    var q = l.Where(a => a.WhenInDt == o.WhenInDt).FirstOrDefault();
                    if (q != null)
                    {
                        return;
                    }

                    var i = l.Count - 100;
                    if (i > 0)
                    {
                        l.RemoveRange(0, i);
                    }
                    l.Add(o);
                }
            }
            catch (Exception ex)
            {
                Singleton <TextLog> .Instance.Error(ex, "addandMax100");
            }
        }
Beispiel #2
0
        public void Add(Ohlc o)
        {
            var dt = o.WhenInDt;

            for (int i = 0; i < range.Count - 1; i++)
            {
                if (dt >= range[i] && dt < range[i + 1])
                {
                    dic[range[i]].Calc(o);
                    break;
                }
            }
        }
Beispiel #3
0
 public void Add(Ohlc o)
 {
     if (dic.ContainsKey(o.OhlcType))
     {
         dic[o.OhlcType].AddAndMax100(o);
     }
     else
     {
         dic.Add(o.OhlcType, new List <Ohlc> {
             o
         });
     }
 }
Beispiel #4
0
 /// <summary>
 /// 区间合并
 /// </summary>
 /// <param name="o"></param>
 public void Calc(Ohlc o)
 {
     if (o.WhenInDt > WhenInDt)
     {
         Close = o.Close;
     }
     else if (o.WhenInDt < WhenInDt)
     {
         Open = o.Open;
     }
     if (o.High > High)
     {
         High = o.High;
     }
     if (o.Low > 0 && o.Low < Low)
     {
         Low = o.Low;
     }
     Volume += o.Volume;
 }
Beispiel #5
0
        public void Add(Ohlc o)
        {
            var contract = GetContractById(o.WhatId);

            if (contract == null)
            {
                return;
            }
            if (o == null)
            {
                return;
            }
            lock (loc)
            {
                if (!dic.ContainsKey(contract.Code))
                {
                    dic.Add(contract.Code, new KlineData(contract.Code, contract.Name));
                }
            }

            dic[contract.Code].Add(o);
        }
Beispiel #6
0
 public void Add(Ohlc o)
 {
     m5.Add(o); m15.Add(o); m30.Add(o); m60.Add(o); m480.Add(o); m1440.Add(o);
 }
Beispiel #7
0
        public static Ohlc Fake(DateTime when)
        {
            Ohlc o = new Ohlc(when, 83 + when.Minute * 10, 99 + when.Minute * 10, 79 + when.Minute * 10, 93 + when.Minute * 10, 100);

            return(o);
        }
Beispiel #8
0
 public void Add(Ohlc o)
 {
 }