public MarketOrderSafeStorage(int ordersTimeout, int intervalToUpdateMils, BacktestServerProxy.RobotContext robotContext) { this.ordersTimeout = ordersTimeout; this.intervalToUpdateMils = intervalToUpdateMils; this.robotContext = robotContext; }
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 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>()); }
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)); }
public override void Initialize(BacktestServerProxy.RobotContext grobotContext, CurrentProtectedContext protectedContext) { base.Initialize(grobotContext, protectedContext); // проверка настроек графиков if (Graphics.Count == 0) { Logger.DebugFormat("MultiIndexRobot: настройки графиков не заданы"); return; } if (Graphics.Count > 1) { Logger.DebugFormat("MultiIndexRobot: настройки графиков должны описывать один тикер / один ТФ"); return; } ticker = Graphics[0].a; lastBids = new Dictionary<string, double>(); foreach (var ind in DiversToEnter) { ind.Initialize(); ind.lastIndicies = new List<double>(); ind.indexPeaks = new List<Cortege3<decimal, int, decimal>>(); } foreach (var protectSets in DiversToProtect) foreach (var ind in protectSets.IndexList) { ind.Initialize(); ind.lastIndicies = new List<double>(); ind.indexPeaks = new List<Cortege3<decimal, int, decimal>>(); } foreach (var filter in filters) filter.Initialize(); candles = new List<CandleData>();//CandlesInIndexHistory); packer = new CandlePacker(Graphics[0].b); packerDiverProtect = diversToProtect.Count == 0 ? null : diversToProtect.ToDictionary(d => d, d => new CandlePacker(d.timeframe)); candles4Protect = diversToProtect.Count == 0 ? null : diversToProtect.ToDictionary(d => d, d => new List<CandleData>()); tickerNames = DalSpot.Instance.GetTickerNames(); randomGener = new Random(DateTime.Now.Millisecond); lastBidLists = new Dictionary<string, List<double>>(); // по каждой валютной паре найти макс. количество отсчетов (из формулы индекса) InitLastBidLists(); if (CalcDealChainStat) { dealChainStat = new List<int>(); } }
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; } }
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); }
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); }
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)); }
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); }
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); }
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(); }
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); }
public override void Initialize(BacktestServerProxy.RobotContext grobotContext, CurrentProtectedContext protectedContext) { base.Initialize(grobotContext, protectedContext); // проверка настроек графиков if (Graphics.Count == 0) { Logger.DebugFormat("FiboLevelRobot: настройки графиков не заданы"); return; } if (Graphics.Count > 1) { Logger.DebugFormat("FiboLevelRobot: настройки графиков должны описывать один тикер / один ТФ"); return; } ticker = Graphics[0].a; timeframe = Graphics[0].b; packer = new CandlePacker(timeframe); // расчет вспомогательных переменных side = PriceB > PriceA ? 1 : PriceB < PriceA ? -1 : 0; minuteCandlesCount = 0; minuteCandlesBodiesSum = 0; lastBid = 0; timeOfLastCandle = new DateTime(1972, 1, 1); // получить категории торговых сигналов if (ShouldMakePresignals) { currentPresignalPrimeTimes = presignalMinutesToClose.ToList(); var signals = grobotContext is BacktestServerProxy.RobotContextLive ? ((BacktestServerProxy.RobotContextLive)grobotContext).GetAuthoredTradeSignals() : new List<PaidService>(); if (signals.Count > 0) { var signal = signals[0]; if (signal != null) { authoredTradeSignalCategory = signal.Id; Logger.InfoFormat("Робот {0} - отправляет сигналы {1} ({2})", GetUniqueName(), authoredTradeSignalCategory, signal.Comment); } } } // поставить на графике точечки AddRobotHintOnPriceUpdated("A", 0, priceA, TimeOfA); AddRobotHintOnPriceUpdated("B", 0, priceB, TimeOfB); }
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(); }
public override void Initialize(BacktestServerProxy.RobotContext grobotContext, CurrentProtectedContext protectedContext) { base.Initialize(grobotContext, protectedContext); tickers = Graphics.Select(g => g.a).ToArray(); }
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) }); } }
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>(); }