public MarketOrderSafeStorage(int ordersTimeout, int intervalToUpdateMils,
                               BacktestServerProxy.RobotContext robotContext)
 {
     this.ordersTimeout        = ordersTimeout;
     this.intervalToUpdateMils = intervalToUpdateMils;
     this.robotContext         = robotContext;
 }
Esempio n. 2
0
 public override void Initialize(BacktestServerProxy.RobotContext grobotContext,
                                 Contract.Util.BL.CurrentProtectedContext protectedContextx)
 {
     base.Initialize(grobotContext, protectedContextx);
     packers   = Graphics.ToDictionary(g => g.a, g => new CandlePacker(g.b));
     digitsDen = (int)Math.Pow(10, roundDigits);
 }
 public MarketOrderSafeStorage(int ordersTimeout, int intervalToUpdateMils,
     BacktestServerProxy.RobotContext robotContext)
 {
     this.ordersTimeout = ordersTimeout;
     this.intervalToUpdateMils = intervalToUpdateMils;
     this.robotContext = robotContext;
 }
Esempio n. 4
0
        public override void Initialize(BacktestServerProxy.RobotContext grobotContext, CurrentProtectedContext xprotectedContext)
        {
            base.Initialize(grobotContext, xprotectedContext);
            // проверка настроек графиков
            if (Graphics.Count == 0)
            {
                Logger.DebugFormat("MultiIndexRobot: настройки графиков не заданы");
                return;
            }
            if (Graphics.Count > 1)
            {
                Logger.DebugFormat("MultiIndexRobot: настройки графиков должны описывать один тикер / один ТФ");
                return;
            }
            ticker    = Graphics[0].a;
            timeframe = Graphics[0].b;

            lastBids = new Dictionary <string, double>();

            foreach (var ind in IndexList)
            {
                ind.Initialize();
                ind.lastIndicies = new List <double>();
                ind.indexPeaks   = new List <Cortege3 <decimal, int, decimal> >();
            }

            candles      = new List <CandleData>();
            packer       = new CandlePacker(Graphics[0].b);
            tickerNames  = DalSpot.Instance.GetTickerNames();
            randomGener  = new Random(DateTime.Now.Millisecond);
            lastBidLists = new Dictionary <string, List <double> >();
            // по каждой валютной паре найти макс. количество отсчетов (из формулы индекса)
            InitLastBidLists();
        }
Esempio n. 5
0
        public override void Initialize(BacktestServerProxy.RobotContext grobotContext, CurrentProtectedContext protectedContext)
        {
            base.Initialize(grobotContext, protectedContext);

            depoWarning   = HighWaterMark * (1 - PercentYellow / 100M);
            depoStopout   = HighWaterMark * (1 - PercentRed / 100M);
            lastCheckTime = null;
            lastState     = StateCode.OK;
            orderStorage  = new MarketOrderSafeStorage(1000, 10 * 1000, grobotContext);
        }
Esempio n. 6
0
 public override void Initialize(BacktestServerProxy.RobotContext robotContext, CurrentProtectedContext protectedContext)
 {
     base.Initialize(robotContext, protectedContext);
     if (Graphics.Count == 0)
     {
         return;
     }
     packers     = Graphics.ToDictionary(g => g.a, g => new CandlePacker(g.b));
     pointCost   = Graphics.ToDictionary(g => g.a, g => DalSpot.Instance.GetAbsValue(g.a, 1M));
     lastCandles = Graphics.ToDictionary(g => g.a, g => new List <CandleData>());
 }
Esempio n. 7
0
        public override void Initialize(BacktestServerProxy.RobotContext robotContext, CurrentProtectedContext protectedContext)
        {
            base.Initialize(robotContext, protectedContext);

            if (Graphics.Count == 0)
            {
                return;
            }
            packers                = Graphics.ToDictionary(g => g.a, g => new CandlePacker(g.b));
            pointCost              = Graphics.ToDictionary(g => g.a, g => DalSpot.Instance.GetAbsValue(g.a, 1M));
            storedCandles          = Graphics.ToDictionary(g => g.a, g => new RestrictedQueue <CandleData>(CandlesToDetermineAverage));
            bollingerSignalHistory = Graphics.ToDictionary(g => g.a, g => new RestrictedQueue <int>(CandlesAfter));
        }
Esempio n. 8
0
        public override void Initialize(BacktestServerProxy.RobotContext grobotContext, CurrentProtectedContext protectedContext)
        {
            base.Initialize(grobotContext, protectedContext);
            // проверка настроек графиков
            if (Graphics.Count == 0)
            {
                Logger.DebugFormat("Atracotes MTS: настройки графиков не заданы");
                return;
            }
            if (Graphics.Count > 1)
            {
                Logger.DebugFormat("Atracotes MTS: настройки графиков должны описывать один тикер / один ТФ");
                return;
            }
            ticker = Graphics[0].a;

            lastBids = new Dictionary <string, double>();

            foreach (var ind in IndexList)
            {
                ind.Initialize();
                ind.lastIndicies = new List <double>();
                ind.indexPeaks   = new List <Cortege3 <decimal, int, decimal> >();
            }

            candles = new List <CandleData>();
            packer  = new CandlePacker(Graphics[0].b);

            var levels = FiboLevels.ToFloatArrayUniform();

            fiboLevels.Clear();
            foreach (var level in levels)
            {
                try
                {
                    fiboLevels.Add(level);
                }
                catch (FormatException)
                {
                }
            }

            tickerNames  = DalSpot.Instance.GetTickerNames();
            randomGener  = new Random(DateTime.Now.Millisecond);
            lastBidLists = new Dictionary <string, List <double> >();
            // по каждой валютной паре найти макс. количество отсчетов (из формулы индекса)
            InitLastBidLists();
            //RobotTradeState = TradeState.НетПозиций;
            stopsOnPositions = StopPositionsState.Незащищены;
            TerminalLog.Instance.SaveRobotLog("Atracotes MTS: RobotTradeState = " + RobotTradeState);
        }
Esempio n. 9
0
        public override void Initialize(BacktestServerProxy.RobotContext robotContext, CurrentProtectedContext protectedContext)
        {
            base.Initialize(robotContext, protectedContext);

            if (Graphics.Count == 0)
            {
                return;
            }
            packers            = Graphics.ToDictionary(g => g.a, g => new CandlePacker(g.b));
            pointCost          = Graphics.ToDictionary(g => g.a, g => DalSpot.Instance.GetAbsValue(g.a, 1M));
            candlesStoredCount = Math.Max(MovAvgPeriod, MomentumPeriod);
            storedCandles      = Graphics.ToDictionary(g => g.a, g => new List <CandleData>(candlesStoredCount));
            storedMovAvg       = Graphics.ToDictionary(g => g.a, g => new List <int>(3));
        }
Esempio n. 10
0
 /// <summary>
 /// переопределяется почти в каждом роботе
 /// </summary>
 public override void Initialize(BacktestServerProxy.RobotContext robotContext, CurrentProtectedContext protectedContext)
 {
     // обязательная строка
     base.Initialize(robotContext, protectedContext);
     // для робота не заданы торгуемый инструмент (иинструменты) / таймфрейм (таймфреймы)
     if (Graphics.Count == 0)
     {
         return;
     }
     packers        = Graphics.ToDictionary(g => g.a, g => new CandlePacker(g.b));
     pointCost      = Graphics.ToDictionary(g => g.a, g => DalSpot.Instance.GetAbsValue(g.a, 1M));
     patternCandles = Graphics.ToDictionary(g => g.a, g => new List <CandleData>());
     storedCandles  = Graphics.ToDictionary(g => g.a, g => new RestrictedQueue <CandleData>(CandlesToDetermineAverage));
 }
Esempio n. 11
0
 public override void Initialize(BacktestServerProxy.RobotContext robotContext, CurrentProtectedContext protectedContext)
 {
     base.Initialize(robotContext, protectedContext);
     if (Graphics.Count == 0)
     {
         return;
     }
     ticker    = Graphics[0].a;
     pointCost = DalSpot.Instance.GetAbsValue(ticker, 1f);
     if (BrickSizeAuto)
     {
         lastPrices = new RestrictedQueue <CandleData>(AutosizePeriod);
     }
     packer = new CandlePacker(Graphics[0].b);
 }
Esempio n. 12
0
 public override void Initialize(BacktestServerProxy.RobotContext grobotContext, CurrentProtectedContext protectedContext)
 {
     base.Initialize(grobotContext, protectedContext);
     // проверка настроек графиков
     if (Graphics.Count == 0)
     {
         Logger.DebugFormat("StopRobot: настройки графиков не заданы");
         return;
     }
     if (Graphics.Count > 1)
     {
         Logger.DebugFormat("StopRobot: настройки графиков должны описывать один тикер / один ТФ");
         return;
     }
     ticker = Graphics[0].a;
     packer = new CandlePacker(Graphics[0].b);
 }
Esempio n. 13
0
 public override void Initialize(BacktestServerProxy.RobotContext grobotContext,
                                 Contract.Util.BL.CurrentProtectedContext protectedContextx)
 {
     base.Initialize(grobotContext, protectedContextx);
     if (Graphics.Count == 0)
     {
         Logger.DebugFormat("TailBodyRobot: настройки графиков не заданы");
         return;
     }
     if (Graphics.Count > 1)
     {
         Logger.DebugFormat("TailBodyRobot: настройки графиков должны описывать один тикер / один ТФ");
         return;
     }
     packer    = new CandlePacker(Graphics[0].b);
     ticker    = Graphics[0].a;
     pointCost = 1.0 / DalSpot.Instance.GetPrecision10(ticker);
 }
Esempio n. 14
0
 public override void Initialize(BacktestServerProxy.RobotContext grobotContext,
                                 Contract.Util.BL.CurrentProtectedContext protectedContextx)
 {
     base.Initialize(grobotContext, protectedContextx);
     if (Graphics.Count == 0)
     {
         Logger.DebugFormat("CaymanRobot: настройки графиков не заданы");
         return;
     }
     if (Graphics.Count > 1)
     {
         Logger.DebugFormat("CaymanRobot: настройки графиков должны описывать один тикер / один ТФ");
         return;
     }
     packer = new CandlePacker(Graphics[0].b);
     ticker = Graphics[0].a;
     ReadCaymanHistory();
 }
Esempio n. 15
0
 public override void Initialize(BacktestServerProxy.RobotContext grobotContext, CurrentProtectedContext protectedContext)
 {
     base.Initialize(grobotContext, protectedContext);
     // проверка настроек графиков
     if (Graphics.Count == 0)
     {
         Logger.DebugFormat("FibonacciRobot: настройки графиков не заданы");
         return;
     }
     if (Graphics.Count > 1)
     {
         Logger.DebugFormat("FibonacciRobot: настройки графиков должны описывать один тикер / один ТФ");
         return;
     }
     ticker     = Graphics[0].a;
     packer     = new CandlePacker(Graphics[0].b);
     candles    = new List <CandleData>();
     pointPrice = 1M / DalSpot.Instance.GetPrecision10(ticker);
     //fiboDistanceAbs = FiboReachDistancePoint*pointPrice;
     markedZigZagPivots = new List <int>();
 }
Esempio n. 16
0
        public override void Initialize(BacktestServerProxy.RobotContext grobotContext, Contract.Util.BL.CurrentProtectedContext protectedContextx)
        {
            base.Initialize(grobotContext, protectedContextx);
            if (Graphics.Count == 0)
            {
                Logger.DebugFormat("RobotMA: настройки графиков не заданы");
                return;
            }
            if (Graphics.Count > 1)
            {
                Logger.DebugFormat("RobotMA: настройки графиков должны описывать один тикер / один ТФ");
                return;
            }
            packer     = new CandlePacker(Graphics[0].b);
            ticker     = Graphics[0].a;
            stopLoss   = null;
            takeProfit = null;


            extremumRangeQueue = new RestrictedQueue <CandleData>(ExtremumRange * 2 + 1);
            extremumQueue      = new RestrictedQueue <Cortege3 <float, bool, DateTime> >(4);
        }
Esempio n. 17
0
        public override void Initialize(BacktestServerProxy.RobotContext grobotContext,
                                        Contract.Util.BL.CurrentProtectedContext protectedContextx)
        {
            base.Initialize(grobotContext, protectedContextx);
            if (Graphics.Count == 0)
            {
                Logger.DebugFormat("CounterNettoRobot: настройки графиков не заданы");
                return;
            }

            packers = Graphics.ToDictionary(g => g.a, g => new CandlePacker(g.b));

            if (!File.Exists(NettoFilePath))
            {
                Logger.DebugFormat("CounterNettoRobot: файл не найден");
                return;
            }
            nettoReader = new StreamReader(NettoFilePath, Encoding.ASCII);
            NettoRecord.ReadHeader(nettoReader);
            cur  = NettoRecord.ReadNext(nettoReader);
            next = NettoRecord.ReadNext(nettoReader);
        }
        public override void Initialize(BacktestServerProxy.RobotContext grobotContext)
        {
            base.Initialize(grobotContext);
            // проверка настроек графиков
            if (Graphics.Count == 0)
            {
                Logger.DebugFormat("OscillatorBasedRobot: настройки графиков не заданы");
                return;
            }
            if (Graphics.Count > 1)
            {
                Logger.DebugFormat("OscillatorBasedRobot: настройки графиков должны описывать один тикер / один ТФ");
                return;
            }
            ticker = Graphics[0].a;

            try
            {
                formulaResolver      = new ExpressionResolver(indexFormula);
                formulaVariableNames = formulaResolver.GetVariableNames();
                lastBids             = new Dictionary <string, float>();
                lastIndicies         = new RestrictedQueue <float>(CandlesInIndexHistory);
                candles      = new RestrictedQueue <CandleData>(CandlesInIndexHistory);
                packer       = new CandlePacker(Graphics[0].b);
                indexPeaks   = new List <Cortege3 <float, int, float> >();
                tickerNames  = DalSpot.Instance.GetTickerNames();
                randomGener  = new Random(DateTime.Now.Millisecond);
                lastBidLists = new Dictionary <string, RestrictedQueue <float> >();
                // по каждой валютной паре найти макс. количество отсчетов (из формулы индекса)
                InitLastBidLists();
            }
            catch (Exception ex)
            {
                Logger.ErrorFormat("OscillatorBasedRobot: ошибка парсинга выражения \"{0}\": {1}",
                                   indexFormula, ex);
                formulaResolver = null;
            }
        }
Esempio n. 19
0
        public override void Initialize(BacktestServerProxy.RobotContext grobotContext, CurrentProtectedContext protectedContextx)
        {
            base.Initialize(grobotContext, protectedContextx);
            if (Graphics.Count == 0)
            {
                Logger.DebugFormat("RobotMA: настройки графиков не заданы");
                return;
            }
            if (Graphics.Count > 1)
            {
                Logger.DebugFormat("RobotMA: настройки графиков должны описывать один тикер / один ТФ");
                return;
            }
            packer    = new CandlePacker(Graphics[0].b);
            ticker    = Graphics[0].a;
            maDifSign = 0;
            queueSlow = new RestrictedQueue <float>(RangeSlowMA);
            queueFast = new RestrictedQueue <float>(RangeFastMA);

            virtualDeal    = null;
            prevSign       = 0;
            virtualResults = new RestrictedQueue <float>(PeriodVirtualResults);
        }
Esempio n. 20
0
        public override void Initialize(BacktestServerProxy.RobotContext grobotContext, Contract.Util.BL.CurrentProtectedContext gprotectedContext)
        {
            base.Initialize(grobotContext, gprotectedContext);

            if (Graphics.Count == 0)
            {
                return;
            }

            plannedOrders = new List <Cortege3 <string, int, DateTime> >();
            rnd           = new Random();
            packers       = Graphics.ToDictionary(g => g, g => new CandlePacker(g.b));

            // перевести рабочие часы в удобную форму
            workHours.Clear();
            var workHoursParts = WorkingHours.ToIntArrayUniform();

            for (var i = 0; i < workHoursParts.Length / 2; i++)
            {
                var start = workHoursParts[i * 2];
                var end   = workHoursParts[i * 2 + 1];
                if (end == start || end < start)
                {
                    continue;
                }

                workHours.Add(new Cortege2 <int, int>(start, end));
            }

            if (workHours.Count < 1)
            {
                workHours.Clear();
                workHours.AddRange(new List <Cortege2 <int, int> > {
                    new Cortege2 <int, int>(10, 18), new Cortege2 <int, int>(20, 22)
                });
            }
        }
Esempio n. 21
0
        public override void Initialize(BacktestServerProxy.RobotContext grobotContext, CurrentProtectedContext protectedContext)
        {
            base.Initialize(grobotContext, protectedContext);

            initMessageWasSent = false;
            timeSinceUpdate.Touch();

            ordersFromMt4.ExtractAll(1000 * 10);
            ordersFromMt4Received = false;
            sentRequests.ExtractAll(1000 * 10);

            // стартовать прослушку порта
            try
            {
                var e = new IPEndPoint(IPAddress.Parse(hostMt4), portOwn);
                client = new UdpClient(e);
                client.BeginReceive(ReceiveCallback, null);
            }
            catch (ArgumentOutOfRangeException)
            {
                errorMessage = string.Format("MT4 транслятор: порт ({0}) задан неверно. Допустимый диапазон: {1} - {2}",
                                             portOwn, IPEndPoint.MinPort, IPEndPoint.MaxPort);
                client = null;
                return;
            }
            catch (Exception ex)
            {
                client       = null;
                errorMessage = string.Format("MT4 транслятор: ошибка прослушивания порта ({0}): {1}",
                                             portOwn, ex.Message);
            }

            // стратовать поток отправки команд
            commandSendThread = new Thread(CommandSendRoutine);
            commandSendThread.Start();
        }
Esempio n. 22
0
 public override void Initialize(BacktestServerProxy.RobotContext grobotContext, CurrentProtectedContext protectedContext)
 {
     base.Initialize(grobotContext, protectedContext);
     tickers = Graphics.Select(g => g.a).ToArray();
 }
Esempio n. 23
0
 public override void Initialize(BacktestServerProxy.RobotContext grobotContext, CurrentProtectedContext protectedContextx)
 {
     base.Initialize(grobotContext, protectedContextx);
 }