Example #1
0
        private void axYuantaQuote1_OnGetMktAll(object sender, AxYuantaQuoteLib._DYuantaQuoteEvents_OnGetMktAllEvent e)
        {
            //DataGrid.Rows.Add(e.symbol, e.refPri, e.openPri, e.highPri, e.lowPri, e.upPri, e.dnPri, e.matchTime, e.matchPri, e.matchQty, e.tolMatchQty);
            DataRow DR = this.dt.Rows.Find(e.symbol);
            if (DR != null)
            {
                DR["參考價"] = e.refPri;
                DR["開盤價"] = e.openPri;
                DR["最高價"] = e.highPri;
                DR["最低價"] = e.lowPri;
                DR["漲停價"] = e.upPri;
                DR["跌停價"] = e.dnPri;
                DR["成交時間"] = e.matchTime != "" ? (string.Format("{0}:{1}:{2}.{3}", e.matchTime.Substring(0, 2), e.matchTime.Substring(2, 2), e.matchTime.Substring(4, 2), e.matchTime.Substring(6, 3))) : "";
                DR["成交價位"] = e.matchPri;
                DR["成交數量"] = e.matchQty;
                DR["總成交量"] = e.tolMatchQty;
                DR["買五"] = e.bestBuyPri +e.bestBuyQty ;
                DR["賣五"] = e.bestSellPri+e.bestSellQty;

                DR.EndEdit();
                DR.AcceptChanges();
            }
            else
            {
                DR = this.dt.NewRow();
                DR["商品代碼"] = e.symbol;
                DR["參考價"] = e.refPri;
                DR["開盤價"] = e.openPri;
                DR["最高價"] = e.highPri;
                DR["最低價"] = e.lowPri;
                DR["漲停價"] = e.upPri;
                DR["跌停價"] = e.dnPri;
                DR["成交時間"] = e.matchTime!="" ? (string.Format("{0}:{1}:{2}.{3}", e.matchTime.Substring(0, 2), e.matchTime.Substring(2, 2), e.matchTime.Substring(4, 2), e.matchTime.Substring(6, 3)) ): "";
                DR["成交價位"] = e.matchPri;
                DR["成交數量"] = e.matchQty;
                DR["總成交量"] = e.tolMatchQty;
                DR["買五"] = e.bestBuyPri + e.bestBuyQty;
                DR["賣五"] = e.bestSellPri + e.bestSellQty;
                this.dt.Rows.Add(DR);
            }

            ListShow(String.Format("{0} 買五:{1}-{2}", e.symbol, e.bestBuyPri, e.bestBuyQty));
            ListShow(String.Format("{0} 賣五:{1}-{2}", e.symbol, e.bestSellPri, e.bestSellQty));
        }
Example #2
0
 private void axYuantaQuote1_OnRegError(object sender, AxYuantaQuoteLib._DYuantaQuoteEvents_OnRegErrorEvent e)
 {
     textBox_status2.Text = e.errCode.ToString();
 }
Example #3
0
 private void axYuantaQuote1_OnGetMktAll(object sender, AxYuantaQuoteLib._DYuantaQuoteEvents_OnGetMktAllEvent e)
 {
     master.process(e);
 }
Example #4
0
        //連線Event OnMktStatusChange (int Status, char* Msg)	與行情發送端連線的狀態,回傳LinkStatus
        private void axYuantaQuote1_OnMktStatusChange(object sender, AxYuantaQuoteLib._DYuantaQuoteEvents_OnMktStatusChangeEvent e)
        {
            textBox_status.Text = DateTime.Now.ToString("HH:mm:ss.fff ")+e.msg.ToString();
            if (e.msg.ToString().IndexOf("行情連線結束") >= 0)
            {
                //隔幾秒再連線

                textBox_status.Text=DateTime.Now.ToString("HH:mm:ss.fff ")+"行情連線結束,隔5秒重新連線";
                timer1.Enabled = true;
            }
            else if (e.msg.ToString().IndexOf("行情連線失敗") >= 0)
            {
                //隔幾秒再連線
                //可能網路不通
                textBox_status.Text = DateTime.Now.ToString("HH:mm:ss.fff ")+"行情連線失敗,隔5秒重新連線";
                timer1.Enabled = true;
            }
        }
Example #5
0
        public void process(AxYuantaQuoteLib._DYuantaQuoteEvents_OnGetMktAllEvent marketEvent)
        {

            refPrice = marketEvent.refPri;
            openPrice = marketEvent.openPri;
            highPrice = marketEvent.highPri;
            lowPrice = marketEvent.lowPri;
            upPrice = marketEvent.upPri;
            downPrice = marketEvent.dnPri;

            matchTime = marketEvent.matchTime != "" ? (string.Format("{0}:{1}:{2}.{3}", marketEvent.matchTime.Substring(0, 2), marketEvent.matchTime.Substring(2, 2), marketEvent.matchTime.Substring(4, 2), marketEvent.matchTime.Substring(6, 3))) : "";

            matchPrice = marketEvent.matchPri;
            matchQuantity = marketEvent.matchQty;
            totalMatchQuantity = marketEvent.tolMatchQty;
            bestBuyFive = marketEvent.bestBuyPri + marketEvent.bestBuyQty;
            bestSellFive = marketEvent.bestSellPri + marketEvent.bestSellQty;


            try
            {

                outputLine = Convert.ToString(now.Year) + nowMonth + nowDay + "," + futuresCode + "     ," + TradeUtility.TradeUtility.getInstance().dealYearMonth() + "     ," + matchTime.Substring(0, 2) + matchTime.Substring(3, 2) + matchTime.Substring(6, 2) + "," + matchPrice + "," + matchQuantity + ",-,-,";

                allTradeOutputFile.writeLine(outputLine);

                parentForm.textBox_TradePrice.Text = Convert.ToString(matchPrice);

                if (!isStopTodayTrade && enableTrade)
                {
                    startTrade(matchTime, matchPrice, matchQuantity);//執行交易程式
                }

            }
            catch (IOException e)
            {
                throw e;
            }
        }