Beispiel #1
0
        public MoneyBalanceOverTime(BaseInvestmentSchedule investmentSchedule, BaseInvestmentStategy investmentStategy, List <MoneyDaily> dailyMoneyLogs)
        {
            AmountInvested         = 0;
            BaseInvestmentSchedule = investmentSchedule;
            BaseInvestmentStategy  = investmentStategy;

            StartDate = DateTime.MaxValue;
            EndDate   = DateTime.MinValue;

            DataDictionary = new Dictionary <DateTime, MoneyDaily>();
            this.Data      = dailyMoneyLogs;

            foreach (var item in dailyMoneyLogs)
            {
                AmountInvested += item.CashInvested;
                DataDictionary.Add(item.Date, item);

                if (item.Date.IsBefore(StartDate))
                {
                    StartDate = item.Date;
                }

                if (item.Date.IsAfter(EndDate))
                {
                    EndDate = item.Date;
                }
            }
        }
Beispiel #2
0
        public MethodEvaluation(BaseInvestmentStategy method, StockMarketHistoricalData data)
        {
            Method         = method;
            HistoricalData = data;
            DailyMoneyLogs = new List <MoneyDaily>();

            // computer extra data fields on Historical Data
            HistoricalData.SetCalculatedFieldsForDateRange(method.StrategyStartDate, method.StrategyEndDate, 200);
            StartDate = Method.StrategyStartDate ?? HistoricalData.DataStartDate;
            EndDate   = Method.StrategyEndDate ?? HistoricalData.DataEndDate;
        }
Beispiel #3
0
        private void SelectStrategyButton_Click(object sender, EventArgs e)
        {
            //SelectedStrategy = new CrystalBallStrategy(SelectedSchedule, this.StartDateTimePicker.Value, this.EndDateTimePicker.Value);
            //SelectedStrategy = new AlwaysBuyBasedOnWeekDay(SelectedSchedule, DayOfWeek.Monday, this.StartDateTimePicker.Value, this.EndDateTimePicker.Value);
            //SelectedStrategy = new BuyAccordingToMonth(SelectedSchedule, this.StartDateTimePicker.Value, this.EndDateTimePicker.Value);
            SelectedStrategy = new BasedOnPercentageStrategy(SelectedSchedule, this.StartDateTimePicker.Value, this.EndDateTimePicker.Value);
            SelectedStrategy = new IfUpOverPeriodOfTime(SelectedSchedule, this.StartDateTimePicker.Value, this.EndDateTimePicker.Value);

            InvestmentStrategyLabel.Text = SelectedStrategy.StategyName;

            UpdateStartAnalysisButton();
        }
Beispiel #4
0
        public static void TestStrategy(BaseInvestmentStategy stategy, StockMarketHistoricalData data)
        {
            var startDate = stategy.StrategyStartDate;
            var endDate   = stategy.StrategyEndDate;

            data.SetCalculatedFieldsForDateRange(startDate, endDate);

            var methodEval = new MethodEvaluation(stategy, data);
            var result     = methodEval.StartEvaluation(null, 0, 0);

            result.ToCSVFile();
            result.ToMutedCSVFile();
            var lastDay = result.Data.Last();

            Console.WriteLine();
            Console.WriteLine(stategy.StrategyDescription);
            Console.WriteLine("Cash: " + lastDay.CashOnHand + " Stock: " + lastDay.ValueOfStockOnHand);
        }