Exemple #1
0
 void myTimer_t0441_Tick(object sender, EventArgs e)
 {
     t0441.SetFieldData("t0441InBlock", "cts_expcode", 0, 연속키_t0441_cts_expcode);
     t0441.SetFieldData("t0441InBlock", "cts_medocd", 0, 연속키_t0441_cts_medocd);
     t0441.Request(true);
     myTimer_t0441.Stop();
 }
Exemple #2
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (rdb_모의계좌.Checked)//모의투자는 CACBQ21900를 지원안함.
            {
                string 상품상세명 = "";
                if (e.RowIndex == 0)
                {
                    상품상세명 = "선물옵션";
                }
                else
                {
                    상품상세명 = "주식위탁";
                }

                dataGridView1.Rows[e.RowIndex].Cells["계좌명"].Value = "모의투자"; //계좌명
                dataGridView1.Rows[e.RowIndex].Cells["상품"].Value  = 상품상세명;  //상품상세명
            }
            else if (e.ColumnIndex == 2)
            {
                string 계좌번호 = dataGridView1.Rows[e.RowIndex].Cells["계좌번호"].Value.ToString().Trim();
                string 비밀번호 = dataGridView1.Rows[e.RowIndex].Cells["비밀번호"].Value.ToString().Trim();

                myXAQueryClass.ResFileName = @"C:\eBEST\xingAPI\Res\CACBQ21900.res";//CACBQ21900
                myXAQueryClass.SetFieldData("CACBQ21900InBlock1", "RecCnt", 0, "1");
                myXAQueryClass.SetFieldData("CACBQ21900InBlock1", "AcntNo", 0, 계좌번호);
                myXAQueryClass.SetFieldData("CACBQ21900InBlock1", "InptPwd", 0, 비밀번호);
                myXAQueryClass.Request(false);
            }
        }
Exemple #3
0
 private void 취소주문()
 {
     CSPAT00800.SetFieldData("CSPAT00800InBlock1", "OrgOrdNo", 0, textBox4.Text.Trim());
     CSPAT00800.SetFieldData("CSPAT00800InBlock1", "AcntNo", 0, comboBox1.SelectedItem.ToString());
     CSPAT00800.SetFieldData("CSPAT00800InBlock1", "InptPwd", 0, textBox5.Text.Trim());
     CSPAT00800.SetFieldData("CSPAT00800InBlock1", "IsuNo", 0, textBox1.Text.Trim());
     CSPAT00800.SetFieldData("CSPAT00800InBlock1", "OrdQty", 0, textBox2.Text.Trim());
     CSPAT00800.Request(false);
 }
 private void 취소주문()
 {          
     CFOAT00300.SetFieldData("CFOAT00300InBlock1", "AcntNo", 0, comboBox1.SelectedItem.ToString());
     CFOAT00300.SetFieldData("CFOAT00300InBlock1", "Pwd", 0, textBox5.Text.Trim());
     CFOAT00300.SetFieldData("CFOAT00300InBlock1", "FnoIsuNo", 0, from단축to확장(textBox1.Text.Trim()));
     CFOAT00300.SetFieldData("CFOAT00300InBlock1", "OrgOrdNo", 0, textBox4.Text.Trim());
     CFOAT00300.SetFieldData("CFOAT00300InBlock1", "CancQty", 0, textBox2.Text.Trim());
     CFOAT00300.Request(false);
 }
Exemple #5
0
        public Class주식종목마스터()
        {
            myXAQueryClass_t9945.ReceiveData += new _IXAQueryEvents_ReceiveDataEventHandler(myXAQueryClass_t9945_ReceiveData);

            myXAQueryClass_t9945.ReceiveMessage += new _IXAQueryEvents_ReceiveMessageEventHandler(myXAQueryClass_t9945_ReceiveMessage);

            myXAQueryClass_t9945.ResFileName = @"C:\ETRADE\xingAPI\Res\t9945.res";
            myXAQueryClass_t9945.SetFieldData("t9945InBlock", "gubun", 0, "1");
            myXAQueryClass_t9945.Request(false);

            myTimer.Tick    += new EventHandler(myTimer_Tick);
            myTimer.Interval = 1000;
            myTimer.Start();
        }
Exemple #6
0
 public virtual void QueryExcute(Dictionary <string, string> InputDataTable)
 {
     foreach (KeyValuePair <string, string> inputData in InputDataTable)
     {
         myXAQueryClass.SetFieldData(InBlockName, inputData.Key, 0, inputData.Value);
     }
     myXAQueryClass.Request(false);
 }
Exemple #7
0
 private void 정정주문()
 {
     CSPAT00700.SetFieldData("CSPAT00700InBlock1", "OrgOrdNo", 0, textBox4.Text.Trim());
     CSPAT00700.SetFieldData("CSPAT00700InBlock1", "AcntNo", 0, comboBox1.SelectedItem.ToString());
     CSPAT00700.SetFieldData("CSPAT00700InBlock1", "InptPwd", 0, textBox5.Text.Trim());
     CSPAT00700.SetFieldData("CSPAT00700InBlock1", "IsuNo", 0, textBox1.Text.Trim());
     CSPAT00700.SetFieldData("CSPAT00700InBlock1", "OrdQty", 0, textBox2.Text.Trim());
     CSPAT00700.SetFieldData("CSPAT00700InBlock1", "OrdprcPtnCode", 0, "00");
     CSPAT00700.SetFieldData("CSPAT00700InBlock1", "OrdCndiTpCode", 0, "0");
     CSPAT00700.SetFieldData("CSPAT00700InBlock1", "OrdPrc", 0, textBox3.Text.Trim());
     CSPAT00700.Request(false);
 }
Exemple #8
0
        public bool SELL()
        {
            try
            {
                // 매도주문
                XAQ_00600.ResFileName     = ".\\Res\\CSPAT00600.res";
                XAQ_00600.ReceiveMessage += XAQ_00600_ReceiveMessage;

                XAQ_00600.SetFieldData("CSPAT00600InBlock1", "AcntNo", 0, ACCOUNTNUMBER);

                if (ISEXEC)
                {
                    XAQ_00600.SetFieldData("CSPAT00600InBlock1", "InptPwd", 0, "miji1212");
                }
                else
                {
                    XAQ_00600.SetFieldData("CSPAT00600InBlock1", "InptPwd", 0, "miji12!@");
                }

                XAQ_00600.SetFieldData("CSPAT00600InBlock1", "IsuNo", 0, STOCKCODE);
                XAQ_00600.SetFieldData("CSPAT00600InBlock1", "OrdQty", 0, ORDERQTY.ToString());
                XAQ_00600.SetFieldData("CSPAT00600InBlock1", "BnsTpCode", 0, "1");
                XAQ_00600.SetFieldData("CSPAT00600InBlock1", "OrdprcPtnCode", 0, "03");
                XAQ_00600.SetFieldData("CSPAT00600InBlock1", "MgntrnCode", 0, "000");
                XAQ_00600.SetFieldData("CSPAT00600InBlock1", "LoanDt", 0, "");
                XAQ_00600.SetFieldData("CSPAT00600InBlock1", "OrdCndiTpCode", 0, "0");

                LR(LogType.INFORMATION, string.Format("매도 주문요청 종목코드 : {0} , 수량 : {1} ", STOCKCODE, ORDERQTY.ToString()));
                if (XAQ_00600.Request(false) < 0)
                {
                    LR(LogType.ERROR, "주문전송 오류 " + STOCKCODE);
                    isSucc = false;
                }

                return(isSucc);
            }
            catch (Exception e)
            {
                EventLog.WriteEntry("ETRADE_SELL-SELL", e.ToString());
                return(false);
            }
        }
 private void 정정주문()
 {
     CFOAT00200.SetFieldData("CFOAT00200InBlock1", "AcntNo", 0, comboBox1.SelectedItem.ToString());
     CFOAT00200.SetFieldData("CFOAT00200InBlock1", "Pwd", 0, textBox5.Text.Trim());
     CFOAT00200.SetFieldData("CFOAT00200InBlock1", "FnoIsuNo", 0, from단축to확장(textBox1.Text.Trim()));
     CFOAT00200.SetFieldData("CFOAT00200InBlock1", "OrgOrdNo", 0, textBox4.Text.Trim());
     CFOAT00200.SetFieldData("CFOAT00200InBlock1", "FnoOrdprcPtnCode", 0, "00");
     CFOAT00200.SetFieldData("CFOAT00200InBlock1", "OrdPrc", 0, textBox3.Text.Trim());
     CFOAT00200.SetFieldData("CFOAT00200InBlock1", "MdfyQty", 0, textBox2.Text.Trim());
     CFOAT00200.Request(false); 
 }
Exemple #10
0
        void myTimer_1_Tick(object sender, EventArgs e)
        {
            foreach (KeyValuePair <string, List <string> > code in Form1.Master주식종목)
            {
                if (code.Value.Count == 3)
                {
                    myXAQueryClass_t1101.SetFieldData("t1101InBlock", "shcode", 0, code.Key);
                    myXAQueryClass_t1101.Request(false);

                    if (code.Key == 마지막code)
                    {
                        myTimer_1.Stop();
                    }
                    break;
                }
            }
        }
Exemple #11
0
 void myTimer_t0434_Tick(object sender, EventArgs e)
 {
     t0434.SetFieldData("t0434InBlock", "cts_ordno", 0, 연속키_t0434_cts_ordno);
     t0434.Request(true);
     myTimer_t0434.Stop();
 }
Exemple #12
0
 private void 매도주문()
 {
     CSPAT00600.SetFieldData("CSPAT00600InBlock1", "AcntNo", 0, comboBox1.SelectedItem.ToString());
     CSPAT00600.SetFieldData("CSPAT00600InBlock1", "InptPwd", 0, textBox5.Text.Trim());
     CSPAT00600.SetFieldData("CSPAT00600InBlock1", "IsuNo", 0, textBox1.Text.Trim());
     CSPAT00600.SetFieldData("CSPAT00600InBlock1", "OrdQty", 0, textBox2.Text.Trim());
     CSPAT00600.SetFieldData("CSPAT00600InBlock1", "OrdPrc", 0, textBox3.Text.Trim());
     CSPAT00600.SetFieldData("CSPAT00600InBlock1", "BnsTpCode", 0, "1");
     CSPAT00600.SetFieldData("CSPAT00600InBlock1", "OrdprcPtnCode", 0, "00");
     CSPAT00600.SetFieldData("CSPAT00600InBlock1", "MgntrnCode", 0, "000");
     //CSPAT00600.SetFieldData("CSPAT00600InBlock1", "LoanDt", 0, "값");
     CSPAT00600.SetFieldData("CSPAT00600InBlock1", "OrdCndiTpCode", 0, "0");
     CSPAT00600.Request(false);
 }
Exemple #13
0
 public virtual void QueryExcute(Dictionary <string, string> InputDataTable)
 {
     myXAQueryClass.ResFileName = @"C:\eBEST\xingAPI\Res\t1102.res";
     myXAQueryClass.SetFieldData("t1102InBlock", "shcode", 0, CConst.SH_CODE);
     myXAQueryClass.Request(false);
 }
Exemple #14
0
 void myTimer_t0424_Tick(object sender, EventArgs e)
 {
     t0424.SetFieldData("t0425InBlock", "cts_expcode", 0, 연속key_t0424);
     t0424.Request(true);
     myTimer_t0424.Stop();
 }
Exemple #15
0
 void myTimer_t0425_Tick(object sender, EventArgs e)
 {
     t0425.SetFieldData("t0424InBlock", "cts_ordno", 0, 연속key_t0425);
     t0425.Request(true);
     myTimer_t0425.Stop();
 }
Exemple #16
0
 public void SetFieldData(string blockName, string fieldName, int index, string value)
 {
     _xaQuery.SetFieldData(blockName, fieldName, index, value);
 }
Exemple #17
0
        public void add_jongmok()
        {
            string jongmok_code = jongmokCode.Text;   // 종목코드
            int    qty          = Decimal.ToInt32(stockQty.Value);
            string jongmok_nm;                        // 주식이름
            long   price;                             // 주식가격
            int    price_hoga_t1;                     // 매수호가1
            int    price_hoga_t2;                     // 매수호가2
            int    price_sehoga_t1;                   // 매도호가1
            int    price_sehoga_t2;                   // 매도호가2
            string BnsTpCode = "";

            if (OrderOption == "매도")
            {
                BnsTpCode = "1";
            }
            else if (OrderOption == "매수")
            {
                BnsTpCode = "2";
            }
            else
            {
            }

            // 종목명 가져오기
            query.ResFileName = "Res/t1101.res";
            query.SetFieldData("t1101InBlock", "shcode", 0, jongmok_code);
            int rQstate = query.Request(false);

            if (rQstate < 0)
            {
                LogBox.Items.Add("전송에러!");
                LogBox.Items.Add("에러코드: " + rQstate);
            }
            else
            {
                while (true)
                {
                    Thread.Sleep(500);
                    if (database.StringGet("TRDataState") == "t1101")
                    {
                        jongmok_nm      = query.GetFieldData("t1101OutBlock", "hname", 0);               // 종목이름
                        price           = long.Parse(query.GetFieldData("t1101OutBlock", "price", 0));   // 시장가
                        price_hoga_t1   = int.Parse(query.GetFieldData("t1101OutBlock", "bidho1", 0));   // 매수호가1
                        price_hoga_t2   = int.Parse(query.GetFieldData("t1101OutBlock", "bidho2", 0));   // 매수호가2
                        price_sehoga_t1 = int.Parse(query.GetFieldData("t1101OutBlock", "offerho1", 0)); // 매도호가1
                        price_sehoga_t2 = int.Parse(query.GetFieldData("t1101OutBlock", "offerho2", 0)); // 매도호가2
                        if (jongmok_nm.Length > 0)
                        {
                            // 계좌번호 있는지 검사
                            string accountCode = cmbAccount.Items[0].ToString();
                            if (accountCode.Length > 0)
                            {
                                // 계좌번호가 있는 것으로 확인한 후 주문 진행
                                query.ResFileName = "Res/CSPAT00600.res";
                                query.SetFieldData("CSPAT00600InBlock1", "AcntNo", 0, accountCode);       // 계좌번호
                                query.SetFieldData("CSPAT00600InBlock1", "InptPwd", 0, txtPassword.Text); // 입력비밀번호
                                query.SetFieldData("CSPAT00600InBlock1", "IsuNo", 0, jongmokCode.Text);   // 종목코드
                                query.SetFieldData("CSPAT00600InBlock1", "OrdQty", 0, qty.ToString());    // 주문수량
                                query.SetFieldData("CSPAT00600InBlock1", "OrdPrc", 0, price.ToString());  // 주문가
                                query.SetFieldData("CSPAT00600InBlock1", "BnsTpCode", 0, BnsTpCode);      // 매매구분
                                query.SetFieldData("CSPAT00600InBlock1", "OrdprcPtnCode", 0, "00");       // 호가유형구분 (00: 지정가, 03: 시장가)
                                query.SetFieldData("CSPAT00600InBlock1", "MgntrnCode", 0, "000");         // 신용거래구분 - 000
                                query.SetFieldData("CSPAT00600InBlock1", "LoanDt", 0, "");                // 대출일 - 사용하지 않음
                                query.SetFieldData("CSPAT00600InBlock1", "OrdCndiTpCode", 0, "0");        // 주문조건구분 - 0
                                int joomonState = query.Request(false);                                   // 주문요청
                                if (joomonState < 0)
                                {
                                    LogBox.Items.Add("전송실패!");
                                    LogBox.Items.Add("에러코드: " + joomonState);
                                    break;
                                }
                                else
                                {
                                    // 주문결과 전송될때까지 0.5 초 기다림
                                    LogBox.Items.Add("주문 전송완료!");
                                    Thread.Sleep(500);
                                    if (database.StringGet("TRDataState") == "CSPAT00600")
                                    {
                                        // 주문상태 가져오기
                                        if (database.StringGet("RecentOrderState") != "true")
                                        {
                                            // 주문에러로 기록하지 않음.
                                        }
                                        else
                                        {
                                            LogBox.Items.Add("주문이 정상적으로 완료되었습니다");
                                            LogBox.Items.Add("주문번호: " + database.StringGet("RecentOrderNo"));
                                            // 함수에 거래항목 기록
                                            writeOrder(int.Parse(BnsTpCode), price, qty, database.StringGet("RecentOrderNo"), jongmok_code, jongmok_nm);
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        // 주문접수 안된 경우
                                        break;
                                    }
                                }
                            }
                            else
                            {
                                // 계좌번호 오류
                                break;
                            }
                        }
                        else
                        {
                            // 종목코드 오류.
                            break;
                        }
                    }
                    else
                    {
                    }
                }
                _information.Abort();
            }
        }