コード例 #1
0
ファイル: PriceSet.cs プロジェクト: kozzion/KozzionTrading
        //TODO make unit tests
        private static List <Price> CreatePriceListClean(IReadOnlyList <Price> price_list_unclean)
        {
            //Build price
            List <Price> clean_price_list = new List <Price>();
            DateTimeUTC  time             = price_list_unclean[0].Time;
            double       bid         = price_list_unclean[0].Bid;
            double       ask         = price_list_unclean[0].Ask;
            int          price_index = 0;

            while (price_index < price_list_unclean.Count)
            {
                if (time < price_list_unclean[price_index].Time)
                {
                    //Create new price
                    clean_price_list.Add(new Price(time, bid, ask));
                    time = time.AddSeconds(1);
                }
                else
                {
                    //Save and scroll
                    ask = price_list_unclean[price_index].Ask;
                    bid = price_list_unclean[price_index].Bid;
                    price_index++;
                }
            }
            //TODO make last
            clean_price_list.Add(new Price(time, bid, ask));
            return(clean_price_list);
        }
コード例 #2
0
ファイル: PriceSet.cs プロジェクト: kozzion/KozzionTrading
        private static IReadOnlyList <Price> CreatePrices(DateTimeUTC open_time, DateTimeUTC final_time)
        {
            List <Price> price = new List <Price>();

            while (open_time <= final_time)
            {
                price.Add(new Price(open_time, 0, 0));
                open_time = open_time.AddSeconds(1);
            }
            return(price);
        }
コード例 #3
0
ファイル: PriceSet.cs プロジェクト: kozzion/KozzionTrading
        private static IReadOnlyList <PriceCandle> CreateSecond1(DateTimeUTC open_time, DateTimeUTC final_time)
        {
            List <PriceCandle> candles = new List <PriceCandle>();

            while (open_time < final_time)
            {
                candles.Add(new PriceCandle(open_time, 0, 0));
                open_time = open_time.AddSeconds(1);
            }
            return(candles);
        }
コード例 #4
0
ファイル: PriceCandle.cs プロジェクト: kozzion/KozzionTrading
        public static DateTimeUTC GetCloseTime(DateTimeUTC time, TimeScale time_scale)
        {
            DateTimeUTC open_time = GetOpenTime(time, time_scale);

            switch (time_scale)
            {
            case TimeScale.Second1:
                return(open_time.AddSeconds(1));

            case TimeScale.Minute1:
                return(open_time.AddMinutes(1));

            case TimeScale.Minute15:
                return(open_time.AddMinutes(15));

            case TimeScale.Minute30:
                return(open_time.AddMinutes(30));

            case TimeScale.Hour1:
                return(open_time.AddHours(1));

            case TimeScale.Hour4:
                return(open_time.AddHours(4));

            case TimeScale.Day1:
                return(open_time.AddDays(1));

            case TimeScale.Week1:
                return(open_time.AddDays(7));

            case TimeScale.Month1:
                return(open_time.AddMonths(1));

            default:
                throw new Exception("Unknown Timescale");
            }
        }