Exemplo n.º 1
0
        public MarketGuess()
        {
            ShortPoints = new List <MarketDataPoint>();
            LongPoints  = new List <MarketDataPoint>();

            LocalHigh = 0;
            LocalLow  = double.MaxValue;

            FirstVolume  = new MarketVolume(0);
            SecondVolume = new MarketVolume(0);

            BuyPrice = 0;

            MarketAction       = MarketAction.undefined;
            BoundsMarketAction = MarketAction.withinBounds;
        }
Exemplo n.º 2
0
        static void SimulationAccuracy(List <MarketGuess> guesses)
        {
            Dictionary <string, List <MarketGuess> > SuccessFailures = new Dictionary <string, List <MarketGuess> >();

            #region Classification Success/Failures

            List <MarketGuess> Success       = new List <MarketGuess>();
            List <MarketGuess> Fail          = new List <MarketGuess>();
            List <MarketGuess> Uncertain     = new List <MarketGuess>();
            List <MarketGuess> BoundsSuccess = new List <MarketGuess>();
            List <MarketGuess> BoundsFail    = new List <MarketGuess>();
            List <MarketGuess> Undefined     = new List <MarketGuess>();

            foreach (MarketGuess marketGuess in guesses)
            {
                if (marketGuess.MarketAction == MarketAction.undefined)
                {
                    Undefined.Add(marketGuess);
                }

                else if (marketGuess.MarketAction == MarketAction.buy)
                {
                    if (marketGuess.LongPoints.Count > marketGuess.ShortPoints.Count &&
                        marketGuess.HighestSellPercentage > marketGuess.LowestShortPercentage)
                    {
                        if (marketGuess.BoundsMarketAction == MarketAction.withinBounds)
                        {
                            Success.Add(marketGuess);
                        }
                        else
                        {
                            BoundsFail.Add(marketGuess);
                        }
                    }
                    else if (marketGuess.LongPoints.Count < marketGuess.ShortPoints.Count &&
                             marketGuess.HighestSellPercentage < marketGuess.LowestShortPercentage)
                    {
                        if (marketGuess.BoundsMarketAction == MarketAction.withinBounds)
                        {
                            Fail.Add(marketGuess);
                        }
                        else
                        {
                            BoundsSuccess.Add(marketGuess);
                        }
                    }
                    else
                    {
                        Uncertain.Add(marketGuess);
                    }
                }

                else if (marketGuess.MarketAction == MarketAction.shrt)
                {
                    if (marketGuess.LongPoints.Count < marketGuess.ShortPoints.Count &&
                        marketGuess.HighestSellPercentage < marketGuess.LowestShortPercentage)
                    {
                        if (marketGuess.BoundsMarketAction == MarketAction.withinBounds)
                        {
                            Success.Add(marketGuess);
                        }
                        else
                        {
                            BoundsFail.Add(marketGuess);
                        }
                    }
                    else if (marketGuess.LongPoints.Count > marketGuess.ShortPoints.Count &&
                             marketGuess.HighestSellPercentage > marketGuess.LowestShortPercentage)
                    {
                        if (marketGuess.BoundsMarketAction == MarketAction.withinBounds)
                        {
                            Fail.Add(marketGuess);
                        }
                        else
                        {
                            BoundsSuccess.Add(marketGuess);
                        }
                    }
                    else
                    {
                        Uncertain.Add(marketGuess);
                    }
                }

                else if (marketGuess.MarketAction == MarketAction.doNotTouch)
                {
                    if (Math.Abs(marketGuess.BuyPrice) < 0.001)
                    {
                        Success.Add(marketGuess);
                    }
                    else if (marketGuess.ShortPoints.Count < 5 && marketGuess.LongPoints.Count < 5)
                    {
                        Success.Add(marketGuess);
                    }
                    else if (marketGuess.ShortPoints.Count > 10 || marketGuess.LongPoints.Count > 10)
                    {
                        Fail.Add(marketGuess);
                    }
                    else
                    {
                        Uncertain.Add(marketGuess);
                    }
                }
            }

            SuccessFailures.Add("Success", Success);
            SuccessFailures.Add("Fail", Fail);
            SuccessFailures.Add("Uncertain", Uncertain);
            SuccessFailures.Add("BoundsSuccess", BoundsSuccess);
            SuccessFailures.Add("BoundsFail", BoundsFail);
            SuccessFailures.Add("Undefined", Undefined);

            #endregion

            Dictionary <string, Dictionary <MarketAction, List <MarketGuess> > > BreakDownActions =
                new Dictionary <string, Dictionary <MarketAction, List <MarketGuess> > >();

            #region Action Breakdown

            foreach (KeyValuePair <string, List <MarketGuess> > keyValuePair in SuccessFailures)
            {
                Dictionary <MarketAction, List <MarketGuess> > ActionDict = new Dictionary <MarketAction, List <MarketGuess> >();
                List <MarketGuess> buy          = new List <MarketGuess>();
                List <MarketGuess> shrt         = new List <MarketGuess>();
                List <MarketGuess> noTouch      = new List <MarketGuess>();
                List <MarketGuess> undefined    = new List <MarketGuess>();
                List <MarketGuess> outOfBounds  = new List <MarketGuess>();
                List <MarketGuess> withinBounds = new List <MarketGuess>();
                foreach (MarketGuess marketGuess in keyValuePair.Value)
                {
                    switch (marketGuess.MarketAction)
                    {
                    case MarketAction.buy:
                        buy.Add(marketGuess);
                        break;

                    case MarketAction.shrt:
                        shrt.Add(marketGuess);
                        break;

                    case MarketAction.doNotTouch:
                        noTouch.Add(marketGuess);
                        break;

                    case MarketAction.undefined:
                        undefined.Add(marketGuess);
                        break;
                    }

                    switch (marketGuess.BoundsMarketAction)
                    {
                    case MarketAction.withinBounds:
                        withinBounds.Add(marketGuess);
                        break;

                    case MarketAction.outOfBounds:
                        outOfBounds.Add(marketGuess);
                        break;
                    }
                }
                ActionDict.Add(MarketAction.buy, buy);
                ActionDict.Add(MarketAction.shrt, shrt);
                ActionDict.Add(MarketAction.doNotTouch, noTouch);
                ActionDict.Add(MarketAction.undefined, undefined);
                ActionDict.Add(MarketAction.withinBounds, withinBounds);
                ActionDict.Add(MarketAction.outOfBounds, outOfBounds);

                BreakDownActions.Add(keyValuePair.Key, ActionDict);
            }

            #endregion

            int totalBuy          = 0;
            int totalShort        = 0;
            int totalDoNotTouch   = 0;
            int totalUndefined    = 0;
            int totalWithinBounds = 0;
            int totalOutOfBounds  = 0;
            foreach (KeyValuePair <string, Dictionary <MarketAction, List <MarketGuess> > > action in BreakDownActions)
            {
                foreach (KeyValuePair <MarketAction, List <MarketGuess> > keyValuePair in action.Value)
                {
                    if (keyValuePair.Key == MarketAction.buy)
                    {
                        totalBuy += keyValuePair.Value.Count;
                    }
                    if (keyValuePair.Key == MarketAction.shrt)
                    {
                        totalShort += keyValuePair.Value.Count;
                    }
                    if (keyValuePair.Key == MarketAction.doNotTouch)
                    {
                        totalDoNotTouch += keyValuePair.Value.Count;
                    }
                    if (keyValuePair.Key == MarketAction.undefined)
                    {
                        totalUndefined += keyValuePair.Value.Count;
                    }
                    if (keyValuePair.Key == MarketAction.withinBounds)
                    {
                        totalWithinBounds += keyValuePair.Value.Count;
                    }
                    if (keyValuePair.Key == MarketAction.outOfBounds)
                    {
                        totalOutOfBounds += keyValuePair.Value.Count;
                    }
                }
            }

            logAccuracy.WriteLine("---Parameters---");
            logAccuracy.WriteLine($"Bounds margin:{MarketGuess.highLowBoundsPerc}");
            logAccuracy.WriteLine($"Profit:{MarketGuess.profit}");
            logAccuracy.WriteLine();
            logAccuracy.WriteLine(MarketVolume.OutputVolumeClasses());
            logAccuracy.WriteLine("------");
            logAccuracy.WriteLine();

            logAccuracy.WriteLine($"Guesses: {guesses.Count}");
            logAccuracy.WriteLine();
            logAccuracy.WriteLine($"Successes: {Success.Count}\t{(double)Success.Count / guesses.Count}");
            logAccuracy.WriteLine($"Failures: {Fail.Count}\t{(double)Fail.Count / guesses.Count}");
            logAccuracy.WriteLine($"Uncertain: {Uncertain.Count}\t{(double)Uncertain.Count / guesses.Count}");
            logAccuracy.WriteLine($"BoundsSuccess: {BoundsSuccess.Count}\t{(double)BoundsSuccess.Count / guesses.Count}");
            logAccuracy.WriteLine($"BoundsFail: {BoundsFail.Count}\t{(double)BoundsFail.Count / guesses.Count}");
            logAccuracy.WriteLine($"Undefined: {Undefined.Count}\t{(double)Undefined.Count / guesses.Count}");
            logAccuracy.WriteLine();

            logAccuracy.WriteLine($"Buy: {totalBuy}\t{(double)totalBuy / guesses.Count}");
            logAccuracy.WriteLine($"Short: {totalShort}\t{(double)totalShort / guesses.Count}");
            logAccuracy.WriteLine($"DoNotTouch: {totalDoNotTouch}\t{(double)totalDoNotTouch / guesses.Count}");
            logAccuracy.WriteLine($"Undefined: {totalUndefined}\t{(double)totalUndefined / guesses.Count}");
            logAccuracy.WriteLine($"WithinBounds: {totalWithinBounds}\t{(double)totalWithinBounds / guesses.Count}");
            logAccuracy.WriteLine($"OutOfBounds: {totalOutOfBounds}\t{(double)totalOutOfBounds / guesses.Count}");
            logAccuracy.WriteLine();

            foreach (KeyValuePair <string, Dictionary <MarketAction, List <MarketGuess> > > breakDownAction in BreakDownActions)
            {
                logAccuracy.WriteLine($"{breakDownAction.Key}:");
                foreach (KeyValuePair <MarketAction, List <MarketGuess> > keyValuePair in breakDownAction.Value)
                {
                    logAccuracy.WriteLine($"{keyValuePair.Key} {keyValuePair.Value.Count}");
                }
                logAccuracy.WriteLine();
            }

            foreach (KeyValuePair <string, List <MarketGuess> > keyValuePair in SuccessFailures)
            {
                logAccuracy.WriteLine($"---{keyValuePair.Key}---");
                foreach (MarketGuess marketGuess in keyValuePair.Value)
                {
                    logAccuracy.WriteLine(marketGuess);
                }
            }
        }