public void Save(MonteCarloSimulationDto dto)
 {
     if (dto.IsNew)
     {
         MonteCarloSimulation monteCarloSimulation = dto.MapTo <MonteCarloSimulation>();
         int id = this._repository.InsertAndGetId(monteCarloSimulation);
         this.RunSimulationEnqueue(new MonteCarloSimulationDto()
         {
             Id = id
         });
     }
     else
     {
         MonteCarloSimulation monteCarloSimulation = this._repository.Get(dto.Id);
         dto.MapTo(monteCarloSimulation);
     }
 }
        public void RunSimulation(MonteCarloSimulationDto dto)
        {
            MonteCarloSimulation sim = _repository.Get(dto.Id);

            sim.MapTo(dto);
            List <Trade>  sample  = this._tradeRepository.GetAll().Where(x => x.TradingAccountId == dto.TradingAccountId && x.ExitReason != TradeExitReasons.None).ToList();
            List <Market> markets = this._marketRepository.GetAll().Where(x => x.Active).ToList();

            dto.Simulate(sample, markets, this._consoleHubProxy);
            dto.MapTo(sim);
        }