Beispiel #1
0
        public Model(Func <IChartView> create_chart_cb)
        {
            try
            {
                Shutdown                = new CancellationTokenSource();
                Exchanges               = new ExchangeContainer();
                Coins                   = new CoinDataList();
                Funds                   = new FundContainer();
                Bots                    = new BotContainer(this);
                PriceData               = new PriceDataMap(Shutdown.Token);
                Charts                  = new ChartContainer(create_chart_cb);
                Indicators              = new IndicatorContainer();
                SelectedOpenOrders      = new ObservableCollection <Order>();
                SelectedCompletedOrders = new ObservableCollection <OrderCompleted>();
                SelectedTransfers       = new ObservableCollection <Transfer>();
                EditTradeContexts       = new List <EditTradeContext>();

                // Enable settings auto save after everything is up and running
                SettingsData.Settings.AutoSaveOnChanges = true;

                AllowTradesChanged += HandleAllowTradesChanged;
                BackTestingChange  += HandleBackTestingChange;
            }
            catch
            {
                Shutdown?.Cancel();
                Dispose();
                throw;
            }
        }
Beispiel #2
0
        public Simulation(IEnumerable <Exchange> exchanges, PriceDataMap price_data_map, BotContainer bots)
        {
            m_sw_main_loop = new Stopwatch();
            Exchanges      = new Dictionary <string, SimExchange>();
            PriceData      = price_data_map;
            Bots           = bots;

            // Create a SimExchange for each exchange
            Clock = StartTime;
            foreach (var exch in exchanges)
            {
                Exchanges[exch.Name] = new SimExchange(this, exch, price_data_map);
            }

            // Ensure the first update to the price data after creating the simulation
            // resets all instrument's cached data
            UpdatePriceData(force_invalidate: true);
        }