Ejemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();
            Instance = this;

            Title = Title.Put(LocalizedStrings.Str1355);

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

            LogManager = new LogManager();
            LogManager.Listeners.Add(new FileLogListener("Data\\sample.log"));
            LogManager.Listeners.Add(new GuiLogListener(Monitor));

            var entityRegistry = new CsvEntityRegistry("Data");

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

            var storageRegistry = ConfigManager.GetService <IStorageRegistry>();

            Connector = new Connector(entityRegistry, storageRegistry);
            LogManager.Sources.Add(Connector);

            InitConnector(entityRegistry);
        }
Ejemplo n.º 2
0
        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()));
        }
Ejemplo n.º 3
0
        public MainWindow()
        {
            InitializeComponent();
            Instance = this;

            Title = Title.Put("Multi connection");

            _ordersWindow.MakeHideable();
            _myTradesWindow.MakeHideable();
            _tradesWindow.MakeHideable();
            _securitiesWindow.MakeHideable();
            _stopOrdersWindow.MakeHideable();
            _portfoliosWindow.MakeHideable();

            var logManager = new LogManager();

            logManager.Listeners.Add(new FileLogListener("sample.log"));

            var entityRegistry = new CsvEntityRegistry("Data");

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

            var storageRegistry = ConfigManager.GetService <IStorageRegistry>();

            SerializationContext.DelayAction = entityRegistry.DelayAction = new DelayAction(entityRegistry.Storage, ex => ex.LogError());

            Connector = new Connector(entityRegistry, storageRegistry);
            logManager.Sources.Add(Connector);

            InitConnector(entityRegistry);
        }
Ejemplo n.º 4
0
        public MainWindow()
        {
            InitializeComponent();
            Instance = this;

            Title = Title.Put("Multi connection");

            _ordersWindow.MakeHideable();
            _myTradesWindow.MakeHideable();
            _tradesWindow.MakeHideable();
            _securitiesWindow.MakeHideable();
            _stopOrdersWindow.MakeHideable();
            _portfoliosWindow.MakeHideable();
            _orderLogWindow.MakeHideable();
            _newsWindow.MakeHideable();

            var path = _defaultDataPath.ToFullPath();

            _settingsFile = Path.Combine(path, "connection.xml");

            var logManager = new LogManager();

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

            HistoryPath.Folder = path;

            var entityRegistry = new CsvEntityRegistry(path);

            var storageRegistry = new StorageRegistry
            {
                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"));

            Connector = new Connector(entityRegistry, storageRegistry, snapshotRegistry);
            logManager.Sources.Add(Connector);

            InitConnector(entityRegistry, snapshotRegistry, nativeIdStorage);
        }
Ejemplo n.º 5
0
        public MainWindow()
        {
            InitializeComponent();
            Instance = this;

            Title = Title.Put("Multi connection");

            _ordersWindow.MakeHideable();
            _myTradesWindow.MakeHideable();
            _tradesWindow.MakeHideable();
            _securitiesWindow.MakeHideable();
            _stopOrdersWindow.MakeHideable();
            _portfoliosWindow.MakeHideable();

            var logManager = new LogManager();

            logManager.Listeners.Add(new FileLogListener("sample.log"));

            var path = _defaultDataPath.ToFullPath();

            HistoryPath.Folder = path;

            var entityRegistry = new CsvEntityRegistry(path);

            ConfigManager.RegisterService(entityRegistry.ProcessorProvider);

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

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

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

            Connector = new Connector(entityRegistry, storageRegistry, snapshotRegistry);
            logManager.Sources.Add(Connector);

            InitConnector(entityRegistry, snapshotRegistry);
        }
Ejemplo n.º 6
0
        public MainWindow()
        {
            InitializeComponent();
            Instance = this;

            Title = Title.Put(LocalizedStrings.Str1355);

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

            LogManager = new LogManager();
            LogManager.Listeners.Add(new FileLogListener("Data\\sample.log"));
            LogManager.Listeners.Add(new GuiLogListener(Monitor));

            var entityRegistry = new CsvEntityRegistry("Data");

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

            var storageRegistry  = ServicesRegistry.StorageRegistry;
            var snapshotRegistry = new SnapshotRegistry(Path.Combine("Data", "Snapshots"));

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

            InitConnector(entityRegistry, snapshotRegistry);
        }
Ejemplo n.º 7
0
        public MainWindow()
        {
            InitializeComponent();
            Instance = this;

            Title = Title.Put("Plaza II");

            _ordersWindow.MakeHideable();
            _ordersLogWindow.MakeHideable();
            _myTradesWindow.MakeHideable();
            _tradesWindow.MakeHideable();
            _securitiesWindow.MakeHideable();
            _portfoliosWindow.MakeHideable();

            const string dataPath = "Data";

            _entityRegistry = new CsvEntityRegistry(dataPath);

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

            _storageRegistry = new StorageRegistry
            {
                DefaultDrive = new LocalMarketDataDrive(dataPath)
            };

            _snapshotRegistry = new SnapshotRegistry(Path.Combine(dataPath, "Snapshots"));

            //AppName.Text = Trader.AppName;

            Tables.SelectedTables = Trader.Tables.Select(t => t.Id);

            _logManager.Sources.Add(Trader);
            _logManager.Listeners.Add(new FileLogListener {
                LogDirectory = "StockSharp_Plaza"
            });
        }
Ejemplo n.º 8
0
        private void InitConnector(CsvEntityRegistry entityRegistry)
        {
            // subscribe on connection successfully event
            Connector.Connected += () =>
            {
                this.GuiAsync(() => ChangeConnectStatus(true));
            };

            // subscribe on connection error event
            Connector.ConnectionError += error => this.GuiAsync(() =>
            {
                ChangeConnectStatus(false);
                MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2959);
            });

            Connector.Disconnected += () => this.GuiAsync(() => ChangeConnectStatus(false));

            // subscribe on error event
            Connector.Error += error =>
            {
                this.GuiAsync(() => MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2955));
            };

            // subscribe on error of market data subscription event
            Connector.MarketDataSubscriptionFailed += (security, msg, error) =>
            {
                this.GuiAsync(() => MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2956Params.Put(msg.DataType, security)));
            };

            Connector.NewSecurity += security => _securitiesWindow.SecurityPicker.Securities.Add(security);

            Connector.NewOrder += order =>
            {
                _ordersWindow.OrderGrid.Orders.Add(order);
                _securitiesWindow.ProcessOrder(order);
            };

            // display order as own volume in quotes window
            Connector.OrderChanged += _securitiesWindow.ProcessOrder;

            // put the registration error into order's table
            Connector.OrderRegisterFailed += _ordersWindow.OrderGrid.AddRegistrationFail;

            Connector.NewMyTrade += _myTradesWindow.TradeGrid.Trades.Add;

            Connector.NewPortfolio += _portfoliosWindow.PortfolioGrid.Portfolios.Add;
            Connector.NewPosition  += _portfoliosWindow.PortfolioGrid.Positions.Add;

            // set market data provider
            _securitiesWindow.SecurityPicker.MarketDataProvider = Connector;

            try
            {
                if (File.Exists(_settingsFile))
                {
                    Connector.Load(new XmlSerializer <SettingsStorage>().Deserialize(_settingsFile));
                }
            }
            catch
            {
            }

            if (Connector.StorageAdapter == null)
            {
                return;
            }

            entityRegistry.Init();

            Connector.StorageAdapter.DaysLoad = TimeSpan.FromDays(3);
            //Connector.StorageAdapter.Load();

            ConfigManager.RegisterService <IExchangeInfoProvider>(new StorageExchangeInfoProvider(entityRegistry));
        }
Ejemplo n.º 9
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();
        }
Ejemplo n.º 10
0
        private void InitConnector(CsvEntityRegistry entityRegistry, SnapshotRegistry snapshotRegistry)
        {
            // subscribe on connection successfully event
            Connector.Connected += () =>
            {
                this.GuiAsync(() => ChangeConnectStatus(true));
            };

            // subscribe on connection error event
            Connector.ConnectionError += error => this.GuiAsync(() =>
            {
                ChangeConnectStatus(false);
                MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2959);
            });

            Connector.Disconnected += () => this.GuiAsync(() => ChangeConnectStatus(false));

            // subscribe on error event
            Connector.Error += error =>
                               this.GuiAsync(() => MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2955));

            // subscribe on error of market data subscription event
            Connector.MarketDataSubscriptionFailed += (security, msg, error) =>
                                                      this.GuiAsync(() => MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2956Params.Put(msg.DataType, security)));

            Connector.NewSecurity += _securitiesWindow.SecurityPicker.Securities.Add;
            Connector.NewTrade    += _tradesWindow.TradeGrid.Trades.Add;

            Connector.NewOrder     += _ordersWindow.OrderGrid.Orders.Add;
            Connector.NewStopOrder += _stopOrdersWindow.OrderGrid.Orders.Add;
            Connector.NewMyTrade   += _myTradesWindow.TradeGrid.Trades.Add;

            Connector.NewPortfolio += _portfoliosWindow.PortfolioGrid.Portfolios.Add;
            Connector.NewPosition  += _portfoliosWindow.PortfolioGrid.Positions.Add;

            // subscribe on error of order registration event
            Connector.OrderRegisterFailed += _ordersWindow.OrderGrid.AddRegistrationFail;
            // subscribe on error of order cancelling event
            Connector.OrderCancelFailed += OrderFailed;

            // subscribe on error of stop-order registration event
            Connector.OrderRegisterFailed += _stopOrdersWindow.OrderGrid.AddRegistrationFail;
            // subscribe on error of stop-order cancelling event
            Connector.StopOrderCancelFailed += OrderFailed;

            // set market data provider
            _securitiesWindow.SecurityPicker.MarketDataProvider = Connector;

            try
            {
                if (File.Exists(_settingsFile))
                {
                    var ctx = new ContinueOnExceptionContext();
                    ctx.Error += ex => ex.LogError();

                    using (new Scope <ContinueOnExceptionContext> (ctx))
                        Connector.Load(new XmlSerializer <SettingsStorage>().Deserialize(_settingsFile));
                }
            }
            catch
            {
            }

            if (Connector.StorageAdapter == null)
            {
                return;
            }

            try
            {
                entityRegistry.Init();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.ToString());
            }

            Connector.StorageAdapter.DaysLoad = TimeSpan.FromDays(3);
            Connector.LookupAll();

            snapshotRegistry.Init();

            ConfigManager.RegisterService <IExchangeInfoProvider>(new StorageExchangeInfoProvider(entityRegistry));
        }
Ejemplo n.º 11
0
        private void InitConnector(CsvEntityRegistry entityRegistry)
        {
            // subscribe on connection successfully event
            Connector.Connected += () =>
            {
                this.GuiAsync(() => ChangeConnectStatus(true));
            };

            // subscribe on connection error event
            Connector.ConnectionError += error => this.GuiAsync(() =>
            {
                ChangeConnectStatus(false);
                MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2959);
            });

            Connector.Disconnected += () => this.GuiAsync(() => ChangeConnectStatus(false));

            // subscribe on error event
            Connector.Error += error =>
                               this.GuiAsync(() => MessageBox.Show(this, error.ToString(), LocalizedStrings.Str2955));

            // subscribe on error of market data subscription event
            Connector.MarketDataSubscriptionFailed += (security, msg) =>
                                                      this.GuiAsync(() => MessageBox.Show(this, msg.Error.ToString(), LocalizedStrings.Str2956Params.Put(msg.DataType, security)));

            Connector.NewSecurities += securities => _securitiesWindow.SecurityPicker.Securities.AddRange(securities);
            Connector.NewTrades     += trades => _tradesWindow.TradeGrid.Trades.AddRange(trades);

            Connector.NewOrders     += orders => _ordersWindow.OrderGrid.Orders.AddRange(orders);
            Connector.NewStopOrders += orders => _stopOrdersWindow.OrderGrid.Orders.AddRange(orders);
            Connector.NewMyTrades   += trades => _myTradesWindow.TradeGrid.Trades.AddRange(trades);

            Connector.NewPortfolios += portfolios => _portfoliosWindow.PortfolioGrid.Portfolios.AddRange(portfolios);
            Connector.NewPositions  += positions => _portfoliosWindow.PortfolioGrid.Positions.AddRange(positions);

            // subscribe on error of order registration event
            Connector.OrdersRegisterFailed     += OrdersFailed;
            Connector.StopOrdersRegisterFailed += OrdersFailed;

            // subscribe on error of order cancelling event
            Connector.OrdersCancelFailed     += OrdersFailed;
            Connector.StopOrdersCancelFailed += OrdersFailed;

            // set market data provider
            _securitiesWindow.SecurityPicker.MarketDataProvider = Connector;

            try
            {
                if (File.Exists(_settingsFile))
                {
                    Connector.Load(new XmlSerializer <SettingsStorage>().Deserialize(_settingsFile));
                }
            }
            catch
            {
            }

            if (Connector.StorageAdapter == null)
            {
                return;
            }

            entityRegistry.Init();

            Connector.StorageAdapter.DaysLoad = TimeSpan.FromDays(3);
            Connector.StorageAdapter.Load();

            ConfigManager.RegisterService <IExchangeInfoProvider>(new ExchangeInfoProvider(entityRegistry));
        }