コード例 #1
0
ファイル: MathUtil.cs プロジェクト: HongSeokHwan/legacy
        public static double GetPnLRatePerYear(ProfitAndLossResult input)
        {
            double totalYear = (input.EndDate - input.StartDate).Days / 365;
            double totalPnLRate = GetPnLRateTotal(input);

            return totalPnLRate / totalYear;
        }
コード例 #2
0
ファイル: MathUtil.cs プロジェクト: HongSeokHwan/legacy
        public static DrawDown GetMaxDrawDown(ProfitAndLossResult input)
        {
            DateTime curDate = input.StartDate;

            DrawDown mdd = new DrawDown();

            while (curDate <= input.EndDate)
            {
                if (input.IsExistDate(curDate))
                {
                    DrawDown dd = GetDrawDown(curDate, input.EndDate, input);

                    if (dd.Value < mdd.Value)
                    {
                        mdd = dd;
                    }
                }
                curDate = curDate.AddDays(1);
            }
            return mdd;
        }
コード例 #3
0
        public ProfitAndLossResult GetResult(AssetWeightLog log)
        {
            ProfitAndLossResult result = new ProfitAndLossResult(_opSet.GetKey(), this.Input.InitInvestAmount);
            result.CalculatePnL(log, _readyData);
            result.AvgPnLPerYear = MathUtil.GetAvgPnLPerYear(result);
            result.PPM = MathUtil.GetYearPnLPerMDD(result);

            return result;
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: HongSeokHwan/legacy
 void AddNewResult_Raw(ExperimentData experimentData, ProfitAndLossResult result)
 {
     _result.Add(result);
     UpdateDataGridView(experimentData);
 }
コード例 #5
0
ファイル: Form1.cs プロジェクト: HongSeokHwan/legacy
 public void HandleResult(ExperimentData experimentData, ProfitAndLossResult result)
 {
     this.Invoke(new AddNewResult(AddNewResult_Raw), new object[] { experimentData, result });
     //this.Invoke(new AddNewResult(AddNewResult_Raw), result);
 }
コード例 #6
0
ファイル: MathUtil.cs プロジェクト: HongSeokHwan/legacy
        static DrawDown GetDrawDown(DateTime startDate, DateTime endDate, ProfitAndLossResult input)
        {
            DateTime curDate = startDate;

            double startDateCumPnL = input.GetCumPnL(startDate);
            DrawDown dd = new DrawDown();
            dd.StartDate = startDate;
            dd.EndDate = endDate;

            while (curDate <= endDate)
            {
                if (input.IsExistDate(curDate))
                {
                    double curDateCumPnL = input.GetCumPnL(curDate);
                    double diff = curDateCumPnL - startDateCumPnL;

                    if (diff <= dd.Value)
                    {
                        //update
                        dd.Value = diff;
                        dd.EndDate = curDate;
                    }
                }
                curDate = curDate.AddDays(1);
            }

            return dd;
        }
コード例 #7
0
ファイル: MathUtil.cs プロジェクト: HongSeokHwan/legacy
 public static double GetYearPnLPerMDD(ProfitAndLossResult input)
 {
     DrawDown mdd = GetMaxDrawDown(input);
     double pnl = GetAvgPnLPerYear(input);
     return Math.Abs(pnl / mdd.Value);
 }
コード例 #8
0
ファイル: MathUtil.cs プロジェクト: HongSeokHwan/legacy
 public static double GetPnLRateTotal(ProfitAndLossResult input)
 {
     return input.TotalPnL / input.InitInvestAmount;
 }
コード例 #9
0
ファイル: MathUtil.cs プロジェクト: HongSeokHwan/legacy
 public static double GetAvgPnLPerYear(ProfitAndLossResult input)
 {
     double totalYear = (input.EndDate - input.StartDate).Days / 365;
     double pnlPerYear = input.TotalPnL / totalYear;
     return pnlPerYear;
 }