커뮤니티

진입제한 시간 추가

프로필 이미지
좌오비우오비
2025-04-30 11:38:36.0
199
글번호 226291
답변완료
본문쓰기 금지단어가 있어 (Ex*ecuted)로 표현했습니다. 아래 수식은 093000~151500까지 매수진입이 오픈되어 있습니다. 103000까지 매수가 실행되지 않으면 거래중지 하는 수식을 추가해 주십시요. 수식내용 요약 093000 이후 0.03 체결이 발생한 콜옵션행사가를 기준으로 1행사가 내가격에 매수주문을 내는 것입니다. ex) 094500에 콜행사가 345.00 에서 0.03 체결이 발생함. 094500에 콜행사가 342.50 에서 0.50 체결이 발생함. <--- 매수주문 항상 고맙습니다. ******************************************************************************* var OrderList = []; var IsBuyEx*ecuted = false; // 매수가 실행되었는지 확인하는 변수 var IsSellEx*ecuted = false; // 매도가 실행되었는지 확인하는 변수 function Main_OnStart() { Main.SetTimer(1, 1000); } function Main_OnTimer(nEventID) { var d = new Date(); HHMMSS = d.getHours()*10000 + d.getMinutes()*100 + d.getSeconds(); // 타이머 종료 후 09:30:00 이후 if (nEventID == 1 && HHMMSS >= 093000) { // 15:15:00 이전 if (HHMMSS < 151500) { // 매수 후 추가 매수가 발생하지 않도록 확인 if (!IsBuyEx*ecuted) { // 전체 콜 종목 대상 for (var x = -Option1.lowersATM; x <= Option1.uppersATM; x++) { // 현재가 0.03 발생 if (Option1.GetCurrent(0, x) == 0.03) { // 내가 주문한 종목인지 판별 var Order = true; if (OrderList.length > 0) { for (var y = 0; y < OrderList.length; y++) { if (Option1.GetATMCallRecent(x-1) == OrderList[y]) { Order = false; } } } // 주문을 낸 적이 없으면 매수 주문 if (Order == true) { // 첫 매수 실행 OrderList.push(Option1.GetATMCallRecent(x-1)); Account1.OrderBuy(Option1.GetATMCallRecent(x-1), 1, Option1.GetAsk(0, x-1, 5), 0); IsBuyEx*ecuted = true; // 매수가 실행되었음을 표시 } } } } // 매수 후 2.5 이상 수익이면 청산 if (IsBuyEx*ecuted && !IsSellEx*ecuted) { for (var i = 0; i < OrderList.length; i++) { Account1.SetBalance(OrderList[i], 0); if (Account1.Balance.count > 0 && Account1.Balance.position == 2 && Account1.Balance.current >= Account1.Balance.avgUnitCost + 2.5) { // 익절 조건 충족 시 매도 Account1.OrderSell(Account1.Balance.code, Account1.Balance.count, Option1.GetBid(Account1.Balance.code, 5), 0); IsSellEx*ecuted = true; // 매도가 실행되었음을 표시 } } } } else // 15:15:00 이후 { // 모든 주문을 청산 (시간 종료) if (IsBuyEx*ecuted && !IsSellEx*ecuted) { if (OrderList.length > 0) { for (var i = 0; i < OrderList.length; i++) { Account1.SetBalance(OrderList[i], 0); if (Account1.Balance.count > 0 && Account1.Balance.position == 2) { // 시간 종료로 매도 Account1.OrderSell(Account1.Balance.code, Account1.Balance.count, Option1.GetBid(Account1.Balance.code, 5), 0); IsSellEx*ecuted = true; // 매도가 실행되었음을 표시 } } } } } } }
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2025-05-02 11:00:04.0

안녕하세요 예스스탁입니다. 별도변수를 만들어 스팟시작시에는 true값을 가지게 하고 10시30분에 sBuyEx*ecuted변수가 아직 false이면 해당변수를 false로 만들어 진입하지 않게 하시면 됩니다. var OrderList = []; var IsBuyEx*ecuted = false; // 매수가 실행되었는지 확인하는 변수 var IsSellEx*ecuted = false; // 매도가 실행되었는지 확인하는 변수 var Trade; function Main_OnStart() { Main.SetTimer(1, 1000); Trade = true; } function Main_OnTimer(nEventID) { var d = new Date(); HHMMSS = d.getHours()*10000 + d.getMinutes()*100 + d.getSeconds(); if (nEventID == 1 && HHMMSS >= 103000 && IsBuyEx*ecuted == false) { Trade = false; } // 타이머 종료 후 09:30:00 이후 if (nEventID == 1 && HHMMSS >= 093000 && Trade == true) { // 15:15:00 이전 if (HHMMSS < 151500) { // 매수 후 추가 매수가 발생하지 않도록 확인 if (!IsBuyEx*ecuted) { // 전체 콜 종목 대상 for (var x = -Option1.lowersATM; x <= Option1.uppersATM; x++) { // 현재가 0.03 발생 if (Option1.GetCurrent(0, x) == 0.03) { // 내가 주문한 종목인지 판별 var Order = true; if (OrderList.length > 0) { for (var y = 0; y < OrderList.length; y++) { if (Option1.GetATMCallRecent(x-1) == OrderList[y]) { Order = false; } } } // 주문을 낸 적이 없으면 매수 주문 if (Order == true) { // 첫 매수 실행 OrderList.push(Option1.GetATMCallRecent(x-1)); Account1.OrderBuy(Option1.GetATMCallRecent(x-1), 1, Option1.GetAsk(0, x-1, 5), 0); IsBuyEx*ecuted = true; // 매수가 실행되었음을 표시 } } } } // 매수 후 2.5 이상 수익이면 청산 if (IsBuyEx*ecuted && !IsSellEx*ecuted) { for (var i = 0; i < OrderList.length; i++) { Account1.SetBalance(OrderList[i], 0); if (Account1.Balance.count > 0 && Account1.Balance.position == 2 && Account1.Balance.current >= Account1.Balance.avgUnitCost + 2.5) { // 익절 조건 충족 시 매도 Account1.OrderSell(Account1.Balance.code, Account1.Balance.count, Option1.GetBid(Account1.Balance.code, 5), 0); IsSellEx*ecuted = true; // 매도가 실행되었음을 표시 } } } } else // 15:15:00 이후 { // 모든 주문을 청산 (시간 종료) if (IsBuyEx*ecuted && !IsSellEx*ecuted) { if (OrderList.length > 0) { for (var i = 0; i < OrderList.length; i++) { Account1.SetBalance(OrderList[i], 0); if (Account1.Balance.count > 0 && Account1.Balance.position == 2) { // 시간 종료로 매도 Account1.OrderSell(Account1.Balance.code, Account1.Balance.count, Option1.GetBid(Account1.Balance.code, 5), 0); IsSellEx*ecuted = true; // 매도가 실행되었음을 표시 } } } } } } } 즐거운 하루되세요 > 좌오비우오비 님이 쓴 글입니다. > 제목 : 진입제한 시간 추가 > 본문쓰기 금지단어가 있어 (Ex*ecuted)로 표현했습니다. 아래 수식은 093000~151500까지 매수진입이 오픈되어 있습니다. 103000까지 매수가 실행되지 않으면 거래중지 하는 수식을 추가해 주십시요. 수식내용 요약 093000 이후 0.03 체결이 발생한 콜옵션행사가를 기준으로 1행사가 내가격에 매수주문을 내는 것입니다. ex) 094500에 콜행사가 345.00 에서 0.03 체결이 발생함. 094500에 콜행사가 342.50 에서 0.50 체결이 발생함. <--- 매수주문 항상 고맙습니다. ******************************************************************************* var OrderList = []; var IsBuyEx*ecuted = false; // 매수가 실행되었는지 확인하는 변수 var IsSellEx*ecuted = false; // 매도가 실행되었는지 확인하는 변수 function Main_OnStart() { Main.SetTimer(1, 1000); } function Main_OnTimer(nEventID) { var d = new Date(); HHMMSS = d.getHours()*10000 + d.getMinutes()*100 + d.getSeconds(); // 타이머 종료 후 09:30:00 이후 if (nEventID == 1 && HHMMSS >= 093000) { // 15:15:00 이전 if (HHMMSS < 151500) { // 매수 후 추가 매수가 발생하지 않도록 확인 if (!IsBuyEx*ecuted) { // 전체 콜 종목 대상 for (var x = -Option1.lowersATM; x <= Option1.uppersATM; x++) { // 현재가 0.03 발생 if (Option1.GetCurrent(0, x) == 0.03) { // 내가 주문한 종목인지 판별 var Order = true; if (OrderList.length > 0) { for (var y = 0; y < OrderList.length; y++) { if (Option1.GetATMCallRecent(x-1) == OrderList[y]) { Order = false; } } } // 주문을 낸 적이 없으면 매수 주문 if (Order == true) { // 첫 매수 실행 OrderList.push(Option1.GetATMCallRecent(x-1)); Account1.OrderBuy(Option1.GetATMCallRecent(x-1), 1, Option1.GetAsk(0, x-1, 5), 0); IsBuyEx*ecuted = true; // 매수가 실행되었음을 표시 } } } } // 매수 후 2.5 이상 수익이면 청산 if (IsBuyEx*ecuted && !IsSellEx*ecuted) { for (var i = 0; i < OrderList.length; i++) { Account1.SetBalance(OrderList[i], 0); if (Account1.Balance.count > 0 && Account1.Balance.position == 2 && Account1.Balance.current >= Account1.Balance.avgUnitCost + 2.5) { // 익절 조건 충족 시 매도 Account1.OrderSell(Account1.Balance.code, Account1.Balance.count, Option1.GetBid(Account1.Balance.code, 5), 0); IsSellEx*ecuted = true; // 매도가 실행되었음을 표시 } } } } else // 15:15:00 이후 { // 모든 주문을 청산 (시간 종료) if (IsBuyEx*ecuted && !IsSellEx*ecuted) { if (OrderList.length > 0) { for (var i = 0; i < OrderList.length; i++) { Account1.SetBalance(OrderList[i], 0); if (Account1.Balance.count > 0 && Account1.Balance.position == 2) { // 시간 종료로 매도 Account1.OrderSell(Account1.Balance.code, Account1.Balance.count, Option1.GetBid(Account1.Balance.code, 5), 0); IsSellEx*ecuted = true; // 매도가 실행되었음을 표시 } } } } } } }