// единичный тест public BotPanel TestBot(OptimazerFazeReport reportFaze, OptimizerReport reportToBot) { if (_primeThreadWorker != null) { return(null); } string botName = NumberGen.GetNumberDeal(StartProgram.IsOsOptimizer).ToString(); List <string> names = new List <string> { botName }; _asyncBotFactory.CreateNewBots(names, _master.StrategyName, _master.IsScript, StartProgram.IsTester); OptimizerServer server = CreateNewServer(reportFaze); List <IIStrategyParameter> parametrs = reportToBot.GetParameters(); BotPanel bot = CreateNewBot(botName, parametrs, parametrs, server, StartProgram.IsTester); DateTime timeStartWaiting = DateTime.Now; while (bot.IsConnected == false) { Thread.Sleep(50); if (timeStartWaiting.AddSeconds(20) < DateTime.Now) { SendLogMessage( OsLocalization.Optimizer.Message10, LogMessageType.Error); return(null); } } server.TestingStart(); timeStartWaiting = DateTime.Now; while (bot.TabsSimple[0].CandlesAll == null || bot.TabsSimple[0].TimeServerCurrent.AddHours(1) < reportFaze.Faze.TimeEnd) { Thread.Sleep(20); if (timeStartWaiting.AddSeconds(20) < DateTime.Now) { break; } } Thread.Sleep(2000); return(bot); }
public OptimizerReport(int fazeUid, string securityName, List <IIStrategyParameter> paramaters) { Uid = NumberGen.GetNumberDeal(StartProgram.IsOsOptimizer); FazeUid = fazeUid; SecurityName = securityName; for (int i = 0; i < paramaters.Count; i++) { StrategyParameters.Add(paramaters[i].GetStringToSave()); } }
/// <summary> /// создать сделку /// </summary> public Position CreatePosition(string botName, Side direction, decimal priceOrder, int volume, OrderPriceType priceType, TimeSpan timeLife, Security security, Portfolio portfolio) { Position newDeal = new Position(); newDeal.Number = NumberGen.GetNumberDeal(); newDeal.Direction = direction; newDeal.State = PositionStateType.Opening; newDeal.AddNewOpenOrder(CreateOrder(direction, priceOrder, volume, priceType, timeLife)); newDeal.NameBot = botName; newDeal.Lots = security.Lot; newDeal.PriceStepCost = security.PriceStepCost; newDeal.PriceStep = security.PriceStep; newDeal.PortfolioValueOnOpenPosition = portfolio.ValueCurrent; return(newDeal); }