예스스탁
예스스탁 답변
2026-02-13 14:27:32
안녕하세요
예스스탁입니다.
아래식 예제수식 참고하시기 바랍니다.
Monthly와 weekly 중에 만기일이 가장 상품을 선택애서
ATM기준으로 차트를 생성하고 ATM이 2단계 변경되면
삭제하고 새로 차트를 생성합니다.
스크립트 객체화면
옵션객체추가 -> 객체명 Option1, 코스피200 옵션으로 지정
옵션객체추가 -> 객체명 Option2, (M)코스피200 Weekly옵션으로 지정
옵션객체추가 -> 객체명 Option3, (T)코스피200 Weekly옵션으로 지정
var ATM변경 = 2; //2행사가 변경
var OP,ATM,CT;
var F;
var C1,C2,C3,C4,C5;
var P1,P2,P3,P4,P5;
function Main_OnStart()
{
var D1 = Option1.GetRemainDays(0, 0);
var D2 = Option2.GetRemainDays(0, 0);
var D3 = Option3.GetRemainDays(0, 0);
Main.MessageList("Month",D1);
Main.MessageList("Week월",D2);
Main.MessageList("Week목",D3);
OP = 1;
if (D2 < D1)
OP = 2;
if (D3 < D1)
OP = 3;
ATM = 0;
Main.MessageList("OP",OP);
Main.SetTimer(1,5000);
}
function Main_OnTimer(nEventID)
{
if (nEventID == 1)
{
var Change = false;
if (OP == 1)
{
curATM = Option1.GetExercisePrice(0,2);
if (curATM >= ATM+(2.5*ATM변경) || curATM <= ATM-(2.5*ATM변경))
{
Main.MessageList("ATM변경",curATM,ATM);
ATM = curATM;
Change = true;
F = "00000000";
C1 = Option1.GetCodeByExercisePrice(0,ATM);
C2 = Option1.GetCodeByExercisePrice(0,ATM+2.5);
C3 = Option1.GetCodeByExercisePrice(0,ATM+5.0);
C4 = Option1.GetCodeByExercisePrice(0,ATM+7.5);
C5 = Option1.GetCodeByExercisePrice(0,ATM+10.0);
P1 = Option1.GetCodeByExercisePrice(1,ATM);
P2 = Option1.GetCodeByExercisePrice(1,ATM-2.5);
P3 = Option1.GetCodeByExercisePrice(1,ATM-5.0);
P4 = Option1.GetCodeByExercisePrice(1,ATM-7.5);
P5 = Option1.GetCodeByExercisePrice(1,ATM-10.0);
Main.MessageList("OP1",C1,C2,C3,C4,C5);
Main.MessageList("OP1",P1,P2,P3,P4,P5);
}
}
if (OP == 2)
{
curATM = Option2.GetExercisePrice(0,2);
if (curATM >= ATM+(2.5*ATM변경) || curATM <= ATM-(2.5*ATM변경))
{
Main.MessageList("ATM변경",curATM,ATM,ATM+2.5,ATM+5.0,ATM+7.5);
ATM = curATM;
Change = true;
F = "00000000";
C1 = Option2.GetCodeByExercisePrice(0,ATM);
C2 = Option2.GetCodeByExercisePrice(0,ATM+2.5);
C3 = Option2.GetCodeByExercisePrice(0,ATM+5.0);
C4 = Option2.GetCodeByExercisePrice(0,ATM+7.5);
C5 = Option2.GetCodeByExercisePrice(0,ATM+10.0);
P1 = Option2.GetCodeByExercisePrice(1,ATM);
P2 = Option2.GetCodeByExercisePrice(1,ATM-2.5);
P3 = Option2.GetCodeByExercisePrice(1,ATM-5.0);
P4 = Option2.GetCodeByExercisePrice(1,ATM-7.5);
P5 = Option2.GetCodeByExercisePrice(1,ATM-10.0);
Main.MessageList("OP2",C1,C2,C3,C4,C5);
Main.MessageList("OP2",P1,P2,P3,P4,P5);
}
}
if (OP == 3)
{
curATM = Option3.GetExercisePrice(0,2);
if (curATM >= ATM+(2.5*ATM변경) || curATM <= ATM-(2.5*ATM변경))
{
Main.MessageList("ATM변경",curATM,ATM);
ATM = curATM;
Change = true;
F = "00000000";
C1 = Option3.GetCodeByExercisePrice(0,ATM);
C2 = Option3.GetCodeByExercisePrice(0,ATM+2.5);
C3 = Option3.GetCodeByExercisePrice(0,ATM+5.0);
C4 = Option3.GetCodeByExercisePrice(0,ATM+7.5);
C5 = Option3.GetCodeByExercisePrice(0,ATM+10.0);
P1 = Option3.GetCodeByExercisePrice(1,ATM);
P2 = Option3.GetCodeByExercisePrice(1,ATM-2.5);
P3 = Option3.GetCodeByExercisePrice(1,ATM-5.0);
P4 = Option3.GetCodeByExercisePrice(1,ATM-7.5);
P5 = Option3.GetCodeByExercisePrice(1,ATM-10.0);
Main.MessageList("OP3",C1,C2,C3,C4,C5);
Main.MessageList("OP3",P1,P2,P3,P4,P5);
}
}
if (Change == true)
{
if (CT != null)
{
var a = Main.RemoveObject(CT);
Main.MessageList("차트삭제:",a);
}
Main.MessageList(C1,C2,C3,C4,C5);
Main.MessageList(P1,P2,P3,P4,P5);
//기본종목셋팅(연결선물 주간장,5분 5000개, 갭보정안함, 수정주가처리 안함)
var data1 = new ReqChartItem(F,5,CHART_PERIOD_MINUTE, 5000, CHART_REQCOUNT_BAR, false, false);
//참조데이터 셋팅(ReqChartItem를 이용해 종목과 주기등지정)
//data2종목
var Data2 = new ReqChartItem(C1,5,CHART_PERIOD_MINUTE,5000,CHART_REQCOUNT_BAR,false,false)
//data3종목
var Data3 = new ReqChartItem(C2,5,CHART_PERIOD_MINUTE,5000,CHART_REQCOUNT_BAR,false,false)
//data3종목
var Data4 = new ReqChartItem(C3,5,CHART_PERIOD_MINUTE,5000,CHART_REQCOUNT_BAR,false,false)
//data4종목
var Data5 = new ReqChartItem(C4,5,CHART_PERIOD_MINUTE,5000,CHART_REQCOUNT_BAR,false,false)
//data5종목
var Data6 = new ReqChartItem(C5,5,CHART_PERIOD_MINUTE,5000,CHART_REQCOUNT_BAR,false,false)
//data6종목
var Data7 = new ReqChartItem(P1,5,CHART_PERIOD_MINUTE,5000,CHART_REQCOUNT_BAR,false,false)
//data7종목
var Data8 = new ReqChartItem(P2,5,CHART_PERIOD_MINUTE,5000,CHART_REQCOUNT_BAR,false,false)
//data8종목
var Data9 = new ReqChartItem(P3,5,CHART_PERIOD_MINUTE,5000,CHART_REQCOUNT_BAR,false,false)
//data9종목
var Data10 = new ReqChartItem(P4,5,CHART_PERIOD_MINUTE,5000,CHART_REQCOUNT_BAR,false,false)
//data10종목
var Data11 = new ReqChartItem(P5,5,CHART_PERIOD_MINUTE,5000,CHART_REQCOUNT_BAR,false,false)
//참조 데이터는 복수로 지정이 가능하므로 Array에 담아 지정
var RefSet = new Array(Data2,Data3,Data4,Data5,Data6,Data7,Data8,Data9,Data10,Data11);
//차트 셋팅 제외하고 시스템,자표, 참조데이터는 생략가능, 생략하면 null로 지정
var A = Main.ReqChartEx(data1, null, null, RefSet);
Main.MessageList("차트재생성",A);
}
}
}
function Main_OnRcvChartEx(ChartEx)
{
CT = ChartEx;
}
새해 복 많이 받으시고 즐거운 명절 보내시기 바랍니다.