private void ResumeArbitrageForm() { FormStrategyResume frmResume = new FormStrategyResume(); if (frmResume.HasResumeStrategy("商品套利策略")) { frmResume.delegate_GetAllStrategyName = new delegate_getallstrategyname(GetAllStrategy); List <StrategyContext> arContext = frmResume.GetStrategyContext("商品套利策略"); foreach (StrategyContext oStrategy in arContext) { FormArbitrage frmArbitrage = new FormArbitrage(); frmArbitrage.delegate_Init = new delete_init(this.axHSQuanTrade1.Init); frmArbitrage.delegate_GetParams = new delegate_getstrategyparams(this.axHSQuanTrade1.GetStrategyParamInfo); frmArbitrage.delegate_GetAllStrategyName = new delegate_getallstrategyname(GetAllStrategy); frmArbitrage.delegate_AddrunStrategy = new delegate_AddRunStrategy(axHSQuanTrade1.AddRunStrategy); frmArbitrage.del_SetStrategyParam = new delegate_SetStrategyParam(axHSQuanTrade1.SetStrategyParam); frmArbitrage.del_GetStrategyParam = new delete_getValues(axHSQuanTrade1.GetParamValue); frmArbitrage.m_oStrategyManager = this.stragegymanager; frmArbitrage.del_GetStrategyContext = new delegate_GetStrategyContext(axHSQuanTrade1.GetStrategyContext); frmArbitrage.del_SetStrategyContext = new delegate_SetStrategyContext(axHSQuanTrade1.SetStrategyContext); frmArbitrage.del_StopStrategy = new delete_stop(axHSQuanTrade1.StopStrategy); frmArbitrage.Init(RegisterOcxMsgChannel); frmArbitrage.MdiParent = this; frmArbitrage.ResumeStrategy(oStrategy); frmArbitrage.Show(); } } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { int nt = comboBox1.SelectedIndex; if (nt == -1) { return; } string name = comboBox1.Items[nt].ToString(); dataGridView1.Columns.Clear(); //检查此策略是否存在上次未运行完毕 FormStrategyResume frmResume = new FormStrategyResume(); if (frmResume.HasResumeStrategy(name)) { frmResume.delegate_GetAllStrategyName = this.delegate_GetAllStrategyName; if (DialogResult.Yes == frmResume.ShowDialog()) { StrategyContext oStrategy = null; if (frmResume.GetResumeStrategyCase(frmResume.ResumeStrategyId, ref oStrategy)) { m_sStrategyId = oStrategy.Uid; dataGridView1.Columns.Add("col0", "参数名"); dataGridView1.Columns.Add("col1", "参数值"); dataGridView1.Columns.Add("col2", "说明"); dataGridView1.Columns[0].ReadOnly = true; dataGridView1.Columns[2].ReadOnly = true; for (int i = 0; i < oStrategy.Params.Count; i++) { StrategyParam _param = oStrategy.Params[i]; DataGridViewRow oRow = new DataGridViewRow(); DataGridViewCell oCell0, oCell1, oCell2; if (0 == _param.ParamName.CompareTo("涨停类型")) { oCell0 = new DataGridViewTextBoxCell(); oCell0.Value = _param.ParamName; DataGridViewCellStyle oCell0Style = new DataGridViewCellStyle(); oCell0Style.BackColor = SystemColors.Control; DataGridViewComboBoxCell oCellCmb = new DataGridViewComboBoxCell(); oCellCmb.Items.Add("0"); oCellCmb.Items.Add("1"); oCellCmb.Value = "0"; oCell1 = oCellCmb; oCell2 = new DataGridViewTextBoxCell(); oCell2.Value = "0,普通涨停; 1,一字涨停"; } else if (0 == _param.ParamName.CompareTo("退出信号为指令价或收盘价")) { oCell0 = new DataGridViewTextBoxCell(); oCell0.Value = _param.ParamName; DataGridViewComboBoxCell oCellCmb = new DataGridViewComboBoxCell(); oCellCmb.Items.Add("0"); oCellCmb.Items.Add("1"); oCellCmb.Value = "0"; oCell1 = oCellCmb; oCell2 = new DataGridViewTextBoxCell(); oCell2.Value = "0,指令价; 1,收盘价"; } else { oCell0 = new DataGridViewTextBoxCell(); oCell0.Value = _param.ParamName; oCell1 = new DataGridViewTextBoxCell(); oCell1.Value = _param.ParamValue; oCell2 = new DataGridViewTextBoxCell(); oCell2.Value = ""; } oRow.Cells.Add(oCell0); oRow.Cells.Add(oCell1); oRow.Cells.Add(oCell2); dataGridView1.Rows.Add(oRow); } //resume open postion for (int i = 0; i < oStrategy.Postions.Count; i++) { ContractPostion oPos = oStrategy.Postions[i]; ListViewItem oItem = new ListViewItem(new string[] { oPos.OpenTime, oPos.ContractCode, oPos.ContractName, (0 == oPos.Direction ? "买入" : "卖出"), oPos.HighPrice.ToString(), oPos.OpenPrice.ToString(), oPos.Postion.ToString(), (oPos.Postion * oPos.OpenPrice).ToString() }); this.lstTradeRec.Items.Add(oItem); } } } else { m_sStrategyId = Guid.NewGuid().ToString(); OnInitStrategyParams(name); } } else { m_sStrategyId = Guid.NewGuid().ToString(); OnInitStrategyParams(name); } }