Ejemplo n.º 1
0
        public static double GetPnLRatePerYear(ProfitAndLossResult input)
        {
            double totalYear = ((double)(input.EndDate - input.StartDate).Days) / 365.00;
            double totalPnLRate = GetPnLRateTotal(input);

            return totalPnLRate / totalYear;
        }
Ejemplo n.º 2
0
        public void HandleResult(SimCaseResultOverview experimentData, ProfitAndLossResult result)
        {
            String fileName = String.Format("pnl_{0}.csv", result.Key);
            CsvUtil.CsvOut(fileName, result);

            DrawDown mdd = MathUtil.GetMaxDrawDown(result);
            double pnLRateTotal = MathUtil.GetPnLRateTotal(result);
            double pnlRatePerYear = MathUtil.GetPnLRatePerYear(result);
            double ppm = MathUtil.GetPPM(result);
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        public ProfitAndLossResult GetResult(AssetRateDataLog log)
        {
            ProfitAndLossResult result = new ProfitAndLossResult(_opSet.GetKey(), this.Input.InitInvestAmount);
            result.CalculatePnL(log, _readyData);

            return result;
        }
Ejemplo n.º 5
0
 void AddNewResult_Raw(SimCaseResultOverview overview, ProfitAndLossResult result)
 {
     _result.Add(result);
        // UpdateDataGridView(experimentData);
     UpdateOverview(overview);
 }
Ejemplo n.º 6
0
 public void HandleResult(SimCaseResultOverview experimentData, ProfitAndLossResult result)
 {
     this.Invoke(new AddNewResult(AddNewResult_Raw), new object[] { experimentData, result });
     //this.Invoke(new AddNewResult(AddNewResult_Raw), result);
 }
Ejemplo n.º 7
0
 ProfitAndLossResult CalculatePnL(AssetRateDataLog log, MarketDataSet marketData)
 {
     ProfitAndLossResult pnl = new ProfitAndLossResult(String.Format("{0}", this.Name), this.InputData.InitInvestAmount);
     pnl.CalculatePnL(log, marketData);
     return pnl;
 }
Ejemplo n.º 8
0
 public static double GetPPM(ProfitAndLossResult input)
 {
     DrawDown mdd = GetMaxDrawDown(input);
     double pnl = GetAvgPnLPerYear(input);
     return pnl / Math.Abs(mdd.Value);
 }
Ejemplo n.º 9
0
 public static double GetPnLRateTotal(ProfitAndLossResult input)
 {
     return input.TotalPnL / input.InitInvestAmount;
 }
Ejemplo n.º 10
0
 public static double GetAvgPnLPerYear(ProfitAndLossResult input)
 {
     double totalYear = ((double) (input.EndDate - input.StartDate).Days) / 365.00;
     double pnlPerYear = input.TotalPnL / totalYear;
     return pnlPerYear;
 }
Ejemplo n.º 11
0
        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;
        }