Example #1
0
        static List <MarketDay> PopulateDays(List <MarketDataPoint> marketDataPoints)
        {
            List <MarketDay> marketDays = new List <MarketDay>();

            MarketDataPoint currentDP = new MarketDataPoint("", DateTime.Now, 0, 0, 0, 0, 0);
            MarketDataPoint previousDP;

            MarketDay day = new MarketDay();

            bool firstDP = true;

            double totalCount  = marketDataPoints.Count;
            double count       = 0;
            double per         = 0;
            double previousPer = 0;

            foreach (MarketDataPoint dataPoint in marketDataPoints)
            {
                count++;
                per = count / totalCount;
                if (per > previousPer + 0.05)
                {
                    previousPer = per;
                    Console.Write("|");
                }

                if (firstDP)
                {
                    firstDP = false;

                    currentDP = dataPoint;
                    day       = new MarketDay();
                    day.AddDataPoint(currentDP);
                }
                else
                {
                    previousDP = currentDP;
                    currentDP  = dataPoint;

                    if (currentDP.Ticker == previousDP.Ticker)
                    {
                        day.AddDataPoint(currentDP);
                    }
                    else
                    {
                        marketDays.Add(day);
                        day = new MarketDay();
                        day.AddDataPoint(currentDP);
                    }
                }
            }

            return(marketDays);
        }
Example #2
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(MarketDay.ToStringNice(false));
            sb.AppendLine($"Action:{MarketAction} {BoundsMarketAction} Volumes:{FirstVolume.Volume}-{SecondVolume.Volume} {FirstVolume.VolumeClass}-{SecondVolume.VolumeClass} VolumeChange:{VolumeChange.ToString("f4")} LowHigh:{LocalLow}-{LocalHigh} Bounds:{LowBound}-{HighBound} BuyPrice:{BuyPrice}");
            sb.AppendLine($"Long:{LongPoints.Count} Highest:{HighestSellPoint?.High ?? 0} at {HighestSellPoint?.DateTime.TimeOfDay ?? new TimeSpan(0)} {HighestSellPercentage.ToString("f4")}");
            sb.AppendLine($"Short:{ShortPoints.Count} Lowest:{LowestShortPoint?.Low ?? 0} at {LowestShortPoint? .DateTime.TimeOfDay ?? new TimeSpan(0)} {LowestShortPercentage.ToString("f4")}");

            return(sb.ToString());
        }
Example #3
0
        public static List <MarketDay> ExtractSimulationData()
        {
            var file = File.ReadLines("output.txt");

            List <MarketDay> days      = new List <MarketDay>();
            MarketDay        day       = new MarketDay();
            MarketDataPoint  dataPoint = new MarketDataPoint("", DateTime.Now, 0, 0, 0, 0, 0);
            bool             first     = true;

            foreach (var s in file)
            {
                if (s != "")
                {
                    if (!s.Contains("\t"))
                    {
                        if (!first)
                        {
                            days.Add(day);
                        }
                        day     = new MarketDay();
                        day.Gap = double.Parse(s.Split(',')[7]);
                        first   = false;
                    }
                    else
                    {
                        day.AddDataPoint(ExtractDataString(s));
                    }
                }
            }

            foreach (var marketDay in days)
            {
                if (marketDay.DateTime < new DateTime(2016, 10, 31))
                {
                    foreach (var marketDataPoint in marketDay.DataPoints)
                    {
                        marketDataPoint.DateTime = marketDataPoint.DateTime.AddHours(-1);
                    }
                }
            }

            return(days);
        }