Function my_Get1mETF50_FuturesAndSpot(TargetDate);
Begin
BegT:=TargetDate;
EndT:=TargetDate+16/24;
setsysparam(Pn_cycle(),Cy_1m()); //1分钟
setsysparam(Pn_precision(),4);
//初始化
m1 := select datetimetostr(['date']) as '日期',
['close'] as '期货收盘价'
from markettable
datekey BegT to EndT
of 'IH1510' End;
m2 := select datetimetostr(['date']) as '日期',
['close'] as '现货收盘价'
from markettable
datekey BegT to EndT
of 'SH000016' End;
m := select [1].['日期'],['期货收盘价'], ['现货收盘价']
from m1 join m2 on [1].['日期'] = [2].['日期'] end;
return m;
End;
Function my_Get1mSellAndBuy(TargetDate,optionCodes);
Begin
//optionCodes :=array('OP10000416','OP10000417','OP10000425',
//'OP10000410','OP10000413','OP10000420');
ETF50Code := 'SH510050';
BegT:=TargetDate-9/24;
EndT:=TargetDate+16/24;
setsysparam(Pn_cycle(),Cy_1m()); //1分钟
setsysparam(Pn_precision(),4);
//初始化
marr := array();
//查询
for i:=0 to length(optionCodes)-1
do
marr[i] := select datetimetostr(['date']) as '日期',
['sale1'] as concat(optionCodes[i]['代码'],'卖一价'),
['buy1'] as concat(optionCodes[i]['代码'],'买一价')
from markettable
datekey BegT to EndT
of optionCodes[i] End;
mETF := select datetimetostr(['date']) as '日期',
['close'] as concat(ETF50Code,'收盘价')
from markettable
datekey BegT to EndT
of ETF50Code End;
//返回结果
return marr[0]|marr[1]|marr[2]|marr[3]|marr[4]|marr[5]|mETF;
End;
Function my_Get5mETF50(TargetDate);
Begin
BegT:=TargetDate;
EndT:=TargetDate+16/24;
setsysparam(Pn_cycle(),Cy_5m()); //5分钟
setsysparam(Pn_precision(),4);
return
select datetimetostr(['date']) as '日期',
['open'] as '开盘价',
['close'] as '收盘价'
from markettable
datekey BegT to EndT
of 'SH510050'
End;
End;
Function my_GetSheet4Data(TargetDate);
Begin
//返回sheet4的数据表:241行*13列
optionCodes := my_GetTop3CallAndPut(TargetDate);
return my_Get1mSellAndBuy(TargetDate,optionCodes);
End;
Function my_GetTop3CallAndPut(TargetDate);
Begin
callCodes := array('OP10000405','OP10000406','OP10000407','OP10000408','OP10000409',
'OP10000415','OP10000416','OP10000417',
'OP10000421','OP10000423','OP10000425');
putCodes := array('OP10000410','OP10000411','OP10000412','OP10000413','OP10000414',
'OP10000418','OP10000419','OP10000420',
'OP10000422','OP10000424','OP10000426');
allCodes := array();
allCodes[0] := callCodes;
allCodes[1] := putCodes;
BegT:=TargetDate;
EndT:=TargetDate+16/24;
setsysparam(Pn_cycle(),Cy_day()); //日线
setsysparam(Pn_precision(),4);
//初始化
mTemp := array();
//查询成交量排在前3位的Call和Put
for i:=0 to 1
do
mTemp[i] := select drange (0 to 2)
['StockID'] as '代码'
from markettable
datekey BegT to EndT
of allCodes[i]
order by ['Vol'] Desc
End;
//mTop返回最高的三个call和put的StockID ,按照代码(执行价格)分别排序
mTop := array();
for i:=0 to 1
do
mTop[i]:= select *
from mTemp[i]
order by ['代码'] Asc
End;
return (mTop[0] union mTop[1]);
End;