Esempio n. 1
0
        /// <summary>
        /// Get bar from line
        /// </summary>
        /// <param name="line"></param>
        /// <returns></returns>
        public static Bar LoadBar(string data)
        {
            NumberFormatInfo numberFormatInfo = DataContext.NumberFormatInfo;
            Bar bar = new Bar();

            string[] dataArray = data.Split(DataContext.Delimiter);
            // Symbol
            //bar.Symbol = dataArray[0];

            //// Date
            //string dateString = dataArray[2];
            //int year = int.Parse(dateString.Substring(0, 4));
            //int month = int.Parse(dateString.Substring(4, 2));
            //int day = int.Parse(dateString.Substring(6, 2));
            //// Time
            //string timeString = dataArray[3];
            //int hour = int.Parse(timeString.Substring(0, 2));
            //int minute = int.Parse(timeString.Substring(2, 2));
            //int second = int.Parse(timeString.Substring(4, 2));
            //// Set time
            //bar.Time = new DateTime(year, month, day, hour, minute, second);
            bar.Time = LoadDateTime(dataArray);

            // OHLCV
            string openString = dataArray[4];
            bar.Open = double.Parse(openString, numberFormatInfo);
            string highString = dataArray[5];
            bar.High = double.Parse(highString, numberFormatInfo);
            string lowString = dataArray[6];
            bar.Low = double.Parse(lowString, numberFormatInfo);
            string closeString = dataArray[7];
            bar.Close = double.Parse(closeString, numberFormatInfo);
            string volString = dataArray[8];
            bar.Volume = int.Parse(volString, numberFormatInfo);

            return bar;
        }
Esempio n. 2
0
 /// <summary>
 /// Create a new Bar object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="open">Initial value of the Open property.</param>
 /// <param name="low">Initial value of the Low property.</param>
 /// <param name="high">Initial value of the High property.</param>
 /// <param name="close">Initial value of the Close property.</param>
 /// <param name="volume">Initial value of the Volume property.</param>
 /// <param name="time">Initial value of the Time property.</param>
 /// <param name="period">Initial value of the Period property.</param>
 /// <param name="symbol">Initial value of the Symbol property.</param>
 public static Bar CreateBar(global::System.Guid id, global::System.Double open, global::System.Double low, global::System.Double high, global::System.Double close, global::System.Int32 volume, global::System.DateTime time, global::System.Int32 period, global::System.String symbol)
 {
     Bar bar = new Bar();
     bar.Id = id;
     bar.Open = open;
     bar.Low = low;
     bar.High = high;
     bar.Close = close;
     bar.Volume = volume;
     bar.Time = time;
     bar.Period = period;
     bar.Symbol = symbol;
     return bar;
 }
Esempio n. 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the AllBars EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAllBars(Bar bar)
 {
     base.AddObject("AllBars", bar);
 }