Example #1
0
        public MainWindow()
        {
            InitializeComponent();
            Instance = this;

            Title = Title.Put(LocalizedStrings.Str1355);

            const string path = "Data";

            _settingsFile = Path.Combine(path, $"connection{Paths.DefaultSettingsExt}");

            LogManager = new LogManager();
            LogManager.Listeners.Add(new FileLogListener {
                LogDirectory = Path.Combine(path, "Logs")
            });
            LogManager.Listeners.Add(new GuiLogListener(Monitor));

            var entityRegistry = new CsvEntityRegistry(path);

            ConfigManager.RegisterService <IEntityRegistry>(entityRegistry);

            var exchangeInfoProvider = new StorageExchangeInfoProvider(entityRegistry, false);

            ConfigManager.RegisterService <IExchangeInfoProvider>(exchangeInfoProvider);

            var storageRegistry = new StorageRegistry(exchangeInfoProvider)
            {
                DefaultDrive = new LocalMarketDataDrive(Path.Combine(path, "Storage"))
            };

            var snapshotRegistry = new SnapshotRegistry(Path.Combine(path, "Snapshots"));

            Connector = new Connector(entityRegistry.Securities, entityRegistry.PositionStorage, storageRegistry.ExchangeInfoProvider, storageRegistry, snapshotRegistry, new StorageBuffer())
            {
                Adapter =
                {
                    StorageSettings =
                    {
                        DaysLoad = TimeSpan.FromDays(3),
                        Mode     = StorageModes.Snapshot,
                    }
                },
                CheckSteps = true,
            };
            LogManager.Sources.Add(Connector);

            _securitiesWindow = new SecuritiesWindow();
            _ordersWindow     = new OrdersWindow();
            _portfoliosWindow = new PortfoliosWindow();
            _myTradesWindow   = new MyTradesWindow();

            InitConnector(entityRegistry, snapshotRegistry);

            _strategiesWindow = new StrategiesWindow();
            _strategiesWindow.LoadStrategies(path);

            _ordersWindow.MakeHideable();
            _myTradesWindow.MakeHideable();
            _strategiesWindow.MakeHideable();
            _securitiesWindow.MakeHideable();
            _portfoliosWindow.MakeHideable();
        }