Ejemplo n.º 1
0
        /// <summary>
        /// 策略添加按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddStrategy_Click(object sender, RoutedEventArgs e)
        {
            Type         strategyType = (Type)this.cbxStrategyName.SelectedItem;
            Strategy     strategy     = (Strategy)Activator.CreateInstance(strategyType);
            string       instrumentID = this.cbxStrategyInstrumentID.Text.ToString();
            IntervalType intervalType = (IntervalType)Enum.Parse(typeof(IntervalType), this.cbxStrategyIntervalType.Text.ToString());
            int          interval     = int.Parse(this.cbxStrategyInterval.Text);

            //调用参数Form
            using (FormParams fp = new FormParams())
            {
                ////从文本中做参数赋值
                //string ss = "(MaxLoss:1)";
                //foreach (var v in ss.Trim('(', ')').Split(','))
                //{
                //    strategy.SetParameterValue(v.Split(':')[0], v.Split(':')[1]);
                //}
                //策略参数配置
                fp.propertyGrid1.SelectedObject = strategy;
                fp.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
                if (fp.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }
                strategy.Notify("");
            }

            //将策略添加到DictStrategies
            string name = strategyType.Name + "_" + instrumentID + "_" + interval +
                          "_" + intervalType.ToString() + strategy.GetParams();

            this.AddStrategy(strategy, name, instrumentID, interval, intervalType);
        }
 public static IRequest <Form> Create(FormParams formParams)
 {
     if (formParams == FormParams.Book)
     {
         return(new Request <Book>());
     }
     if (formParams == FormParams.Copybook)
     {
         return(new Request <Copybook>());
     }
     return(new Request <Notebook>());
 }
Ejemplo n.º 3
0
        private HttpContent BuildContent()
        {
            if (_content != null)
            {
                return(_content);
            }
            else if (HasFormParams)
            {
                return(new FormUrlEncodedContent(FormParams.Select(x => new KeyValuePair <string, string>(x.Key, x.Value))));
            }

            return(null);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 双击选中策略,修改参数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lvAllStrategy_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (lvAllStrategy.SelectedItem == null)
            {
                return;
            }
            Strategy strategy = (Strategy)lvAllStrategy.SelectedItem;

            using (FormParams fp = new FormParams())
            {
                //策略参数配置
                fp.propertyGrid1.SelectedObject = strategy;
                fp.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
                if (fp.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }
                string name = strategy.Name;
                int    i    = name.IndexOf('(');
                strategy.Name = name.Remove(i) + strategy.GetParams();
            }
        }