public XingReal(string resFileCode) { _xaReal = new XARealClass(); _xaReal.ReceiveRealData += _xaReal_ReceiveRealData; _xaReal.RecieveLinkData += _xaReal_RecieveLinkData; _xaReal.ResFileName = $".\\Res\\{resFileCode}.res"; }
private void ReceveRealData_H01(XARealClass myXARealClass)//선물주문정정취소(Real)--정정/취소 확인 부분만 처리됨 { if (cmb_AccNum.SelectedItem.ToString().Trim() != myXARealClass.GetFieldData("OutBlock", "accno").Trim()) { return; } if (myXARealClass.GetFieldData("OutBlock", "trcode").Trim() == "TTRODP11301" && (myXARealClass.GetFieldData("OutBlock", "mocagb").Trim() == "2" || myXARealClass.GetFieldData("OutBlock", "mocagb").Trim() == "3")) { string ordno = int.Parse(myXARealClass.GetFieldData("OutBlock", "ordno")).ToString(); //주문번호 string orgordno = int.Parse(myXARealClass.GetFieldData("OutBlock", "orgordno")).ToString(); //원주문번호 string qty = myXARealClass.GetFieldData("OutBlock", "qty"); //실정정취소수량 DataRow row_원주문 = table.Select("ordno = '" + orgordno + "'")[0]; row_원주문["ordrem"] = int.Parse(row_원주문["ordrem"].ToString()) - int.Parse(qty); DataRow row_주문 = table.Select("ordno = '" + ordno + "'")[0]; row_주문["status"] = row_주문["status"].ToString().Replace("주문", "확인"); if (myXARealClass.GetFieldData("OutBlock", "mocagb") == "3")//정정취소구분 1 신규, 2 정정, 3 취소 { row_주문["ordrem"] = 0; } } Grid표시(); }
public ConnectAPI() { session = new XASessionClass(); query = new XAQueryClass(); real = new XARealClass(); SetLogin(new Secret(), session.ConnectServer(server[1], 20001)); }
private void ReceiveRealData_OMG(XARealClass myXARealClass) { label1.Text = string.Format("{0:0#:##:##}", int.Parse(myXARealClass.GetFieldData("OutBlock", "chetime"))); DataRow row; string code = myXARealClass.GetFieldData("OutBlock", "optcode"); if (code.Contains("201")) { row = CallTable.Rows[CallCodeList.IndexOf(code)]; } else { row = PutTable.Rows[PutCodeList.IndexOf(code)]; } row["iv"] = myXARealClass.GetFieldData("OutBlock", "impv"); //내재변동성 row["delt"] = myXARealClass.GetFieldData("OutBlock", "delt"); //델타(블랙숄즈) row["gama"] = myXARealClass.GetFieldData("OutBlock", "gama"); //감마(블랙숄즈) row["vega"] = myXARealClass.GetFieldData("OutBlock", "vega"); //베가(블랙숄즈) row["ceta"] = myXARealClass.GetFieldData("OutBlock", "ceta"); //세타(블랙숄즈) row["rhox"] = myXARealClass.GetFieldData("OutBlock", "rhox"); //로우(블랙숄즈) row["ceta"] = myXARealClass.GetFieldData("OutBlock", "ceta"); //세타(블랙숄즈) row["theoryprice"] = myXARealClass.GetFieldData("OutBlock", "theoryprice"); //이론가(블랙숄즈) }
private void ReceveRealData_OC0(XARealClass myXARealClass) { double 현재가 = double.Parse(myXARealClass.GetFieldData("OutBlock", "price")); string Code = myXARealClass.GetFieldData("OutBlock", "optcode").Trim(); 손익계산(Code, 현재가); }
private void ReceiveRealData_OC0(XARealClass myXARealClass) { label1.Text = string.Format("{0:0#:##:##}", int.Parse(myXARealClass.GetFieldData("OutBlock", "chetime"))); DataRow row; string code = myXARealClass.GetFieldData("OutBlock", "optcode"); if (code.Contains("201")) { row = CallTable.Rows[CallCodeList.IndexOf(code)]; } else { row = PutTable.Rows[PutCodeList.IndexOf(code)]; } row["change"] = 전일대비구분포함(myXARealClass.GetFieldData("OutBlock", "sign")) + myXARealClass.GetFieldData("OutBlock", "change"); //전일대비 row["diff"] = myXARealClass.GetFieldData("OutBlock", "drate"); //등락율 row["price"] = myXARealClass.GetFieldData("OutBlock", "price"); //현재가 row["open"] = myXARealClass.GetFieldData("OutBlock", "open"); //시가 row["high"] = myXARealClass.GetFieldData("OutBlock", "high"); //고가 row["low"] = myXARealClass.GetFieldData("OutBlock", "low"); //저가 row["volume"] = myXARealClass.GetFieldData("OutBlock", "volume"); //누적거래량 row["cvolume"] = myXARealClass.GetFieldData("OutBlock", "cvolume"); //체결량 row["value"] = myXARealClass.GetFieldData("OutBlock", "value"); //누적거래대금 row["offerho1"] = myXARealClass.GetFieldData("OutBlock", "offerho1"); //매도호가1 row["bidho1"] = myXARealClass.GetFieldData("OutBlock", "bidho1"); //매수호가1 row["mgjv"] = myXARealClass.GetFieldData("OutBlock", "openyak"); //미결제약정수량 row["mgjvupdn"] = myXARealClass.GetFieldData("OutBlock", "openyakcha"); //미결제약정증감 row["theoryprice"] = myXARealClass.GetFieldData("OutBlock", "theoryprice"); //이론가 row["timevl"] = myXARealClass.GetFieldData("OutBlock", "timevalue"); //시간가치 row["impv"] = myXARealClass.GetFieldData("OutBlock", "impv"); //내재변동성//?? }
public GoblinBat() { InitializeComponent(); api = new XASessionClass(); query = new XAQueryClass(); real = new XARealClass(); SetLogin(new Secret(), api.ConnectServer(new Server().GetSelectServer("1"), 20001)); }
public QueryControl(string code, string sCode) { this.ShortCode = sCode; query = new XAQueryClass(); query.ResFileName = String.Format(".\\res\\{0}.res", code); query.ReceiveData += query_ReceiveData; query.ReceiveMessage += query_ReceiveMessage; real = new XARealClass(); real.ReceiveRealData += real_ReceiveRealData; }
public BaseRealApi(string resName) { this.resName = resName; inBlock = "InBlock"; outBlock = "OutBlock"; if (real == null) { real = new XARealClass(); real.ReceiveRealData += Real_ReceiveRealData; real.LoadFromResFile($".\\res\\{resName}.res"); } }
private void ReceiveRealData_OH0(XARealClass myXARealClass) { string[] Str = new string[] { myXARealClass.GetFieldData("OutBlock", "offerho1"), //매도호가1 myXARealClass.GetFieldData("OutBlock", "bidho1"), //매수호가1 myXARealClass.GetFieldData("OutBlock", "offerrem1"), //매도호가수량1 myXARealClass.GetFieldData("OutBlock", "bidrem1"), //매수호가수량1 myXARealClass.GetFieldData("OutBlock", "offercnt1"), //매도호가건수1 myXARealClass.GetFieldData("OutBlock", "bidcnt1"), //매수호가건수1 myXARealClass.GetFieldData("OutBlock", "offerho2"), //매도호가2 myXARealClass.GetFieldData("OutBlock", "bidho2"), //매수호가2 myXARealClass.GetFieldData("OutBlock", "offerrem2"), //매도호가수량2 myXARealClass.GetFieldData("OutBlock", "bidrem2"), //매수호가수량2 myXARealClass.GetFieldData("OutBlock", "offercnt2"), //매도호가건수2 myXARealClass.GetFieldData("OutBlock", "bidcnt2"), //매수호가건수2 myXARealClass.GetFieldData("OutBlock", "offerho3"), //매도호가3 myXARealClass.GetFieldData("OutBlock", "bidho3"), //매수호가3 myXARealClass.GetFieldData("OutBlock", "offerrem3"), //매도호가수량3 myXARealClass.GetFieldData("OutBlock", "bidrem3"), //매수호가수량3 myXARealClass.GetFieldData("OutBlock", "offercnt3"), //매도호가건수3 myXARealClass.GetFieldData("OutBlock", "bidcnt3"), //매수호가건수3 myXARealClass.GetFieldData("OutBlock", "offerho4"), //매도호가4 myXARealClass.GetFieldData("OutBlock", "bidho4"), //매수호가4 myXARealClass.GetFieldData("OutBlock", "offerrem4"), //매도호가수량4 myXARealClass.GetFieldData("OutBlock", "bidrem4"), //매수호가수량4 myXARealClass.GetFieldData("OutBlock", "offercnt4"), //매도호가건수4 myXARealClass.GetFieldData("OutBlock", "bidcnt4"), //매수호가건수4 myXARealClass.GetFieldData("OutBlock", "offerho5"), //매도호가5 myXARealClass.GetFieldData("OutBlock", "bidho5"), //매수호가5 myXARealClass.GetFieldData("OutBlock", "offerrem5"), //매도호가수량5 myXARealClass.GetFieldData("OutBlock", "bidrem5"), //매수호가수량5 myXARealClass.GetFieldData("OutBlock", "offercnt5"), //매도호가건수5 myXARealClass.GetFieldData("OutBlock", "bidcnt5"), //매수호가건수5 myXARealClass.GetFieldData("OutBlock", "totofferrem"), //매도호가총수량 myXARealClass.GetFieldData("OutBlock", "totbidrem"), //매수호가총수량 myXARealClass.GetFieldData("OutBlock", "totoffercnt"), //매도호가총건수 myXARealClass.GetFieldData("OutBlock", "totbidcnt"), //매수호가총건수 myXARealClass.GetFieldData("OutBlock", "hotime") //호가시간 }; DataUpdate(Str); }
private void SetAPI(KeyValuePair <string, IBlock> kv) { var real = new XARealClass { ResFileName = string.Concat(Path, kv.Key) }; real.ReceiveRealData += OnReceiveRealData; foreach (var block in kv.Value.GetInBlock(real.GetTrCode())) { real.SetFieldData(block.Name, block.Field, block.Property); } real.AdviseRealData(); Real[kv.Key.Split('.')[0]] = real; }
private void ReceiveRealData_OH0(XARealClass myXARealClass) { label1.Text = string.Format("{0:0#:##:##}", int.Parse(myXARealClass.GetFieldData("OutBlock", "hotime"))); DataRow row; string code = myXARealClass.GetFieldData("OutBlock", "optcode"); if (code.Contains("201")) { row = CallTable.Rows[CallCodeList.IndexOf(code)]; } else { row = PutTable.Rows[PutCodeList.IndexOf(code)]; } row["offerrem1"] = myXARealClass.GetFieldData("OutBlock", "offerrem1"); //매도호가수량1 row["bidrem1"] = myXARealClass.GetFieldData("OutBlock", "bidrem1"); //매수호가수량1 }
private void ReceveRealData_C01(XARealClass myXARealClass)//선물주문체결(Real)--주문 체결 과 관련된 처리를 함. { if (cmb_AccNum.SelectedItem.ToString().Trim() != myXARealClass.GetFieldData("OutBlock", "accno").Trim()) { return; } string ordno = myXARealClass.GetFieldData("OutBlock", "ordno");//주문번호 DataRow row = table.Select("ordno = '" + ordno + "'")[0]; double cheprice = double.Parse(myXARealClass.GetFieldData("OutBlock", "cheprice")); //체결가격 double chevol = double.Parse(myXARealClass.GetFieldData("OutBlock", "chevol")); //체결수량 double 체결량 = double.Parse(row["cheqty"].ToString()); double 체결가 = double.Parse(row["cheprice"].ToString()); double 미체결량 = double.Parse(row["ordrem"].ToString()); row["cheprice"] = Math.Round((cheprice * chevol + 체결가 * 체결량) / (체결량 + chevol), 4);//체결량 가중평균 row["cheqty"] = Math.Round(체결량 + chevol, 0); row["ordrem"] = Math.Round(미체결량 - chevol, 0); row["status"] = "완료"; Grid표시(); }
protected virtual void Dispose(bool disposing) { if (_disposed == false) { if (disposing == true) { if (_xaReal != null) { if (_advise == true) { _xaReal.UnadviseRealData(); _advise = false; } Marshal.ReleaseComObject(_xaReal); _xaReal = null; } } _disposed = true; } }
private void ReceveRealData_C01(XARealClass myXARealClass) { if (cmb_AccNum.SelectedItem.ToString().Trim() != myXARealClass.GetFieldData("OutBlock", "accno").Trim()) { return; } string code = MainForm.종목마스터[myXARealClass.GetFieldData("OutBlock", "expcode")][0]; //종목코드(표준==>단축) double cheprice = double.Parse(myXARealClass.GetFieldData("OutBlock", "cheprice")); //체결가격 double chevol = double.Parse(myXARealClass.GetFieldData("OutBlock", "chevol")); //체결수량 string dosugb = myXARealClass.GetFieldData("OutBlock", "dosugb"); //매도수구분 if (dosugb == "1") { dosugb = "매도"; } else if (dosugb == "2") { dosugb = "매수"; } bool 잔고없슴 = true; for (int i = 0; i < table.Rows.Count; i++) { DataRow row = table.Rows[i]; if (row["expcode"].ToString() == code) { 잔고없슴 = false; double 잔고 = double.Parse(row["jqty"].ToString()); double 평균단가 = double.Parse(row["pamt"].ToString()); string 구분 = row["medosu"].ToString(); //실현손익계산 if (구분 == "매도") { 매매손익 += Math.Min(잔고, chevol) * (평균단가 - cheprice) * 500000d; } else { 매매손익 += Math.Min(잔고, chevol) * (cheprice - 평균단가) * 500000d; } if (dosugb == 구분)//잔고추가(진입) { row["pamt"] = Math.Round((cheprice * chevol + 잔고 * 평균단가) / (잔고 + chevol), 4); row["jqty"] = Math.Round(잔고 + chevol, 0); } else//청산 { int new잔고 = (int)Math.Round(잔고 - chevol, 0); if (new잔고 == 0)//청산완료 { table.Rows.RemoveAt(i); 현재가Real요청(); break; } else if (new잔고 < 0)//Stop and Reverse { row["jqty"] = Math.Abs(new잔고).ToString(); row["pamt"] = cheprice.ToString(); } else//일부청산 { row["jqty"] = new잔고.ToString(); } } } } if (잔고없슴)//진입 { DataRow newrow = table.NewRow(); newrow["expcode"] = code; newrow["medosu"] = dosugb; newrow["jqty"] = chevol.ToString(); newrow["pamt"] = cheprice.ToString(); newrow["price"] = cheprice.ToString(); newrow["appamt"] = chevol * cheprice * 500000d; newrow["dtsunik1"] = "0"; newrow["sunikrt"] = "0"; table.Rows.Add(newrow); 현재가Real요청(); } 총손익계산(); }
private void ReceveRealData_O01(XARealClass myXARealClass)//선물접수(Real)--매도/매수/정정/취소 주문 접수 처리됨 { if (cmb_AccNum.SelectedItem.ToString().Trim() != myXARealClass.GetFieldData("OutBlock", "accno").Trim()) { return; } DataRow newrow = table.NewRow(); newrow["ordno"] = myXARealClass.GetFieldData("OutBlock", "ordno"); //주문번호 newrow["orgordno"] = myXARealClass.GetFieldData("OutBlock", "orgordno"); //원주문번호 newrow["expcode"] = myXARealClass.GetFieldData("OutBlock", "fnoIsuno"); //선물옵션종목번호 string bnstp = myXARealClass.GetFieldData("OutBlock", "bnstp"); //매매구분 //1:매도 2:매수 if (bnstp == "1") { bnstp = "매도"; } else if (bnstp == "2") { bnstp = "매수"; } string trcode = myXARealClass.GetFieldData("OutBlock", "trcode");//TRCODE //SONBT001:신규주문 SONBT002:정정주문 SONBT003:취소주문 if (trcode == "SONBT002") { trcode = "정정"; } else if (trcode == "SONBT003") { trcode = "취소"; } else { trcode = ""; } newrow["medosu"] = bnstp + trcode; string hogatype = myXARealClass.GetFieldData("OutBlock", "hogatype"); //호가유형코드 switch (hogatype) { case "00": hogatype = "지정가"; break; case "03": hogatype = "시장가"; break; case "05": hogatype = "조건부지정가"; break; case "06": hogatype = "최유리지정가"; break; case "10": hogatype = "지정가(IOC)"; break; case "20": hogatype = "지정가(FOK)"; break; case "13": hogatype = "시장가(IOC)"; break; case "23": hogatype = "시장가(FOK)"; break; case "16": hogatype = "최유리지정가(IOC)"; break; case "26": hogatype = "최유리지정가(FOK)"; break; } newrow["ordgb"] = hogatype; newrow["qty"] = myXARealClass.GetFieldData("OutBlock", "ordqty"); //주문수량 newrow["price"] = myXARealClass.GetFieldData("OutBlock", "ordprc"); //주문가격 newrow["cheqty"] = myXARealClass.GetFieldData("OutBlock", "execqty"); //체결수량 newrow["cheprice"] = myXARealClass.GetFieldData("OutBlock", "execprc"); //체결가격 newrow["ordrem"] = myXARealClass.GetFieldData("OutBlock", "unercqty"); //미체결수량 string trcode1 = myXARealClass.GetFieldData("OutBlock", "trcode1"); //tr코드 switch (trcode1) { case "FO01": trcode1 = "접수"; //정상주문 break; case "FO02": trcode1 = "정정주문"; break; case "FO03": trcode1 = "취소주문"; break; case "HO01": trcode1 = "확인"; break; case "CH01": trcode1 = "체결"; break; } newrow["status"] = trcode1; newrow["ordtime"] = myXARealClass.GetFieldData("OutBlock", "trxtime");//처리시각 table.Rows.InsertAt(newrow, 0); Grid표시(); }
private void ReceiveRealData_OC0(XARealClass myXARealClass) { currprice = double.Parse(myXARealClass.GetFieldData("OutBlock", "price"));//현재가 CurrPriceUpdate(); }
public Real() { myXARealClass = new XARealClass(); myXARealClass.ReceiveRealData += new _IXARealEvents_ReceiveRealDataEventHandler(myXARealClass_ReceiveRealData); }