Exemple #1
0
        ///// <summary>
        ///// пример
        ///// </summary>
        ///// <param name="args"></param>
        //override public void Do(string[] args)
        //{
        //    //TradeConsole.ConsoleSetSize();
        //    //TradeConsole.LogAssemblyInfo(assemblies);
        //    //список доступных команд
        //    TradeConsole.ConsoleWriteCommands();
        //    Initialize();
        //    SetupStrategy(args);
        //    base.Do(args);
        //}

        /// <summary>
        /// пример переопределения
        /// Program.Sample1.Initialize()
        /// </summary>
        override public void Initialize()
        {
            Console.WriteLine("Program.Sample1.Initialize()");
            marketDataProvider     = new MarketDataProvider();
            rawTradingDataProvider = new RawTradingDataProvider(DefaultLogger.Instance);
            symbolsDataProvider    = new SymbolsDataProvider();
            traderBase             = new TraderBase(new SmartComOrderManager());
            adapter = new SmartComAdapter();

            SmartComHandlers.Instance.Add <_IStClient_DisconnectedEventHandler>(IsDisconnected);
            SmartComHandlers.Instance.Add <_IStClient_ConnectedEventHandler>(IsConnected);

            sendItemTrade = new SendItemOnTrade(TradingData.Instance, DefaultLogger.Instance);
            //ObservableQueue<Order> orderQueue = TradingData.Instance.Get<ObservableQueue<Order>>();
            //ObservableHashSet<Order> orderQueue = TradingData.Instance.Get<ObservableHashSet<Order>>();

            //sendItemOrder = new SendItemOnOrder(TradingData.Instance.Get<ObservableQueue<Order>>());
            //Отправляем данные клиентам
            {
                //sendItemBar.AddItemHandler(TradeConsole.ConsoleWriteLineBar);
                sendItemTrade.AddItemHandler(TradeConsole.ConsoleWriteLineTrade);
                //senderItemOrder.AddedItemHandler(TradeHubStarter.sendOrder);

                if (AppSettings.GetValue <bool>("SignalHub"))
                {
                    //отправляем через signalR
                    //sendItemBar.AddItemHandler(TradeHubStarter.sendBar);
                    sendItemTrade.AddItemHandler(TradeHubStarter.sendTrade);
                }
            }
        }
        public void Setup()
        {
            this.symbolsDataContext = new SymbolDataContext();
            this.stServerSingleton  = new StServerMockSingleton();
            this.handlers           = new SmartComHandlersDatabase();
            this.binder             = new SmartComBinder(this.stServerSingleton.Instance, this.handlers, new NullLogger());

            this.provider = new SymbolsDataProvider(this.handlers, this.symbolsDataContext, new NullLogger());
            this.binder.Bind();

            this.stServer = (StServerClassMock)this.stServerSingleton.Instance;
        }
Exemple #3
0
        ///// <summary>
        ///// пример
        ///// </summary>
        ///// <param name="args"></param>
        //override public void Do(string[] args)
        //{
        //    //TradeConsole.ConsoleSetSize();
        //    //TradeConsole.LogAssemblyInfo(assemblies);
        //    //список доступных команд
        //    TradeConsole.ConsoleWriteCommands();
        //    Initialize();
        //    SetupStrategy(args);
        //    base.Do(args);
        //}

        /// <summary>
        /// пример переопределения
        /// BackTest Sample1 Initialize()
        /// </summary>
        override public void Initialize()
        {
            Console.WriteLine("BackTest.Sample1.Initialize()");
            marketDataProvider     = new MarketDataProvider();
            rawTradingDataProvider = new RawTradingDataProvider(DefaultLogger.Instance);
            symbolsDataProvider    = new SymbolsDataProvider();
            orderManager           = new TRL.Emulation.BacktestOrderManager(TradingData.Instance, DefaultLogger.Instance);
            //private static SmartComAdapter adapter =
            //    new SmartComAdapter();
            traderBase = new TraderBase(orderManager);
            //new TraderBase(new SmartComOrderManager());
            //strategySettings = new StrategySettings(1,
            //    "ReversMaOnBar strategy",
            //    AppSettings.GetStringValue("Portfolio"),
            //    AppSettings.GetStringValue("Symbol"),
            //    AppSettings.GetValue<double>("Amount"));
            //barSettings = new BarSettings(
            //    strategySettings,
            //    strategySettings.Symbol,
            //    AppSettings.GetValue<int>("Interval"),
            //    AppSettings.GetValue<int>("Period"));
            //assemblies = { "Interop.SmartCOM3Lib.dll", "TRL.Common.dll", "TRL.Connect.Smartcom.dll" };
        }