コード例 #1
0
ファイル: StrategyQTP.cs プロジェクト: wsjiabao/autodz
        private int messageInterval = 40;       // 30s
        #endregion

        #region Public methods

        public StrategyQTP(TStrategy s, RiskM t, NLog log)
        {
            strategyT = s;

            t.SetStrategy(this);
            risk = t;
            
            this.log = log;

            monitors = new Dictionary<string, Monitor>();
        }
コード例 #2
0
ファイル: CRUD.cs プロジェクト: jiangyimin/QTP
        public static TStrategy GetTStrategy(string id)
        {
            TStrategy t = new TStrategy();

            t = MySqlHelper.ExecuteObject<TStrategy>(ConnectionString, string.Format("SELECT * FROM Strategy WHERE Id={0}", id));

            t.Pool = GetTStrategyPool(t.PoolId);
            t.Parse();          // parse fields

            t.Instruments = GetTStrategyInstruments(t.PoolId);

            //t.Positions = MySqlHelper.ExecuteObjects<TPosition>(ConnectionString, string.Format("SELECT * FROM Position WHERE StrategyId={0}", id)); 

            return t;
        }
コード例 #3
0
ファイル: CRUD.cs プロジェクト: wsjiabao/autodz
        public static TStrategy GetTStrategy(string id, NLog log)
        {
            TStrategy t = new TStrategy();

            try
            {
                using (SqlConnection connection = new SqlConnection(ConnectionString))
                {
                    SqlCommand command = new SqlCommand(string.Format("SELECT * FROM Strategy WHERE Id={0}", id), connection);
                    command.Connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        t.Id = (int)reader["Id"];
                        t.Name = (string)reader["Name"];
                        t.GMID = (string)reader["GMID"];
                        t.RiskMClass = (string)reader["RiskMClass"];
                        t.PoolId = (int)reader["PoolId"];
                        t.Args = (string)reader["Args"];
                        t.MDMode = (int)reader["MDMode"];
                    }
                    command.Connection.Close();
                }

                using (SqlConnection connection = new SqlConnection(ConnectionString))
                {
                    SqlCommand command = new SqlCommand("SELECT * FROM Login", connection);
                    command.Connection.Open();
                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        t.UserName = (string)reader["UserName"];
                        t.Password = (string)reader["Password"];
                    }
                    command.Connection.Close();
                }

                t.Instruments = GetTInstruments(t.PoolId);
                t.Positions = GetTPositions(t.Id);
            }
            catch 
            {
                log.WriteError("Read TStrategies");
            }

            return t;
        }
コード例 #4
0
ファイル: StrategyUC.cs プロジェクト: jiangyimin/QTP
        public StrategyUC(TStrategy strategy, Control parent)
        {
            InitializeComponent();

            this.parent = parent;
            this.strategy = strategy;

            // Display information
            lblName.Text = strategy.Name;

            // groupMonitor
            //lblClassName1.Text = string.Format("监控: {0}", strategyMonitorClassName);
            //lblParameter1.Text = string.Format("参数: {0}", strategy.MonitorClassParsString);
            lblNum.Text = string.Format("监控数量:{0}", strategy.Instruments.Count);

            // groupRiskM
            //lblClassName2.Text = string.Format("资管: {0}", strategy.RiskMClassName);
            //lblParameter2.Text = string.Format("参数: {0}", strategy.RiskMClassParsString);
            lblTradeChannel.Text = string.Format("交易通道:{0}", strategy.TradeChannelName);
        }
コード例 #5
0
ファイル: MyStrategy.cs プロジェクト: jiangyimin/QTP
        // Create
        public MyStrategy(TStrategy s, TLogin login)
        {
            strategyT = s;
            this.gmLogin = login;

            // pm manager
            pm = (PoolManager)Activator.CreateInstance(strategyT.Pool.ManagerType, this, strategyT.Pool);
            // monitors
            TAInfo info = new TAInfo(strategyT.TAInfoParameters);           
            monitors = new Dictionary<string, Monitor>();
            foreach (TInstrument ins in strategyT.Instruments)
            {
                Monitor monitor = new Monitor(this, ins, info, strategyT.DLLName);

                symbols += ins.Symbol + ",";
                monitors.Add(ins.Symbol, monitor);

                if (monitor.Target.Symbol == pm.SymbolBench)
                    monitor.IsBench = true;
            }

            // RiskM
            riskM = new RiskM(this, strategyT.RiskMInfoParameters);

            // heartTimer
            heartTimer = new System.Timers.Timer();
            heartTimer.Elapsed += new System.Timers.ElapsedEventHandler(heartTimer_Elapsed);
            heartTimer.Interval = 1000;     // 1s
        }