Ejemplo n.º 1
0
        public static async Task ShowTime(SettingsManager settings)
        {
            DateTime     tradingDayStart = new DateTime(2020, 8, 13, 9, 30, 15);
            TradeManager trader          = new TradeManager(settings, tradingDayStart);

            trader.JournalOfPrices = await trader.CreateJournal();

            StockQuote sq = trader.JournalOfPrices[0];
            Holding    h  = new Holding();

            Console.WriteLine(h.EpochConvertor(sq.EpochTime));
        }
Ejemplo n.º 2
0
        public static async Task <int> TestParameters(SettingsManager settings,
                                                      short month,
                                                      short day,
                                                      double startDelay,
                                                      double checkPointDelay,
                                                      double buyDelay,
                                                      double stopLossDelay,
                                                      double sellTimeDelay,
                                                      double stopLoss,
                                                      int total)
        {
            settings.stopLossPerShare = stopLoss;
            DateTime     tradingDayStart = new DateTime(2020, month, day, 9, 30, 15);
            TradeManager trader          = new TradeManager(settings, tradingDayStart);

            trader.JournalOfPrices = await trader.CreateJournal();

            if (trader.JournalOfPrices.Count == 0)
            {
                return(total);
            }
            DateTime  startTime    = tradingDayStart.AddMinutes(startDelay);
            DateTime  checkPoint   = tradingDayStart.AddMinutes(checkPointDelay);
            DateTime  buyTime      = tradingDayStart.AddMinutes(buyDelay);
            DateTime  stopLossTime = tradingDayStart.AddMinutes(stopLossDelay);
            DateTime  sellTime     = tradingDayStart.AddMinutes(sellTimeDelay);
            Portfolio portfolio    = await trader.CreatePortfolio(startTime, checkPoint, buyTime);

            await trader.StopLoss(portfolio, stopLossTime, sellTime);

            double profit = await trader.ValuePortfolio(sellTime);

            total += (int)Math.Round(profit);
            if (profit > 0)
            {
                Console.WriteLine($"Profit is ${Math.Round(profit)} on {day}th for total to date ${total}.");
                // Console.WriteLine($"Peak potential profit of ${Math.Round(portfolio.PeakValue - portfolio.Cost)}.");
            }
            else
            {
                Console.WriteLine($"LOSS of ${Math.Round(profit)} on {day}th for total to date ${total}.");
            }
            return(total);
        }