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

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

            try {
                Data.VarAnalysis.VarPairData vpd = Data.VarAnalysis.LoadResults(pair);
                optTrigger = vpd.deltaValue;

                Console.WriteLine(pair + ": " + optTrigger.ToString("F8"));

                // todo: check vpd timestamp
                // (if older then 24h then it needs refreshing)
            }
            catch (Exception e) {
                CLI.Manager.PrintWarning("No optimized pair data for " + pair + "!");
            }

            optTrigger *= 50;

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

            SetupRules(optTrigger);

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

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

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

            predictorExtremes = new Data.Predictors.PriceExtremes(pair);
            predictorDX       = new Data.Predictors.DirectionIndex(pair);

            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);

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

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

                predictorDX.Recalculate(tickerList.ToArray());

                if (i % 100 == 0)
                {
                    Utility.ThreadManager.ReportAlive("LowAlts");
                }
            }
        }
예제 #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);
            predictorDX.Recalculate(tickers);

            Utility.TradeTracker.UpdateOpenPosition(pair, buyPrice);
        }