示例#1
0
        public void SetTInstrument(StrategyQTP strategy, TInstrument target)
        {
            this.strategy = strategy;
            this.target = target;

            barsBuffer = new List<Bar>();
            ticksBuffer = new List<Tick>();
        }
示例#2
0
        public static StrategyQTP CreateFromDB(string id, NLog nlog)
        {
            // Read config file
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            CRUD.ConnectionString = config.ConnectionStrings.ConnectionStrings["QTP_DB"].ConnectionString.ToString();

            TStrategy t = CRUD.GetTStrategy(id, nlog);

            Assembly assembly = Assembly.LoadFrom(@"QTP.Domain.dll");
            Type type = assembly.GetType(string.Format("QTP.Domain.{0}", t.RiskMClass));

            RiskM trader = (RiskM)Activator.CreateInstance(type);

            StrategyQTP s = new StrategyQTP(t, trader, nlog);
            
            return s;
        }
示例#3
0
        static void Main(string[] args)
        {
            // process args of program
            if (args.Length == 0)
            {
                System.Console.WriteLine("[错误] 无运行参数");
                System.Console.Read();
                return;
            }

            // Open NLog file
            NLog nlog = new NLog();
            if (!nlog.Open(args[0]))
            {
                System.Console.WriteLine("[错误] 打开日志文件失败");
                System.Console.Read();
                return;
            }

            // 设置中断命令处理程序(即清理并停止策略循环运行)。
            SetConsoleCtrlHandler(new HandlerRoutine(ConsoleCtrlCheck), true);

            // Create Strategy
            currentStrategy = StrategyFactory.CreateFromDB(args[0], nlog);
            if (currentStrategy == null)
            {
                System.Console.WriteLine("[错误] 未能创建策略类");
                System.Console.Read();
                return;
            }

            // Start it
            currentStrategy.Start();

            System.Console.WriteLine("策略已停止运行");
            System.Console.Read();
        }
示例#4
0
文件: RiskM.cs 项目: wsjiabao/autodz
 public void SetStrategy(StrategyQTP s)
 {
     strategy = s;
 }