Пример #1
0
        private static IReadOnlyList <Price> CombinePrices(IList <PriceSet> price_set_list)
        {
            TradingSymbol symbol = price_set_list[0].Symbol;

            for (int index = 1; index < price_set_list.Count; index++)
            {
                if (!price_set_list[index].Symbol.Equals(symbol))
                {
                    throw new Exception("Symbols do not match");
                }

                if (price_set_list[index].OpenDateTime < price_set_list[index - 1].CloseDateTime)
                {
                    throw new Exception("PriceSet show overlap");
                }
            }

            List <Price> price_unclean_list = new List <Price>(price_set_list[0].Prices);

            for (int index = 1; index < price_set_list.Count; index++)
            {
                price_unclean_list.AddRange(price_set_list[index].Prices);
            }
            return(price_unclean_list);
        }
Пример #2
0
        public override bool Equals(object other)
        {
            if (other is TradingSymbol)
            {
                TradingSymbol other_typed = (TradingSymbol)other;
                if (Broker != other_typed.Broker)
                {
                    return(false);
                }
                if (Account != other_typed.Account)
                {
                    return(false);
                }

                if (Symbol != other_typed.Symbol)
                {
                    return(false);
                }

                if (Description != other_typed.Description)
                {
                    return(false);
                }
                return(true);
            }
            return(false);
        }
Пример #3
0
 //Primary constucter
 public PriceSet(TradingSymbol symbol, IReadOnlyList <Price> prices, IReadOnlyList <PriceCandle> second_1)
 {
     this.Symbol  = symbol;
     this.Prices  = prices;
     this.Second1 = second_1;
     //Build rest from prices and second data
     this.Ticks    = CreateTicks(Prices);
     this.Minute1  = CreatePriceCandleList(Second1, TimeScale.Minute1);
     this.Minute15 = CreatePriceCandleList(Second1, TimeScale.Minute15);
     this.Minute30 = CreatePriceCandleList(Second1, TimeScale.Minute30);
     this.Hour1    = CreatePriceCandleList(Second1, TimeScale.Hour1);
     this.Hour4    = CreatePriceCandleList(Second1, TimeScale.Hour4);
     this.Day1     = CreatePriceCandleList(Second1, TimeScale.Day1);
     this.Week1    = CreatePriceCandleList(Second1, TimeScale.Week1);
     this.Month1   = CreatePriceCandleList(Second1, TimeScale.Month1);
 }
Пример #4
0
        public static PriceSet Read(BinaryReader reader)
        {
            TradingSymbol symbol = TradingSymbol.Read(reader);
            int           price_list_clean_count = reader.ReadInt32();
            List <Price>  price_list_clean       = new List <Price>();

            for (int price_index = 0; price_index < price_list_clean_count; price_index++)
            {
                price_list_clean.Add(Price.Read(reader));
            }

            int second1_count          = reader.ReadInt32();
            List <PriceCandle> second1 = new List <PriceCandle>();

            for (int price_index = 0; price_index < second1_count; price_index++)
            {
                second1.Add(PriceCandle.Read(reader));
            }
            return(new PriceSet(symbol, price_list_clean, second1));
        }
Пример #5
0
 //Primary constucter
 public PriceSet(TradingSymbol symbol, DateTimeUTC open_time, DateTimeUTC close_time)
     : this(symbol, CreatePrices(open_time, close_time), CreateSecond1(open_time, close_time))
 {
 }
Пример #6
0
 //Read initial constucter
 public PriceSet(TradingSymbol symbol, IReadOnlyList <Price> price_list_unclean)
     : this(symbol, CreatePriceListClean(price_list_unclean), CreateSecond1(price_list_unclean))
 {
 }