Пример #1
0
 public string FromPeriodicityToLocalizedString(Periodicity periodicity)
 {
     if (periodicity == Periodicity.Year)
     {
         return(Properties.Resources.Year);
     }
     else if (periodicity == Periodicity.Month)
     {
         return(Properties.Resources.Month);
     }
     else if (periodicity == Periodicity.Week)
     {
         return(Properties.Resources.Week);
     }
     else if (periodicity == Periodicity.Day)
     {
         return(Properties.Resources.Day);
     }
     else if (periodicity == Periodicity.Hour)
     {
         return(Properties.Resources.Hour);
     }
     else if (periodicity == Periodicity.Minute)
     {
         return(Properties.Resources.Minute);
     }
     else
     {
         return(periodicity.ToString());
     }
 }
Пример #2
0
 public void WriteXml(XmlWriter writer)
 {
     writer.WriteStartElement("Journal");
     writer.WriteElementString("JournalName", _journalName);
     writer.WriteElementString("Periodicity", _periodicity.ToString());
     writer.WriteStartElement("Articles");
     if (Articles != null)
     {
         Articles.ForEach(article =>
         {
             article.WriteXml(writer);
         });
     }
     writer.WriteEndElement();
     writer.WriteEndElement();
 }
Пример #3
0
        public static BarPeriod ToBarPeriod(Periodicity periodicity)
        {
            var st = periodicity.ToString();

            if (st == "S1")
            {
                return(BarPeriod.S1);
            }
            if (st == "S10")
            {
                return(BarPeriod.S10);
            }
            if (st == "M1")
            {
                return(BarPeriod.M1);
            }
            if (st == "M5")
            {
                return(BarPeriod.M5);
            }
            if (st == "M15")
            {
                return(BarPeriod.M15);
            }
            if (st == "H1")
            {
                return(BarPeriod.H1);
            }
            if (st == "H4")
            {
                return(BarPeriod.H4);
            }
            if (st == "D1")
            {
                return(BarPeriod.D1);
            }
            if (st == "MN1")
            {
                return(BarPeriod.MN1);
            }

            throw new ArgumentException("Unknown periodicity = " + st);
        }
Пример #4
0
        public static BarPeriod ToBarPeriod(Periodicity periodicity)
		{
			var st = periodicity.ToString();
			if (st == "S1")
			{
				return BarPeriod.S1;
			}
			if (st == "S10")
			{
				return BarPeriod.S10;
			}
			if (st == "M1")
			{
				return BarPeriod.M1;
			}
			if (st == "M5")
			{
				return BarPeriod.M5;
			}
			if (st == "M15")
			{
				return BarPeriod.M15;
			}
			if (st == "H1")
			{
				return BarPeriod.H1;
			}
			if (st == "H4")
			{
				return BarPeriod.H4;
			}
			if (st == "D1")
			{
				return BarPeriod.D1;
			}
			if (st == "MN1")
			{
				return BarPeriod.MN1;
			}

			throw new ArgumentException("Unknown periodicity = " + st);
		}
Пример #5
0
        static void ForwardFillBars(IHistoryManager cache, string symbol, Periodicity periodicity, FxPriceType priceType, DateTime startTime, DateTime endTime, ICollection <HistoryBar> bars)
        {
            try
            {
                for (var current = startTime; current < endTime;)
                {
                    var report = cache.QueryBarHistory(current, -RequestedBarsNumber, symbol, periodicity.ToString(), priceType);
                    var items  = report.Items;

                    foreach (var element in report.Items)
                    {
                        if (element.Time >= endTime)
                        {
                            return;
                        }
                        bars.Add(element);
                    }
                    if (items.Count == 0)
                    {
                        return;
                    }
                    current = items.Last().Time;
                    current = current + periodicity;
                }
            }
            catch (StorageHistoryNotFoundException)
            {
            }
        }
Пример #6
0
        protected override List <HistoryBar> RequestHistory(DateTime timestamp, int count)
        {
            var result = new List <HistoryBar>(Math.Abs(count));

            if (count == 0)
            {
                return(result);
            }

            try
            {
                var report = _historyClient.QueryQuoteHistoryBars(timestamp, count, Symbol, Periodicity.ToString(), (PriceType.HasValue && (PriceType.Value == FxPriceType.Ask)) ? TTQuoteHistoryClient.PriceType.Ask : TTQuoteHistoryClient.PriceType.Bid);
                var bars   = report.Select(srcBar =>
                {
                    var dstBar = new HistoryBar
                    {
                        Time  = srcBar.Time,
                        Open  = srcBar.Open,
                        Hi    = srcBar.High,
                        Low   = srcBar.Low,
                        Close = srcBar.Close
                    };
                    return(dstBar);
                });
                result.AddRange(bars);
            }
            catch (Exception) {}

            return(result);
        }
Пример #7
0
        static void ForwardFillBars(IHistoryManager cache, string symbol, Periodicity periodicity, FxPriceType priceType, DateTime startTime, DateTime endTime, ICollection<HistoryBar> bars)
        {
            try
            {
                for (var current = startTime; current < endTime; )
                {
                    var report = cache.QueryBarHistory(current, -RequestedBarsNumber, symbol, periodicity.ToString(), priceType);
                    var items = report.Items;

                    foreach (var element in report.Items)
                    {
                        if (element.Time >= endTime)
                        {
                            return;
                        }
                        bars.Add(element);
                    }
                    if (items.Count == 0)
                    {
                        return;
                    }
                    current = items.Last().Time;
                    current = current + periodicity;
                }
            }
            catch (StorageHistoryNotFoundException)
            {
            }
        }