Esempio n. 1
0
        public override void Setup(bool simulate = false)
        {
            GUI.GUIManager.AddStrategyScreenPair(this.pair);

            // ----------------------------------

            SetupRules();

            // ----------------------------------

            // Check file if this has been bought already
            double openPos = Utility.TradeTracker.GetOpenPosition(pair);

            LastBuyTime  = Utility.TradeTracker.GetOpenPositionBuyTime(pair);
            openPosition = openPos;

            TickerChangedEventArgs lastTicker = Data.Store.GetLastTicker(pair);

            if (lastTicker == null)
            {
                throw new Exception("Couldn't build timeframe model for " + pair + " - no tickers available");
            }

            predictorExtremes = new Data.Predictors.PriceExtremes(pair);
            predictorMeanRev  = new Data.Predictors.MeanReversion(pair, 10800);
            predictorADX      = new Data.Predictors.ADX(pair);
            predictorVolume   = new Data.Predictors.Volume(pair, 300, 3600);

            TickerChangedEventArgs[] tickers = Data.Store.GetTickerData(pair);
            if (tickers == null)
            {
                throw new Exception("Couldn't build predictor history for " + pair + " - no tickers available");
            }

            predictorExtremes.Update(tickers);
            predictorVolume.Recalculate(tickers);
            predictorMeanRev.Recalculate(tickers);

            List <TickerChangedEventArgs> tickerList = new List <TickerChangedEventArgs>();

            for (int i = 0; i < tickers.Length; i++)
            {
                tickerList.Add(tickers[i]);

                predictorADX.Recalculate(tickerList.ToArray());

                if (i % 100 == 0)
                {
                    Utility.ThreadManager.ReportAlive("MeanRevADX");
                }
            }
        }
Esempio n. 2
0
        public override void UpdatePredictors()
        {
            TickerChangedEventArgs lastTicker = Data.Store.GetLastTicker(pair);
            double lastPrice = lastTicker.MarketData.PriceLast;
            double buyPrice  = lastTicker.MarketData.OrderTopBuy;
            double sellPrice = lastTicker.MarketData.OrderTopSell;

            TickerChangedEventArgs[] tickers = Data.Store.GetTickerData(pair);
            if (tickers == null)
            {
                throw new Exception("Data store returned NULL tickers for pair " + pair);
            }

            predictorExtremes.Update(tickers);
            predictorMeanRev.Recalculate(tickers);
            predictorADX.Recalculate(tickers);

            Utility.TradeTracker.UpdateOpenPosition(pair, buyPrice);

            GUI.GUIManager.SetPairSummary(this.pair, tickers, lastTicker.MarketData.Volume24HourBase);
        }