예제 #1
0
        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
        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
        // 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
        }