Пример #1
0
 void ReceivedAllStrategy(string message)
 {
     // FIXME:
     StrategyDesc sd0 = new StrategyDesc
     {
         Name = "python策略示例",
         Desc = "策略示例",
         Dll = "Stock.Strategy.Python.Rotation.dll",
         Clazz = "Stock.Strategy.Python.Rotation.RotationStrategy",
         Enabled = true,
         Group = 0,
         Date = DateTime.Now
     };
     StrategyDesc sd1 = new StrategyDesc
     {
         Name = "雪球策略",
         Desc = "跟踪雪球策略",
         Dll = "Stock.Strategy.XueQiu.dll",
         Clazz = "Stock.Strategy.XueQiu.TraceXueQiuStrategy",
         Enabled = true,
         Group = 0,
         Date = DateTime.Now
     };
     this.Invoke((MethodInvoker)delegate
     {
         // 从服务器获取策略数据,
         StrategyDesc[] sds = new StrategyDesc[] { sd0, sd1 };  // LoadStrategyList(message);
         InitStrategyMenu(sds.ToArray<StrategyDesc>());
     });
 }
Пример #2
0
        //private StrategyDesc[] LoadStrategyList(String message)
        //{
        //    StrategyDesc[] sd = new StrategyDesc[] { new StrategyDesc() };
        //    string[] item = message.Split(',');
        //    sd[0].Clazz = item[1];  // "Stock.Strategy.RotationB.RotationBStrategy";
        //    sd[0].Dll = item[0];    //"Stock.Strategy.RotationB.dll";
        //    sd[0].Desc = item[3];   // "说明:分级B强势轮动策略";
        //    sd[0].Name = item[2];   // "分级B强势轮动策略";
        //    sd[0].Group = int.Parse(item[4]);
        //    return sd;
        //}
        //private StrategyDesc[] LoadMyStrategyList(String message)
        //{
        //    StrategyDesc[] sd = new StrategyDesc[] { new StrategyDesc() };
        //    // FIXME: 不能运行的情况下, 注释157-161行,取消注释152-156行
        //    //sd[0].clazz = "Stock.Strategy.Python.Rotation.RotationStrategy";
        //    //sd[0].dllPath = "Stock.Strategy.Python.Rotation.dll";
        //    //sd[0].desc = "说明:分级A轮动策略";
        //    //sd[0].name = "T+0 呼吸大法";
        //    //sd[0].group = 1;
        //    string[] item = message.Split(',');
        //    sd[0].Clazz = item[1]; // "Stock.Strategy.RotationB.RotationBStrategy";
        //    sd[0].Dll = item[0]; //"Stock.Strategy.RotationB.dll";
        //    sd[0].Desc = item[3]; // "说明:分级B强势轮动策略";
        //    sd[0].Name = item[2]; // "分级B强势轮动策略";
        //    sd[0].Group = int.Parse(item[4]);
        //    return sd;
        //}
        private void InitListView(StrategyDesc[] sds)
        {
            // StrategyDesc[] sds = LoadMyStrategyList(message);
            foreach (StrategyDesc sd in sds)
            {
                this.AddStrategyToListView(sd);
            }

            // this.listView1.Items[0].Selected = true;

               this.panel1.Controls.Add((Control)this.listView1.Items[0].Tag);
        }
Пример #3
0
 /// <summary>
 /// 初始化右键菜单策略
 /// </summary>
 private void InitStrategyMenu(StrategyDesc[] sds)
 {
     foreach (var sd in sds)
     {
         ToolStripMenuItem tsmi = new ToolStripMenuItem();
         tsmi.Text = sd.Name;
         tsmi.Tag = sd;
         tsmi.Click += new EventHandler(AddStrategyToListView);
         if(sd.Group ==0)
             this.miFfjjStrategy.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { tsmi});
         else if(sd.Group == 1)
             this.miGpStrategy.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { tsmi});
     }
 }
Пример #4
0
 private void AddStrategyToListView(StrategyDesc sd)
 {
     BaseStrategy strategy = (BaseStrategy)DllUtils.CreateInstance<IStrategy>(sd.Dll, sd.Clazz);
     strategy.Id = sd.Id;
     strategy.Init();
     StrategyManager.Instance.AddMyStrategy(strategy);
     System.Windows.Forms.ListViewItem lvi = new System.Windows.Forms.ListViewItem(new string[] {
         sd.Name,
         sd.Desc}, -1);
     lvi.Group = this.listView1.Groups[sd.Group];
     lvi.Tag = strategy.Control;
     this.listView1.Items.Add(lvi);
 }