Ejemplo n.º 1
0
        /// <summary>
        /// Load history for special date
        /// </summary>
        /// <param name="date"></param>
        public void Load(DateTime date)
        {
            string filePath = GetFilePath(date);

            this.Clear();
            if (!File.Exists(filePath))
            {
                return;
            }
            using (StreamReader stream = File.OpenText(filePath))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(Level2History));
                Level2History tmpHistory = serializer.Deserialize(stream) as Level2History;
                this.Symbol = tmpHistory.Symbol;
                this.AddRange(tmpHistory);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add Dom snapshot from dde server data
        /// </summary>
        /// <param name="table"></param>
        public static void AddSnapShotFromDde(string symbol, object[][] table)
        {
            // Create level 2 shapshot from table
            Level2 snapShot = new Level2(symbol, table, DateTime.Now);

            // Get level2 history for symbol
            Level2History history;

            if (Level2Histories.ContainsKey(symbol))
            {
                // Add snapshot to existing
                history = Level2Histories[symbol];
            }
            else
            {
                history = new Level2History(symbol)
                {
                    SaveOnExit = true
                };
                Level2Histories.Add(symbol, history);
                // Add this history to bars
                if (QuikQuotesLoader.HistoryBars.ContainsKey(symbol))
                {
                    QuikQuotesLoader.HistoryBars[symbol].Level2History = history;
                }
            }

            if (history.Count != 0 &&
                snapShot.Time.Minute % 5 == 1 &&
                history.Last().Time.Minute != snapShot.Time.Minute)
            {
                // Save history
                history.Save();
            }

            // Add to history
            history.Add(snapShot);
            //history.Save();
            //history.Load(snapShot.Time);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="symbol"></param>
 /// <param name="scale"></param>
 /// <param name="interval"></param>
 public BarsAndDom(string symbol, BarScale scale, int interval) : base(symbol, scale, interval)
 {
     Level2History = new Level2History(Symbol);
 }