커뮤니티

예스스팟 Q&A

cs아빠 님에 의해서 삭제되었습니다.

프로필 이미지
cs아빠
2020-12-19
11
글번호 225390
답변완료

수식 검토 부탁드립니다. (주문변경, 일부미체결, 다중 챠트)

안녕하세요? 코스닥선물을 거래하고 있습니다. (하이투자) 챠트는 KQ20과 KQ100이름으로 두개의 챠트객체가 있고 (둘다 코스닥150연결선물) 종목객체는 코스닥150연결선물입니다. (Marketdata1) 각 챠트에서 5개의 진입수를 가지고 거래를 하고 있는데 진입 및 가격을 현재가로 하다보니 대부분 거래가 잘 되기는 하나 시장이 빨리 움직일 때는 진입이나 청산을 일부 못하는 경우가 발생하고 있습니다. 그래서 상대3~5호가로 진입및 청산주문을 하고 있는데 아무래도 수익률이 떨어지고 있습니다. 그래서 나름 예스스팟으로 수식을 작성하여 보았는데 하이투자는 모의거래가 없어 시험하기가 어려운 상황입니다. 우선 아래의 수식을 보시고 문제가 될 만한 부분이 있는지 검토를 부탁드리겠습니다. *아래의 수식에서 청산신호가 아닌 스위칭신호(BUY신호인데 그전에 그 챠트에서 주문한 매도포지션이 있는 경우)가 발생했을 때도 잘 작동할 수 있을지 궁금합니다. 감사합니다. ----------------------------------------------------------------------- KQ20챠트에서 5개의 매수/매도 신호발생(현재가 주문) - 5초 후 일부 미체결 가격 조정 - 10초후 일부 미체결 가격 조정 - 15초 후 미체결주문 모두 취소 청산 시 현재가 주문 - 5초후 가격조정 - 10초후 가격조정 KQ100챠트에서도 위와 동일한 방식으로 주문함 KQ20챠트와 KQ100챠트는 서로의 진입과 청산에 영향없이 각각 독립적으로 운영 (서로 영향없이)함. --------------------------------------------------------------------------- var Position; var BuyID; var BuyOrderNum; var SellID; var SellOrderNum; var Position100; var BuyID100; var BuyOrderNum100; var SellID100; var SellOrderNum100; var KQ20num; var IniKQ20num; var KQ100num; var IniKQ100num; function Main_OnStart() { Position = 0; IniKQ20num =0; Position100 = 0; IniKQ100num =0; } function KQ20_OnRiseSignal(Signal) { if (Signal.signalKind == 1) { Position = 1; Account1.SetBalanceItem(Main.GetOrderCode(KQ20.GetCode(1)), 2); IniKQ20num = Account1.Balance.count; BuyID = Account1.OrderBuy(Main.GetOrderCode(KQ20.GetCode(1)),Signal.count,MarketData1.current,0); Main.SetTimer(1, 5000); Main.SetTimer(2, 10000); Main.SetTimer(3, 15000); Main.SetTimer(4, 30000); } if (Signal.signalKind == 3) { Position = -1; Account1.SetBalanceItem(Main.GetOrderCode(KQ20.GetCode(1)), 1); IniKQ20num = Account1.Balance.count; SellID = Account1.OrderSell(Main.GetOrderCode(KQ20.GetCode(1)),Signal.count,MarketData1.current,0); Main.SetTimer(1, 5000); Main.SetTimer(2, 10000); Main.SetTimer(3, 15000); Main.SetTimer(4, 30000); } if (Signal.signalKind == 2) { Main.SetTimer(5, 5000); Main.SetTimer(6, 10000); ELID = Account1.OrderSell(Main.GetOrderCode(KQ20.GetCode(1)),KQ20num,MarketData1.current,0) } if (Signal.signalKind == 4) { Main.SetTimer(5, 5000); Main.SetTimer(6, 10000); ESID = Account1.OrderBuy(Main.GetOrderCode(KQ20.GetCode(1)),KQ20num,MarketData1.current,0) } } function Main_OnOrderResponse(OrderResponse) { if (OrderResponse.orderID == BuyID) { BuyOrderNum = OrderResponse.orderNum; } if (OrderResponse.orderID == SellID) { SellOrderNum = OrderResponse.orderNum; } if (OrderResponse.orderID == ELID) { ELOrderNum = OrderResponse.orderNum; } if (OrderResponse.orderID == ESID) { ESOrderNum = OrderResponse.orderNum; } } function Main_OnTimer(nEventID) { if (nEventID == 1 && Position == 1) { Main.KillTimer(1); Account1.SetUnfillOrderNumber(BuyOrderNum); if (Account1.Unfill.count > 0) { BuyID = Account1.OrderReplacePrice(BuyOrderNum, MarketData1.Ask(1)); } } if (nEventID == 1 && Position == -1) { Main.KillTimer(1); Account1.SetUnfillOrderNumber(SellOrderNum); if (Account1.Unfill.count > 0) { SellID = Account1.OrderReplacePrice(SellOrderNum, MarketData1.Bid(1)); } } if (nEventID == 2 && Position == 1) { Main.KillTimer(2); Account1.SetUnfillOrderNumber(BuyOrderNum); if (Account1.Unfill.count > 0) { BuyID = Account1.OrderReplacePrice(BuyOrderNum, MarketData1.Ask(3)); } } if (nEventID == 2 && Position == -1) { Main.KillTimer(2); Account1.SetUnfillOrderNumber(SellOrderNum); if (Account1.Unfill.count > 0) { SellID = Account1.OrderReplacePrice(SellOrderNum, MarketData1.Bid(3)); } } if (nEventID == 3 && Position == 1) { Main.KillTimer(3); EnterN = 0; Account1.SetUnfillOrderNumber(BuyOrderNum); if (Account1.Unfill.count > 0) { Account1.OrderCancel(BuyOrderNum); } } if (nEventID == 3 && Position == -1) { Main.KillTimer(3); EnterN = 0; Account1.SetUnfillOrderNumber(SellOrderNum); if (Account1.Unfill.count > 0) { Account1.OrderCancel(SellOrderNum); } } if (nEventID == 4 && Position == 1) { Account1.SetBalanceItem(Main.GetOrderCode(KQ20.GetCode(1)), 2); KQ20num = Account1.Balance.count - IniKQ20num ; Main.KillTimer(4); Main.MessageList("매수진입수:", KQ20num); } if (nEventID == 4 && Position == -1) { Account1.SetBalanceItem(Main.GetOrderCode(KQ20.GetCode(1)), 1); KQ20num = Account1.Balance.count - IniKQ20num; Main.KillTimer(4); Main.MessageList("매도진입수:", KQ20num); } if (nEventID == 5 && Position == 1) { Main.KillTimer(5); Account1.SetUnfillOrderNumber(ELOrderNum); if (Account1.Unfill.count > 0) { Account1.OrderReplacePrice(ELOrderNum, MarketData1.Bid(3)); } } if (nEventID == 5 && Position == -1) { Main.KillTimer(5); Account1.SetUnfillOrderNumber(ESOrderNum); if (Account1.Unfill.count > 0) { Account1.OrderReplacePrice(ESOrderNum, MarketData1.Ask(3)); } } if (nEventID == 6 && Position == 1) { Main.KillTimer(6); Account1.SetUnfillOrderNumber(ELOrderNum); if (Account1.Unfill.count > 0) { Account1.OrderReplacePrice(ELOrderNum, MarketData1.Bid(5)); } } if (nEventID == 6 && Position == -1) { Main.KillTimer(6); Account1.SetUnfillOrderNumber(ESOrderNum); if (Account1.Unfill.count > 0) { Account1.OrderReplacePrice(ESOrderNum, MarketData1.Ask(5)); } } } function KQ100_OnRiseSignal(Signal) { if (Signal.signalKind == 1) { Position100 = 1; Account1.SetBalanceItem(Main.GetOrderCode(KQ100.GetCode(1)), 2); IniKQ100num = Account1.Balance.count; BuyID100 = Account1.OrderBuy(Main.GetOrderCode(KQ100.GetCode(1)),Signal.count,MarketData1.current,0); Main.SetTimer(7, 5000); Main.SetTimer(8, 10000); Main.SetTimer(9, 15000); Main.SetTimer(10, 30000); } if (Signal.signalKind == 3) { Position100 = -1; Account1.SetBalanceItem(Main.GetOrderCode(KQ100.GetCode(1)), 1); IniKQ100num = Account1.Balance.count; SellID100 = Account1.OrderSell(Main.GetOrderCode(KQ100.GetCode(1)),Signal.count,MarketData1.current,0); Main.SetTimer(7, 5000); Main.SetTimer(8, 10000); Main.SetTimer(9, 15000); Main.SetTimer(10, 30000); } if (Signal.signalKind == 2) { Main.SetTimer(11, 5000); Main.SetTimer(12, 10000); ELID100 = Account1.OrderSell(Main.GetOrderCode(KQ100.GetCode(1)),KQ100num,MarketData1.current,0) } if (Signal.signalKind == 4) { Main.SetTimer(5, 5000); Main.SetTimer(6, 10000); ESID100 = Account1.OrderBuy(Main.GetOrderCode(KQ100.GetCode(1)),KQ100num,MarketData1.current,0) } } function Main_OnOrderResponse(OrderResponse) { if (OrderResponse.orderID == BuyID100) { BuyOrderNum100 = OrderResponse.orderNum; } if (OrderResponse.orderID == SellID100) { SellOrderNum100 = OrderResponse.orderNum; } if (OrderResponse.orderID == ELID100) { ELOrderNum100 = OrderResponse.orderNum; } if (OrderResponse.orderID == ESID100) { ESOrderNum100 = OrderResponse.orderNum; } } function Main_OnTimer(nEventID) { if (nEventID == 7&& Position100 == 1 ) { Main.KillTimer(7); Account1.SetUnfillOrderNumber(BuyOrderNum100); if (Account1.Unfill.count > 0) { BuyID100 = Account1.OrderReplacePrice(BuyOrderNum100, MarketData1.Ask(1)); } } if (nEventID == 7 && Position100 == -1) { Main.KillTimer(7); Account1.SetUnfillOrderNumber(SellOrderNum100); if (Account1.Unfill.count > 0) { SellID100 = Account1.OrderReplacePrice(SellOrderNum100, MarketData1.Bid(1)); } } if (nEventID == 8 && Position100 == 1) { Main.KillTimer(8); Account1.SetUnfillOrderNumber(BuyOrderNum100); if (Account1.Unfill.count > 0) { BuyID100 = Account1.OrderReplacePrice(BuyOrderNum100, MarketData1.Ask(3)); } } if (nEventID == 8 && Position100 == -1) { Main.KillTimer(8); Account1.SetUnfillOrderNumber(SellOrderNum100); if (Account1.Unfill.count > 0) { SellID100 = Account1.OrderReplacePrice(SellOrderNum100, MarketData1.Bid(3)); } } if (nEventID == 9 && Position100 == 1) { Main.KillTimer(9); EnterN = 0; Account1.SetUnfillOrderNumber(BuyOrderNum100); if (Account1.Unfill.count > 0) { Account1.OrderCancel(BuyOrderNum100); } } if (nEventID == 9 && Position100 == -1) { Main.KillTimer(9); EnterN = 0; Account1.SetUnfillOrderNumber(SellOrderNum100); if (Account1.Unfill.count > 0) { Account1.OrderCancel(SellOrderNum100); } } if (nEventID == 10 && Position100 == 1) { Account1.SetBalanceItem(Main.GetOrderCode(KQ100.GetCode(1)), 2); KQ20num = Account1.Balance.count - IniKQ100num ; Main.KillTimer(10); Main.MessageList("매수진입수:", KQ100num); } if (nEventID == 10 && Position100 == -1) { Account1.SetBalanceItem(Main.GetOrderCode(KQ100.GetCode(1)), 1); KQ20num = Account1.Balance.count - IniKQ100num; Main.KillTimer(10); Main.MessageList("매도진입수:", KQ100num); } if (nEventID == 11 && Position100 == 1) { Main.KillTimer(11); Account1.SetUnfillOrderNumber(ELOrderNum100); if (Account1.Unfill.count > 0) { Account1.OrderReplacePrice(ELOrderNum100, MarketData1.Bid(3)); } } if (nEventID == 11 && Position100 == -1) { Main.KillTimer(11); Account1.SetUnfillOrderNumber(ESOrderNum100); if (Account1.Unfill.count > 0) { Account1.OrderReplacePrice(ESOrderNum100, MarketData1.Ask(3)); } } if (nEventID == 12 && Position100 == 1) { Main.KillTimer(12); Account1.SetUnfillOrderNumber(ELOrderNum100); if (Account1.Unfill.count > 0) { Account1.OrderReplacePrice(ELOrderNum100, MarketData1.Bid(5)); } } if (nEventID == 12 && Position100 == -1) { Main.KillTimer(12); Account1.SetUnfillOrderNumber(ESOrderNum100); if (Account1.Unfill.count > 0) { Account1.OrderReplacePrice(ESOrderNum100, MarketData1.Ask(5)); } } }
프로필 이미지
songjs12
2020-12-05
2869
글번호 225383
답변완료

예스스팟에서 청산과 관련 질문

안녕하세요 예스 스팟 수식 작성 중 간단한 문의드립니다. 챠트 객체에서 stoploss나 endofday신호가 나오는 경우 Signalkind가 어떻게 잡히는 지요? Signalkind의 경우 1~4는 buy나 sell, exitlong, short인데 챠트에서 stoploss의 경우에 exitlong/exitshort으로 신호를 인식하게 되는지요? 신호챠트에서 BUY인경우 매도포지션이 있을때 청산하고 매수하는 것으로 알고 있습니다. 이경우 스팟에서는 매도청산 1개, 매수 한개로 신호가 가는지요? 아니면 매수2개로 신호가 가는지요? 감사합니다.
프로필 이미지
songjs12
2020-12-05
2822
글번호 225382

뭐뇌 님에 의해서 삭제되었습니다.

프로필 이미지
뭐뇌
2020-12-05
0
글번호 225381
답변완료

당일 개장시간, 폐장시간을 알 수 있는 함수

안녕하세요. YesSpot으로 당일의 장개시 시간과 장마감 시간을 알수 있는 함수나 방법이 있을까요? 자동매매를 돌리고 있는데 이번 수능일에 장마감 시간이 바뀌어서 오류가 발생했습니다. 물론 제가 좀더 부지런하게 예외조건을 넣어두면 되는 것입니다만, 가급적이면 이것도 자동적으로 처리가 되면 참 좋겠습니다.
프로필 이미지
좋은밤
2020-12-04
2719
글번호 225380
답변완료

수식 문의 드립니다.

안녕하세요. 처음이라 어떤 예스스팟에서 어떤객체를 선택하고 어떤 함수를 사용해야 할지 몰라 문의드립니다. 가이드만 잡아주시면 추가 코드는 응용해서 사용해 보겠습니다. 첨부 그림에서 파란색 화살표 부근에서 매도청산을 하고 싶은데 이부분만 코딩 부탁드립니다. 현재봉의 값이 전봉의 저가를 이탈시 매도청산 or 현재봉의 종가가 기준이평선(5MA) 이탈시 매도청산 감사합니다.
프로필 이미지
코페라
2020-12-04
2624
글번호 225379
답변완료

chart에 포함된 system의 systeminfo 업데이트

기존의 차트(확장차트로 새로 생성하지않은)에 포함된 system 의 sysmteminfo(input, STOPLOSS, TAKEPROFIT 등)을 yes spot에서 업데이트(원격으로 설정변경)할 수 있는 기능이 있을까요??
프로필 이미지
호빗츠
2020-12-01
2544
글번호 225378
답변완료

예스스팟 단독의 STOPLOSS 기능 구현

YES SPOT 으로 주문, 청산(손절, 익절)하는 일반적인 방법은 확장차트객체를 생성하고 system을 설정한뒤, 확장차트의 systeminfo를 spot에서 셋팅하여 system 이 STOPLOSS 및 TAKEPROFIT을 실행하도록 할 수 있다(11월 24일자 답변)고 알고 있습니다. [질문] 이 방법 외에 SPOT 내에서 단독으로 주문도 실행하고, STOPLOSS와 TAKEPROFIT을 하는 방법은 없는지요?? 즉, system을 통하지 않고 spot 자체내에서만의 STOPLOSS 및 TAKEPROFIT에 관한 것입니다.
프로필 이미지
호빗츠
2020-12-01
2664
글번호 225377
답변완료

확장차트객체 생성 후 차트 속성 보는법

안녕하세요. ReqChartEx 로 차트객체를 생성하고, 예스스팟 구동하여 차트 보기를 눌러서 차트가 제대로 생성된 것 까지는 확인했습니다. [문제]SystemInfo 로 전달한 StopLoss, TakeProfit 값 등 설정값을 보기 위해 차트의 오른쪽 클릭을 하면... 일반 예스트레이더 상의 차트에서 오른쪽 클릭했을 때 처럼 "개체속성" 창을 띄워 지지 않습니다. [질의]원래 YesSpot에서 생성된 차트객체에는 그 기능이 없는 것인지? 아니면 YesSpot에서 그 기능을 구현하는 코딩을 해줘야 하는지요??
프로필 이미지
호빗츠
2020-12-01
2616
글번호 225376

하운드독 님에 의해서 삭제되었습니다.

프로필 이미지
하운드독
2020-11-27
0
글번호 225375