private Connector MainPanel_OnCreateConnector(string path)
        {
            //HistoryPath.Folder = path;

            var entityRegistry = new CsvEntityRegistry(path);

            var exchangeInfoProvider = new StorageExchangeInfoProvider(entityRegistry, false);

            ConfigManager.RegisterService <IExchangeInfoProvider>(exchangeInfoProvider);

            var storageRegistry = new StorageRegistry(exchangeInfoProvider)
            {
                DefaultDrive = new LocalMarketDataDrive(path)
            };

            ConfigManager.RegisterService <IEntityRegistry>(entityRegistry);
            ConfigManager.RegisterService <IStorageRegistry>(storageRegistry);
            // ecng.serialization invoke in several places IStorage obj
            ConfigManager.RegisterService(entityRegistry.Storage);

            INativeIdStorage nativeIdStorage = new CsvNativeIdStorage(Path.Combine(path, "NativeId"))
            {
                DelayAction = entityRegistry.DelayAction
            };

            ConfigManager.RegisterService(nativeIdStorage);

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

            return(new Connector(entityRegistry.Securities, entityRegistry.PositionStorage, exchangeInfoProvider, storageRegistry, snapshotRegistry, new StorageBuffer()));
        }
示例#2
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();
        }