커뮤니티

문의드립니다.

프로필 이미지
엠제이
2013-10-27 11:07:22
157
글번호 68890
답변완료
아래 수식은 당일의 상한가/하한가를 구하는 수식입니다. 1000원 이상의 종목은 동일한 값이 나오는데 1000원 이하의 종목은 상한가 값이 제대로 표시되지 않는 것 같습니다. 예를 들어 10/21일 우리들생명과학(종목코드 118000)은 상한가로 603원인데 수식으로 상한가 값을 구하면 600원이 나타납니다. 서로 금액이 다른 이유를 알려주세요~ 감사합니다. var : 하한가(0), DnLimit(0); var : dn1(0), dn2(0), dn3(0), dn4(0), dn5(0),dn6(0); var : 상한가(0), UpLimit(0); var : up1(0), up2(0), up3(0), up4(0), up5(0),up6(0); if DayIndex == 0 then { if date >= 19981207 then { //거래소 98년 12월7일 가격제한폭 15%로 확대 변경됨 if date < 20050328 && CodeCategory() == 2 then //코스닥 2005년 3월28일 이전은 가격제한폭 12% DnLimit = (BP * 0.12); Else //코스닥 2005년 3월28일 이후 및 거래소98년12월 7일이후 15% DnLimit = (BP * 0.15); if CodeCategory() == 2 then { //코스닥 호가단위 ( 2003년 7월21일에 호가 단위 변경됨) if date >= 20030721 then { dn1 = int(DnLimit/100)*100; // 500,000원 이상의 하한가 호가 dn2 = int(DnLimit/100)*100; // 100,000원 이상 ~ 500,000원 미만의 하한가 호가 dn3 = int(DnLimit/100)*100; // 50,000원 이상 ~ 100,000원 미만의 하한가 호가 dn4 = int(DnLimit/50)*50; // 10,000원 이상 ~ 50,000원 미만의 하한가 호가 dn5 = int(DnLimit/10)*10; // 5,000원 이상 ~ 10,000원 미만의 하한가 호가 dn6 = int(DnLimit/5)*5; // 5,000원 미만의 하한가 호가 } else { // 코스닥 2003년7월21일 이전 dn1 = int(DnLimit/1000)*1000; dn2 = int(DnLimit/500)*500; dn3 = int(DnLimit/100)*100; dn4 = int(DnLimit/50)*50; dn5 = int(DnLimit/10)*10; dn6 = int(DnLimit/10)*10; } } Else { //거래소 호가단위 dn1 = int(DnLimit/1000)*1000; dn2 = int(DnLimit/500)*500; dn3 = int(DnLimit/100)*100; dn4 = int(DnLimit/50)*50; dn5 = int(DnLimit/10)*10; dn6 = int(DnLimit/5)*5; } if CodeCategory() == 1 or CodeCategory() == 2 then { //kospi, kosdaq If BP >= 500000 Then 하한가 = BP-dn1; Else If BP >= 100000 Then 하한가 = BP-dn2; Else If BP >= 50000 Then 하한가 = BP-dn3; Else If BP >= 10000 Then 하한가 = BP-dn4; Else If BP >= 5000 Then 하한가 = BP-dn5; Else 하한가 = BP-dn6; } else if CodeCategory() == 8 or CodeCategory() == 9 then { //ETF 하한가 = BP-dn6; } } if date >= 19981207 then { if date < 20050328 && CodeCategory() == 2 then UpLimit = (BP[0] * 1.12); Else UpLimit = (BP[0] * 1.15); if CodeCategory() == 2 then { if date >= 20030721 then { up1 = int(UpLimit/100+0.00001)*100; up2 = int(UpLimit/100+0.00001)*100; up3 = int(UpLimit/100+0.00001)*100; up4 = int(UpLimit/50+0.00001)*50; up5 = int(UpLimit/10+0.00001)*10; up6 = int(UpLimit/5+0.00001)*5; } else { up1 = int(UpLimit/1000+0.00001)*1000; up2 = int(UpLimit/500+0.00001)*500; up3 = int(UpLimit/100+0.00001)*100; up4 = int(UpLimit/50+0.00001)*50; up5 = int(UpLimit/10+0.00001)*10; up6 = int(UpLimit/10+0.00001)*10; } } Else { up1 = int(UpLimit/1000+0.00001)*1000; up2 = int(UpLimit/500+0.00001)*500; up3 = int(UpLimit/100+0.00001)*100; up4 = int(UpLimit/50+0.00001)*50; up5 = int(UpLimit/10+0.00001)*10; up6 = int(UpLimit/5+0.00001)*5; } if CodeCategory() == 1 || CodeCategory() == 2 then { If BP >= 500000 Then 상한가 = up1; Else If BP >= 100000 Then 상한가 = iff(up2>=500000, up1, up2); Else If BP >= 50000 Then 상한가 = iff(up3>=100000, up2, up3); Else If BP >= 10000 Then 상한가 = iff(up4>=50000, up3, up4); Else If BP >= 5000 Then 상한가 = iff(up5>=10000, up4, up5); Else 상한가 = iff(up6>=5000, up5, up6); } else if CodeCategory() == 8 || CodeCategory() == 9 then { // ETF 상한가 = up6; } } } plot1(상한가);
지표
답변 1
프로필 이미지

예스스탁 예스스탁 답변

2013-10-28 15:56:20

안녕하세요 예스스탁입니다. 1000미만의 종목이 호가단위가 1인데 해당 부분이 빠져있었습니다. 수정한 식입니다. var : 하한가(0), DnLimit(0); var : dn1(0), dn2(0), dn3(0), dn4(0), dn5(0),dn6(0),dn7(0); var : 상한가(0), UpLimit(0); var : up1(0), up2(0), up3(0), up4(0), up5(0),up6(0),Up7(0); if date >= 19981207 then { if date < 20050328 && CodeCategory() == 2 then DnLimit = (BP * 0.12); Else DnLimit = (BP * 0.15); if CodeCategory() == 2 then { if date >= 20030721 then { dn1 = int(DnLimit/100)*100; dn2 = int(DnLimit/100)*100; dn3 = int(DnLimit/100)*100; dn4 = int(DnLimit/50)*50; dn5 = int(DnLimit/10)*10; dn6 = int(DnLimit/5)*5; dn7 = int(DnLimit/1)*1; } else { dn1 = int(DnLimit/1000)*1000; dn2 = int(DnLimit/500)*500; dn3 = int(DnLimit/100)*100; dn4 = int(DnLimit/50)*50; dn5 = int(DnLimit/10)*10; dn6 = int(DnLimit/10)*10; dn7 = int(DnLimit/1)*1; } } Else { dn1 = int(DnLimit/1000)*1000; dn2 = int(DnLimit/500)*500; dn3 = int(DnLimit/100)*100; dn4 = int(DnLimit/50)*50; dn5 = int(DnLimit/10)*10; dn6 = int(DnLimit/5)*5; dn7 = int(DnLimit/1)*1; } if CodeCategory() == 1 or CodeCategory() == 2 then { if sdate < 20101004 Then{ If BP >= 500000 Then 하한가 = BP-dn1; Else If BP >= 100000 Then 하한가 = BP-dn2; Else If BP >= 50000 Then 하한가 = BP-dn3; Else If BP >= 10000 Then 하한가 = BP-dn4; Else If BP >= 5000 Then 하한가 = BP-dn5; Else If BP >= 1000 Then 하한가 = BP-dn6; Else 하한가 = BP-dn6; } else{ If BP >= 500000 Then 하한가 = BP-dn1; Else If BP >= 100000 Then 하한가 = BP-dn2; Else If BP >= 50000 Then 하한가 = BP-dn3; Else If BP >= 10000 Then 하한가 = BP-dn4; Else If BP >= 5000 Then 하한가 = BP-dn5; Else If BP >= 1000 Then 하한가 = BP-dn6; Else 하한가 = BP-dn7; } } else if CodeCategory() == 8 or CodeCategory() == 9 then { 하한가 = BP-dn6; } } if date >= 19981207 then { if date < 20050328 && CodeCategory() == 2 then UpLimit = (BP[0] * 1.12); Else UpLimit = (BP[0] * 1.15); if CodeCategory() == 2 then { if date >= 20030721 then { up1 = int(UpLimit/100+0.00001)*100; up2 = int(UpLimit/100+0.00001)*100; up3 = int(UpLimit/100+0.00001)*100; up4 = int(UpLimit/50+0.00001)*50; up5 = int(UpLimit/10+0.00001)*10; up6 = int(UpLimit/5+0.00001)*5; up7 = int(UpLimit/1+0.00001)*1; } else { up1 = int(UpLimit/1000+0.00001)*1000; up2 = int(UpLimit/500+0.00001)*500; up3 = int(UpLimit/100+0.00001)*100; up4 = int(UpLimit/50+0.00001)*50; up5 = int(UpLimit/10+0.00001)*10; up6 = int(UpLimit/10+0.00001)*10; up7 = int(UpLimit/1+0.00001)*1; } } Else { up1 = int(UpLimit/1000+0.00001)*1000; up2 = int(UpLimit/500+0.00001)*500; up3 = int(UpLimit/100+0.00001)*100; up4 = int(UpLimit/50+0.00001)*50; up5 = int(UpLimit/10+0.00001)*10; up6 = int(UpLimit/5+0.00001)*5; up7 = int(UpLimit/1+0.00001)*1; } if CodeCategory() == 1 || CodeCategory() == 2 then { if sdate < 20101004 Then{ If BP >= 500000 Then 상한가 = up1; Else If BP >= 100000 Then 상한가 = iff(up2>=500000, up1, up2); Else If BP >= 50000 Then 상한가 = iff(up3>=100000, up2, up3); Else If BP >= 10000 Then 상한가 = iff(up4>=50000, up3, up4); Else If BP >= 5000 Then 상한가 = iff(up5>=10000, up4, up5); Else If BP >= 1000 Then 상한가 = iff(up5>=5000, up5, up6); Else 상한가 = iff(up6>=1000, up6, up6); } Else{ If BP >= 500000 Then 상한가 = up1; Else If BP >= 100000 Then 상한가 = iff(up2>=500000, up1, up2); Else If BP >= 50000 Then 상한가 = iff(up3>=100000, up2, up3); Else If BP >= 10000 Then 상한가 = iff(up4>=50000, up3, up4); Else If BP >= 5000 Then 상한가 = iff(up5>=10000, up4, up5); Else If BP >= 1000 Then 상한가 = iff(up5>=5000, up5, up6); Else 상한가 = iff(up6>=1000, up6, up7); } } else if CodeCategory() == 8 || CodeCategory() == 9 then { // ETF 상한가 = up6; } } plot1(상한가); plot2(하한가); 즐거운 하루되세요 > 엠제이 님이 쓴 글입니다. > 제목 : 문의드립니다. > 아래 수식은 당일의 상한가/하한가를 구하는 수식입니다. 1000원 이상의 종목은 동일한 값이 나오는데 1000원 이하의 종목은 상한가 값이 제대로 표시되지 않는 것 같습니다. 예를 들어 10/21일 우리들생명과학(종목코드 118000)은 상한가로 603원인데 수식으로 상한가 값을 구하면 600원이 나타납니다. 서로 금액이 다른 이유를 알려주세요~ 감사합니다. var : 하한가(0), DnLimit(0); var : dn1(0), dn2(0), dn3(0), dn4(0), dn5(0),dn6(0); var : 상한가(0), UpLimit(0); var : up1(0), up2(0), up3(0), up4(0), up5(0),up6(0); if DayIndex == 0 then { if date >= 19981207 then { //거래소 98년 12월7일 가격제한폭 15%로 확대 변경됨 if date < 20050328 && CodeCategory() == 2 then //코스닥 2005년 3월28일 이전은 가격제한폭 12% DnLimit = (BP * 0.12); Else //코스닥 2005년 3월28일 이후 및 거래소98년12월 7일이후 15% DnLimit = (BP * 0.15); if CodeCategory() == 2 then { //코스닥 호가단위 ( 2003년 7월21일에 호가 단위 변경됨) if date >= 20030721 then { dn1 = int(DnLimit/100)*100; // 500,000원 이상의 하한가 호가 dn2 = int(DnLimit/100)*100; // 100,000원 이상 ~ 500,000원 미만의 하한가 호가 dn3 = int(DnLimit/100)*100; // 50,000원 이상 ~ 100,000원 미만의 하한가 호가 dn4 = int(DnLimit/50)*50; // 10,000원 이상 ~ 50,000원 미만의 하한가 호가 dn5 = int(DnLimit/10)*10; // 5,000원 이상 ~ 10,000원 미만의 하한가 호가 dn6 = int(DnLimit/5)*5; // 5,000원 미만의 하한가 호가 } else { // 코스닥 2003년7월21일 이전 dn1 = int(DnLimit/1000)*1000; dn2 = int(DnLimit/500)*500; dn3 = int(DnLimit/100)*100; dn4 = int(DnLimit/50)*50; dn5 = int(DnLimit/10)*10; dn6 = int(DnLimit/10)*10; } } Else { //거래소 호가단위 dn1 = int(DnLimit/1000)*1000; dn2 = int(DnLimit/500)*500; dn3 = int(DnLimit/100)*100; dn4 = int(DnLimit/50)*50; dn5 = int(DnLimit/10)*10; dn6 = int(DnLimit/5)*5; } if CodeCategory() == 1 or CodeCategory() == 2 then { //kospi, kosdaq If BP >= 500000 Then 하한가 = BP-dn1; Else If BP >= 100000 Then 하한가 = BP-dn2; Else If BP >= 50000 Then 하한가 = BP-dn3; Else If BP >= 10000 Then 하한가 = BP-dn4; Else If BP >= 5000 Then 하한가 = BP-dn5; Else 하한가 = BP-dn6; } else if CodeCategory() == 8 or CodeCategory() == 9 then { //ETF 하한가 = BP-dn6; } } if date >= 19981207 then { if date < 20050328 && CodeCategory() == 2 then UpLimit = (BP[0] * 1.12); Else UpLimit = (BP[0] * 1.15); if CodeCategory() == 2 then { if date >= 20030721 then { up1 = int(UpLimit/100+0.00001)*100; up2 = int(UpLimit/100+0.00001)*100; up3 = int(UpLimit/100+0.00001)*100; up4 = int(UpLimit/50+0.00001)*50; up5 = int(UpLimit/10+0.00001)*10; up6 = int(UpLimit/5+0.00001)*5; } else { up1 = int(UpLimit/1000+0.00001)*1000; up2 = int(UpLimit/500+0.00001)*500; up3 = int(UpLimit/100+0.00001)*100; up4 = int(UpLimit/50+0.00001)*50; up5 = int(UpLimit/10+0.00001)*10; up6 = int(UpLimit/10+0.00001)*10; } } Else { up1 = int(UpLimit/1000+0.00001)*1000; up2 = int(UpLimit/500+0.00001)*500; up3 = int(UpLimit/100+0.00001)*100; up4 = int(UpLimit/50+0.00001)*50; up5 = int(UpLimit/10+0.00001)*10; up6 = int(UpLimit/5+0.00001)*5; } if CodeCategory() == 1 || CodeCategory() == 2 then { If BP >= 500000 Then 상한가 = up1; Else If BP >= 100000 Then 상한가 = iff(up2>=500000, up1, up2); Else If BP >= 50000 Then 상한가 = iff(up3>=100000, up2, up3); Else If BP >= 10000 Then 상한가 = iff(up4>=50000, up3, up4); Else If BP >= 5000 Then 상한가 = iff(up5>=10000, up4, up5); Else 상한가 = iff(up6>=5000, up5, up6); } else if CodeCategory() == 8 || CodeCategory() == 9 then { // ETF 상한가 = up6; } } } plot1(상한가);