コード例 #1
0
        public static List <DescriptiveResult> GetResultStatistics(IEnumerable <DarkLightResults> results)
        {
            List <DescriptiveResult> DescriptiveStats = new List <DescriptiveResult>();
            ArrayList consecWinners = new ArrayList();
            ArrayList consecLosers  = new ArrayList();
            ArrayList Losses        = new ArrayList();
            ArrayList Wins          = new ArrayList();
            ArrayList grossPL       = new ArrayList();
            ArrayList NetPnL        = new ArrayList();
            ArrayList NetProfits    = new ArrayList();
            ArrayList NetLosses     = new ArrayList();
            ArrayList NetPLPerShare = new ArrayList();

            //get summations
            foreach (var result in results)
            {
                consecWinners.Add(result.ConsecWin);
                consecLosers.Add(result.ConsecLose);
                if (result.GrossPL < 0)
                {
                    Losses.Add(result.GrossPL);
                }
                if (result.GrossPL > 0)
                {
                    Wins.Add(result.GrossPL);
                }
                grossPL.Add(result.GrossPL);
                if (result.NetProfitOrLoss < 0)
                {
                    NetLosses.Add(result.NetProfitOrLoss);
                }
                if (result.NetProfitOrLoss > 0)
                {
                    NetProfits.Add(result.NetProfitOrLoss);
                }
                NetPnL.Add(result.NetProfitOrLoss);
                NetPLPerShare.Add(result.NetPerShare);
            }
            //get descriptive stats
            double[]    consecWins      = consecWinners.ToArray(typeof(double)) as double[];
            Descriptive consecWinsStats = new Descriptive(consecWins);

            consecWinsStats.Analyze();
            DescriptiveStats.Add(consecWinsStats.Result);

            double[]    consecLoss      = consecWinners.ToArray(typeof(double)) as double[];
            Descriptive consecLossStats = new Descriptive(consecLoss);

            consecLossStats.Analyze();
            DescriptiveStats.Add(consecLossStats.Result);

            double[]    grossPnL     = consecWinners.ToArray(typeof(double)) as double[];
            Descriptive GrossPLStats = new Descriptive(grossPnL);

            GrossPLStats.Analyze();
            DescriptiveStats.Add(GrossPLStats.Result);

            double[]    lossPL     = consecWinners.ToArray(typeof(double)) as double[];
            Descriptive LoserStats = new Descriptive(lossPL);

            LoserStats.Analyze();
            DescriptiveStats.Add(LoserStats.Result);

            double[]    winPL       = consecWinners.ToArray(typeof(double)) as double[];
            Descriptive WinnerStats = new Descriptive(winPL);

            WinnerStats.Analyze();
            DescriptiveStats.Add(WinnerStats.Result);

            double[]    netLosses      = consecWinners.ToArray(typeof(double)) as double[];
            Descriptive netLossesStats = new Descriptive(netLosses);

            netLossesStats.Analyze();
            DescriptiveStats.Add(netLossesStats.Result);

            double[]    netProfits      = consecWinners.ToArray(typeof(double)) as double[];
            Descriptive netProfitsStats = new Descriptive(netProfits);

            netProfitsStats.Analyze();
            DescriptiveStats.Add(netProfitsStats.Result);

            double[]    netPnL      = consecWinners.ToArray(typeof(double)) as double[];
            Descriptive netPnLStats = new Descriptive(netPnL);

            netPnLStats.Analyze();
            DescriptiveStats.Add(netPnLStats.Result);

            double[]    netPLPerShare      = consecWinners.ToArray(typeof(double)) as double[];
            Descriptive netPLPerShareStats = new Descriptive(netPLPerShare);

            netPLPerShareStats.Analyze();
            DescriptiveStats.Add(netPLPerShareStats.Result);

            return(DescriptiveStats);
        }
コード例 #2
0
 /// <summary>
 /// Percentile
 /// </summary>
 /// <param name="percent">Pecentile, between 0 to 100</param>
 /// <returns>Percentile</returns>
 public double Percentile(double percent)
 {
     return(Descriptive.percentile(sortedData, percent));
 }