static void Main(string[] args)
        {
            TradingData.Instance.Get <ICollection <Strategy> >().Add(strategy);

            //BarSettings barSettings = new BarSettings(strategy, "RIH4", 3600, 3);
            BarSettings barSettings = new BarSettings(strategy, "SPFB.RTS-3.14", 3600, 3);

            TradingData.Instance.Get <ICollection <BarSettings> >().Add(barSettings);

            BreakOutOnBar breakOnBar =
                new BreakOutOnBar(strategy,
                                  TradingData.Instance,
                                  SignalQueue.Instance,
                                  DefaultLogger.Instance);

            StopLossOnBar stopLossOnBar =
                new StopLossOnBar(strategy,
                                  100,
                                  TradingData.Instance,
                                  SignalQueue.Instance,
                                  DefaultLogger.Instance);

            TakeProfitOnBar takeProfitOnBar =
                new TakeProfitOnBar(strategy,
                                    100,
                                    TradingData.Instance,
                                    SignalQueue.Instance,
                                    DefaultLogger.Instance);


            ITransaction importBars =
                new ImportBarsTransaction(TradingData.Instance.Get <ObservableCollection <Bar> >(),
                                          "bars.txt");

            importBars.Execute();
            while (true)
            {
                try
                {
                    string command = Console.ReadLine();

                    if (command == "stop")
                    {
                        break;
                    }

                    if (command == "pnl")
                    {
                        Console.WriteLine(String.Format("Реализованный профит и лосс составляет {0} пунктов",
                                                        TradingData.Instance.GetProfitAndLossPoints(strategy)));
                    }
                }
                catch (System.Runtime.InteropServices.COMException e)
                {
                    DefaultLogger.Instance.Log(e.Message);
                }
            }
        }
Beispiel #2
0
 private void InitHandler()
 {
     StopLossOnBar handler =
         new StopLossOnBar(this.strategyHeader,
                           this.points,
                           this.tradingData,
                           this.signalQueue,
                           new NullLogger());
 }
Beispiel #3
0
        //private static string[] assemblies = { "Interop.SmartCOM3Lib.dll", "TRL.Common.dll", "TRL.Connect.Smartcom.dll" };

        /// <summary>
        /// пример
        /// </summary>
        /// <param name="args"></param>
        public void SetupStrategy(string[] args)
        {
            //TradingData.Instance.Get<ICollection<Strategy>>().Add(strategyHeader);
            //TradingData.Instance.Get<ICollection<BarSettings>>().Add(barSettings);
            //TradingData.Instance.Get<ICollection<ProfitPointsSettings>>().Add(ppSettings);
            //TradingData.Instance.Get<ICollection<TakeProfitOrderSettings>>().Add(poSettings);
            //TradingData.Instance.Get<ICollection<StopPointsSettings>>().Add(spSettings);
            //TradingData.Instance.Get<ICollection<StopLossOrderSettings>>().Add(soSettings);

            //SMASettings smaSettings = new SMASettings(strategyHeader, 7, 14);
            int         maf         = AppSettings.GetValue <int>("MaFast");
            int         mas         = AppSettings.GetValue <int>("MaSlow");
            SMASettings smaSettings = new SMASettings(strategyHeader, maf, mas);

            TradingData.Instance.Get <ICollection <SMASettings> >().Add(smaSettings);

            //MakeRangeBarsOnTick updateBarsHandler;
            updateBarsHandler = new MakeRangeBarsOnTick(barSettings,
                                                        new TimeTracker(),
                                                        TradingData.Instance,
                                                        DefaultLogger.Instance);

            //IndicatorOnBar2Ma indicatorsOnBar;
            indicatorsOnBar = new IndicatorOnBar2Ma(strategyHeader,
                                                    TradingData.Instance,
                                                    SignalQueue.Instance,
                                                    DefaultLogger.Instance);

            indicatorsOnBar.AddMa1Handler(TradeConsole.ConsoleWriteLineValueDouble);
            indicatorsOnBar.AddMa2Handler(TradeConsole.ConsoleWriteLineValueDouble);
            indicatorsOnBar.AddCrossUpHandler(TradeConsole.ConsoleWriteLineValueBool);
            indicatorsOnBar.AddCrossDnHandler(TradeConsole.ConsoleWriteLineValueBool);

            //Отправляем данные клиентам
            {
                //SetupHubHandlers();
                if (AppSettings.GetValue <bool>("SignalHub"))
                {
                    //отправляем через signalR
                    indicatorsOnBar.AddMa1Handler(TradeHubStarter.sendValueDouble1);
                    indicatorsOnBar.AddMa2Handler(TradeHubStarter.sendValueDouble2);
                    indicatorsOnBar.AddCrossUpHandler(TradeHubStarter.sendValueBool);
                    indicatorsOnBar.AddCrossDnHandler(TradeHubStarter.sendValueBool);

                    //reversHandler.AddMa1Handler(TradeHubStarter.sendIndicator1);
                    //reversHandler.AddMa2Handler(TradeHubStarter.sendIndicator2);
                }
                else
                {
                    Console.WriteLine(String.Format("SignalHub is off"));
                }
            }

            //ReversMaOnBar reversHandler =
            reversHandler = new ReversMaOnBar(strategyHeader,
                                              TradingData.Instance,
                                              SignalQueue.Instance,
                                              DefaultLogger.Instance)
            {
                IndicatorsOnBar = indicatorsOnBar
            };

            double pp = AppSettings.GetValue <double>("ProfitPoints");

            //TakeProfitOnBar takeProfitOnBar =
            takeProfitOnBar =
                new TakeProfitOnBar(strategyHeader,
                                    200,
                                    TradingData.Instance,
                                    SignalQueue.Instance,
                                    DefaultLogger.Instance);

            //StopLossOnBar stopLossOnBar =
            stopLossOnBar =
                new StopLossOnBar(strategyHeader,
                                  100,
                                  TradingData.Instance,
                                  SignalQueue.Instance,
                                  DefaultLogger.Instance);
        }