Example #1
0
 public PrewarningShowForm(Model.WarningFormulaOne formula)
 {
     InitializeComponent();
     this.Formula = formula;
     this.Text    = formula.计算方法;
     Init();
 }
Example #2
0
        public WarningEntity(DataModel.MarketData md, WarningFormulaOne formula)
        {
            this.MData    = md;
            this.wFormula = formula;

            if (!Program.MatchedDataCache[formula.ID].ContainsKey(md.Code))
            {
                Program.MatchedDataCache[formula.ID].TryAdd(md.Code, new MarketDataExtend(md));
            }

            //if (!Program.MatchedCountCache.ContainsKey(this.wFormula.ID))
            //{
            //    Program.MatchedCountCache.TryAdd(wFormula.ID, new ConcurrentDictionary<string, int>());
            //}

            //if (Program.MatchedCountCache[wFormula.ID].ContainsKey(MData.Code))
            //{
            //    Program.MatchedCountCache[wFormula.ID][MData.Code] += 1;
            //}
            //else
            //{
            //    Program.MatchedCountCache[wFormula.ID].TryAdd(MData.Code, 1);
            //}
            //this.WarningCount = Program.MatchedCountCache[wFormula.ID][MData.Code];
            this.WarningCount = Program.MatchedDataCache[this.wFormula.ID][md.Code].Count;
        }
Example #3
0
        private void Init(Model.WarningFormulaOne wfo)
        {
            var values = Enum.GetValues(typeof(Model.CompareType));

            foreach (var item in values)
            {
                this.comboBoxCompare.Items.Add(CommonUtils.CompareString((Model.CompareType)item));
            }
            this.comboBoxCompare.SelectedIndex = (int)wfo.CompareTypeInfo;

            string[] prices = new string[20];
            for (int i = 0; i < numbersZhCn.Length; i++)
            {
                prices[i]      = string.Format("买{0}价", numbersZhCn[i]);
                prices[i + 10] = string.Format("卖{0}价", numbersZhCn[i]);
            }

            foreach (var item in prices)
            {
                this.comboBox1.Items.Add(item);
                this.comboBox2.Items.Add(item);
                this.comboBox3.Items.Add(item);
            }
            this.comboBox1.SelectedIndex = wfo.FirstSetting.Index + wfo.FirstSetting.Direction * 10;
            this.comboBox2.SelectedIndex = wfo.SecondSetting.Index + wfo.SecondSetting.Direction * 10;
            this.comboBox3.SelectedIndex = wfo.ThirdSetting.Index + wfo.ThirdSetting.Direction * 10;

            this.comboBoxCalType.DataSource    = new char[] { '+', '-', '*', '/' };
            this.comboBoxCalType.SelectedIndex = (int)wfo.ParamCalType;

            this.comboBoxLevel.DataSource    = new string[] { "黄色预警", "红色预警" };
            this.comboBoxLevel.SelectedIndex = (int)wfo.Level;

            this.comboBoxCodesType.DataSource = new string[] { "全订阅", "自定义" };;
            if (wfo.IsSubAll)
            {
                this.comboBoxCodesType.SelectedIndex = 0;
                this.rtbCodes.ReadOnly = true;
            }
            else
            {
                this.comboBoxCodesType.SelectedIndex = 1;
                if (wfo.CodeList != null)
                {
                    this.rtbCodes.Text = string.Join(",", wfo.CodeList);
                }
            }
            this.numericUpDownBig.Value       = wfo.LargeVolume;
            this.numericUpDownParam.Value     = wfo.Param;
            this.numericUpDownFrequency.Value = wfo.Frequency; //预警显示频率
        }
Example #4
0
 public PrewarningAddForm(Model.WarningFormulaOne formula)
 {
     InitializeComponent();
     this.Text = "预警公式编辑";
     Formula   = formula as Model.WarningFormulaOne;
 }
Example #5
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            Model.WarningFormulaOne entity = this.Formula ?? new Model.WarningFormulaOne()
            {
                ID = Guid.NewGuid().ToString()
            };

            if (comboBoxCodesType.SelectedIndex != 0)
            {
                entity.IsSubAll = false;
                List <string> codes = GetCodes();
                if (codes.Count < 1)
                {
                    rtbCodes.Focus();
                    MessageBox.Show("预警列表不能为空。");
                    return;
                }

                entity.CodeList = codes;
            }
            else
            {
                entity.IsSubAll = true;
                entity.CodeList = new List <string>();
            }

            var s1 = comboBox1.SelectedItem.ToString();

            entity.FirstSetting = new Model.BidAskItem()
            {
                Index = GetIndex(s1), Direction = GetDerection(s1)
            };

            var s2 = comboBox2.SelectedItem.ToString();

            entity.SecondSetting = new Model.BidAskItem()
            {
                Index = GetIndex(s2), Direction = GetDerection(s2)
            };

            var s3 = comboBox3.SelectedItem.ToString();

            entity.ThirdSetting = new Model.BidAskItem()
            {
                Index = GetIndex(s3), Direction = GetDerection(s3)
            };

            entity.Param = this.numericUpDownParam.Value;

            entity.CompareTypeInfo = (Model.CompareType)comboBoxCompare.SelectedIndex;

            entity.Level = (Model.WarningLevel)comboBoxLevel.SelectedIndex;

            entity.LargeVolume = this.numericUpDownBig.Value;

            entity.ParamCalType = (Model.CalculateType)comboBoxCalType.SelectedIndex;

            entity.Frequency = this.numericUpDownFrequency.Value;

            if (!Program.WarningFormulas.Contains(entity))
            {
                Program.WarningFormulas.Add(entity);
            }

            var strPreWarning = Cryptor.MD5Encrypt(Program.WarningFormulas.ToJSON());

            Program.accountDataSet.参数.SetParaValue("预警列表", strPreWarning);
            if (this.Formula == null)
            {
                var fm = new PrewarningShowForm(entity);
                fm.Show();

                if (Program.fmPreWarnings == null)
                {
                    Program.fmPreWarnings = new List <PrewarningShowForm>();
                }
                Program.fmPreWarnings.Add(fm);
            }
            this.Close();
        }