private void InitializMarketData()
        {
            m_quoteDataSource.Clear();

            try
            {
                List <USeInstrumentDetail> instrumentDetailList = m_orderDriver.QueryInstrumentDetail();
                if (instrumentDetailList == null)
                {
                    return;
                }

                List <USeInstrument> instrumentList = (from e in instrumentDetailList
                                                       orderby e.Instrument.InstrumentCode
                                                       select e.Instrument).ToList();
                foreach (USeInstrument instrument in instrumentList)
                {
                    MarketDataViewModel marketModel = new MarketDataViewModel(instrument);
                    m_quoteDataSource.Add(marketModel);
                }

                m_quoterDriver.Subscribe(instrumentList);
            }
            catch (Exception ex)
            {
                Debug.Assert(false, ex.Message);
            }
        }
        public USeMarketData ConvertModelData(MarketDataViewModel data_model)
        {
            USeMarketData market_data = new USeMarketData();

            if (data_model == null)
            {
                return(market_data);
            }

            market_data.Instrument         = data_model.Instrument;
            market_data.LastPrice          = data_model.LastPrice;
            market_data.AskPrice           = data_model.AskPrice;
            market_data.BidPrice           = data_model.BidPrice;
            market_data.OpenPrice          = data_model.OpenPrice;
            market_data.ClosePrice         = data_model.ClosePrice;
            market_data.HighPrice          = data_model.HighPrice;
            market_data.LowPrice           = data_model.LowPrice;
            market_data.PreClosePrice      = data_model.PreClosePrice;
            market_data.PreSettlementPrice = data_model.PreSettlementPrice;

            //随机一个AskSize和BidSize
            Random ran         = new Random();
            int    randAskSize = ran.Next(6, 23);
            int    randBidSize = ran.Next(8, 20);

            market_data.AskSize = randAskSize;
            market_data.BidSize = randBidSize;

            return(market_data);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 更换品种。
        /// </summary>
        /// <param name="product"></param>
        private void ChangegProduct(string product)
        {
            m_dataSource.Clear();
            if (string.IsNullOrEmpty(product))
            {
                return;
            }

            try
            {
                List <USeInstrumentDetail> instrumentDetailList = USeManager.Instance.OrderDriver.QueryInstrumentDetail(product);
                if (instrumentDetailList == null)
                {
                    return;
                }

                List <USeInstrument> instrumentList = (from e in instrumentDetailList
                                                       orderby e.Instrument.InstrumentCode
                                                       select e.Instrument).ToList();
                foreach (USeInstrument instrument in instrumentList)
                {
                    MarketDataViewModel marketModel = new MarketDataViewModel(instrument);
                    m_dataSource.Add(marketModel);
                }

                USeManager.Instance.QuoteDriver.Subscribe(instrumentList);
            }
            catch (Exception ex)
            {
                Debug.Assert(false, ex.Message);
            }
        }
        private void button_LESSANY_Click(object sender, EventArgs e)
        {
            if (this.textBox_ADDLESSNUM.Text == "")
            {
                return;
            }

            MarketDataViewModel marketDataModel = this.gridQuote.Rows[this.gridQuote.CurrentCell.RowIndex].DataBoundItem as MarketDataViewModel;

            PublichMarketDataLess(ConvertModelData(marketDataModel), System.Convert.ToInt32(this.textBox_ADDLESSNUM.Text));
        }
        private void QuoteDriver_OnMarketDataChanged(object sender, USeMarketDataChangedEventArgs e)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new EventHandler <USeMarketDataChangedEventArgs>(QuoteDriver_OnMarketDataChanged), sender, e);
                return;
            }

            MarketDataViewModel marketModel = m_quoteDataSource.FirstOrDefault(p => p.Instrument == e.MarketData.Instrument);

            if (marketModel != null)
            {
                marketModel.Update(e.MarketData);
            }
        }
Exemplo n.º 6
0
        private void gridQuote_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex < 0)
            {
                return;
            }

            MarketDataViewModel dataModel = this.gridQuote.Rows[e.RowIndex].DataBoundItem as MarketDataViewModel;

            Debug.Assert(dataModel != null);
            if (e.ColumnIndex == this.Column_LastPrice.Index)
            {
                SetPriceCellForeColor(e.CellStyle, dataModel.LastPrice, dataModel.PreSettlementPrice);
            }
            else if (e.ColumnIndex == this.Column_NetChange.Index)
            {
                SetPriceCellForeColor(e.CellStyle, dataModel.NetChange);
            }
            else if (e.ColumnIndex == this.Column_PctChange.Index)
            {
                SetPriceCellForeColor(e.CellStyle, dataModel.PctChange);
            }
            else if (e.ColumnIndex == this.Column_BidPrice.Index)
            {
                SetPriceCellForeColor(e.CellStyle, dataModel.BidPrice, dataModel.PreSettlementPrice);
            }
            else if (e.ColumnIndex == this.Column_AskPrice.Index)
            {
                SetPriceCellForeColor(e.CellStyle, dataModel.AskPrice, dataModel.PreSettlementPrice);
            }
            else if (e.ColumnIndex == this.Column_HighPrice.Index)
            {
                SetPriceCellForeColor(e.CellStyle, dataModel.HighPrice, dataModel.PreSettlementPrice);
            }
            else if (e.ColumnIndex == this.Column_LowPrice.Index)
            {
                SetPriceCellForeColor(e.CellStyle, dataModel.LowPrice, dataModel.PreSettlementPrice);
            }
            else if (e.ColumnIndex == this.Column_OpenPrice.Index)
            {
                SetPriceCellForeColor(e.CellStyle, dataModel.OpenPrice, dataModel.PreSettlementPrice);
            }
        }
Exemplo n.º 7
0
        private void CellContentClickEvent(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex < 0)
            {
                return;
            }

            MarketDataViewModel market_data_model = this.gridQuote.Rows[e.RowIndex].DataBoundItem as MarketDataViewModel;

            if (OnSelectInstrumentChanged != null)
            {
                try
                {
                    OnSelectInstrumentChanged(market_data_model.Instrument);
                }
                catch (Exception ex)
                {
                    Debug.Assert(false, ex.Message);
                }
            }
        }
        private void button_LESS4_Click(object sender, EventArgs e)
        {
            MarketDataViewModel marketDataModel = this.gridQuote.Rows[this.gridQuote.CurrentCell.RowIndex].DataBoundItem as MarketDataViewModel;

            PublichMarketDataLess(ConvertModelData(marketDataModel), 4);
        }