첨부 이미지
그림1
요즘 예스스팟 기능을 익히고 있는데 사용할수록 굉장하다는 생각이 절로 듭니다.
훌륭한 프로그램을 만들어 주셔서 감사드립니다.
게다가 예스스팟 매뉴얼이 워낙 잘 만들어져 있어서 연습하는데 그리 어렵지 않네요.
다만 사전식으로 만들어져 있어서 예제에 없는 부분은 활용하기가 난감한 면이 있습니다.
그래서 엑셀에 로그를 출력하는 방법을 찾느라 좀 헤맸습니다.
무엇보다도 모의투자가 지원되지 않는 종목은 위 그림처럼 출력해서 전진분석을 하시면 될 겁니다.
예스랭귀지의 print문처럼 엑셀에 로그를 출력하려면 SetRowData를 사용하면 되는데 예제가 없길래 제가 만든 예제를 올려드립니다.
마지막행 다음 행에 로그를 찍는 간단 예제입니다.
BuyCallXlRow = xls1.GetRowCount(1) + 1;
xls1.SetRowData(1, "A" + BuyCallXlRow, tm, BuyCallCode, "매수", BuyCallPrice, vol);
예제5.합성선물의 내용을 엑셀로 출력하도록 수정한 내용입니다.
/*스크립트시작-----------------------------------------------------*/
var Start;
var BuyCallCode;
var BuyPutCode;
var SellCallCode;
var SellPutCode;
var BuyCallXlRow;
var BuyPutXlRow;
var SellCallRow;
var SellPutRow;
function Main_OnStart()
{
Main.MessageLog("시작");
Start = 0;
var sData = xls1.GetData(1, "A1");
if (sData != "거래일시")
{
xls1.SetRowData(1, "A1","거래일시","거래상품","매매구분","단가","수량","총매매금액","수익");
}
}
function C1_OnRiseSignal(Signal)
{
Main.MessageLog("신호완성/"+Signal.signalKind);
D = new Date();
YYYY = D.getFullYear();
MM = D.getMonth() + 1;
DD = D.getDate();
hh = D.getHours();
mm = D.getMinutes();
tm = YYYY+"/"+MM+"/"+DD+" "+hh+":"+mm;
if (Signal.signalKind == 1 )
{
Start = 1;
BuyCallCode = Option.GetATMCallRecent(0,0);
BuyPutCode = Option.GetATMPutRecent(0,0);
var BuyCallPrice = Option.GetAskByCode(BuyCallCode,2);
var BuyPutPrice = Option.GetBidByCode(BuyPutCode,2);
A1.OrderBuy(BuyCallCode, Vol, BuyCallPrice, 0);
A1.OrderSell(BuyPutCode, Vol, BuyPutPrice, 0);
Main.MessageLog("합성선물매수");
BuyCallXlRow = xls1.GetRowCount(1) + 1;
xls1.SetRowData(1, "A" + BuyCallXlRow, tm, BuyCallCode, "매수", BuyCallPrice, vol, BuyCallPrice * vol * 500000);
BuyCallXlRow = BuyCallXlRow + 1;
xls1.SetRowData(1, "A" + BuyCallXlRow, tm, BuyCallCode, "평가");
BuyPutXlRow = BuyCallXlRow + 1;
xls1.SetRowData(1, "A" + BuyPutXlRow, tm, BuyPutCode, "매수", BuyPutPrice, vol, BuyPutPrice * vol * 500000);
BuyPutXlRow = BuyPutXlRow + 1;
xls1.SetRowData(1, "A" + BuyPutXlRow, tm, BuyPutCode, "평가");
}
if (Start == 1 && Signal.signalKind == 2 )
{
var BxCallPrice = Option.GetBidByCode(BuyCallCode, 2);
var BxPutPrice = Option.GetAskByCode(BuyPutCode, 2);
A1.OrderSell(BuyCallCode, Vol, BxCallPrice, 0);
A1.OrderBuy(BuyPutCode, Vol, BxPutPrice, 0);
Main.MessageLog("합성선물매수청산");
xls1.SetRowData(1, "A" + BuyCallXlRow, tm, BuyCallCode, "매수청산", BxCallPrice, vol);
xls1.SetRowData(1, "F" + BuyCallXlRow, BxCallPrice * vol * 500000,BxCallPrice - BuyCallPrice);
xls1.SetRowData(1, "A" + BuyPutXlRow, tm, BuyPutCode, "매수청산", BxPutPrice, vol);
xls1.SetRowData(1, "F" + BuyPutXlRow, BxPutPrice * vol * 500000,BxPutPrice - BuyPutPrice);
}
if (Signal.signalKind == 3 )
{
Start = 1;
SellCallCode = Option.GetATMCallRecent(0,0);
SellPutCode = Option.GetATMPutRecent(0,0);
var SellCallPrice = Option.GetBidByCode(SellCallCode,2);
var SellPutPrice = Option.GetAskByCode(SellPutCode,2);
A1.OrderSell(SellCallCode, Vol, SellCallPrice , 0);
A1.OrderBuy(SellPutCode, Vol, SellPutPrice, 0);
Main.MessageLog("합성선물매도");
SellCallXlRow = xls1.GetRowCount(1) + 1;
xls1.SetRowData(1, "A" + SellCallXlRow, tm, SellCallCode, "매도", SellCallPrice, vol, SellCallPrice * vol * 500000);
SellCallXlRow = SellCallXlRow + 1;
xls1.SetRowData(1, "A" + SellCallXlRow, tm, SellCallCode, "평가");
SellPutXlRow = SellCallXlRow + 1;
xls1.SetRowData(1, "A" + SellPutXlRow, tm, SellPutCode, "매도", SellPutPrice, vol, SellPutPrice * vol * 500000);
SellPutXlRow = SellPutXlRow + 1;
xls1.SetRowData(1, "A" + SellPutXlRow, tm, SellPutCode, "평가");
}
if (Start == 1 && Signal.signalKind == 4 )
{
var SxCallPrice = Option.GetAskByCode(SellCallCode, 2);
var SxPutPrice = Option.GetBidByCode(SellPutCode, 2);
A1.OrderBuy(SellCallCode, Vol, SxCallPrice, 0);
A1.OrderSell(SellPutCode, Vol, SxPutPrice, 0);
Main.MessageLog("합성선물매도청산");
xls1.SetRowData(1, "A" + SellCallXlRow, tm, SellCallCode, "매도청산", SxCallPrice, vol);
xls1.SetRowData(1, "F" + SellCallXlRow, SxCallPrice * vol * 500000, SellCallPrice - SxCallPrice);
xls1.SetRowData(1, "A" + SellPutXlRow, tm, SellPutCode, "매도청산", SxPutPrice, vol);
xls1.SetRowData(1, "F" + SellPutXlRow, SxPutPrice * vol * 500000, SellPutPrice - SxPutPrice);
}
}
/*스크립트끝-------------------------------------------------------*/