| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,8 +14,8 @@ getcsasyms:{select sym:necode2sym each code,`$name from update `$code from {lowe | |||
| 14 | 14 | getcsisyms:{ /ex: getcsisyms[] or getcsisyms[`SH] or getcsisyms[`SZ] | |
| 15 | 15 | qrystr:$[null x;qs:"CODE:_in_0000001,0000016,0000300,0000905,0000906,0000852,1399001,1399005,1399006,1399106";x=`SH;"IS_INDEX:true;EXCHANGE:CNSESH";x=`SZ;"IS_INDEX:true;EXCHANGE:CNSESZ";qs]; select sym:necode2sym each`$code,`$name from {lower[cols x]xcol x}.j.k[.Q.hg"http://quotes.money.163.com/hs/service/hsindexrank.php?host=/hs/service/hsindexrank.php&page=0&query=",qrystr,"&fields=no,SYMBOL,NAME&sort=SYMBOL&order=asc&count=5000&type=query"]`list}; | |
| 16 | 16 | ||
| 17 | - /读A股、指数的日行情: getcsbar1d[`000001.SH;.z.D-3;.z.D] | ||
| 18 | - getcsbar1d:{[mysym;startdate;enddate]`date xasc update sym:mysym,open:?[open>0;open;prevclose],high:?[high>0;high;prevclose],low:?[low>0;low;prevclose],close:?[close>0;close;prevclose],0f^mv,0f^fmv from `date`sym`prevclose`open`high`low`close`volume`amount`mv`fmv xcol("DS FFFFFFFFF";enlist",")0: .Q.hg "http://quotes.money.163.com/service/chddata.html?code=",string[sym2necode mysym],"&start=",ssr[string[startdate];".";""],"&end=",ssr[string enddate;".";""],"&fields=LCLOSE;TOPEN;HIGH;LOW;TCLOSE;VOTURNOVER;VATURNOVER;TCAP;MCAP"}; | ||
| 17 | + /读A股、指数的日行情: getcsbar[`000001.SH;.z.D-3;.z.D] | ||
| 18 | + getcsbar:{[mysym;startdate;enddate]`date xasc update sym:mysym,open:?[open>0;open;prevclose],high:?[high>0;high;prevclose],low:?[low>0;low;prevclose],close:?[close>0;close;prevclose],0f^mv,0f^fmv from `date`sym`prevclose`open`high`low`close`volume`amount`mv`fmv xcol("DS FFFFFFFFF";enlist",")0: .Q.hg "http://quotes.money.163.com/service/chddata.html?code=",string[sym2necode mysym],"&start=",ssr[string[startdate];".";""],"&end=",ssr[string enddate;".";""],"&fields=LCLOSE;TOPEN;HIGH;LOW;TCLOSE;VOTURNOVER;VATURNOVER;TCAP;MCAP"}; | ||
| 19 | 19 | ||
| 20 | 20 | /读A股最新行情: prevclose昨收价,open开盘价,high最高价,low最低价,close最新价,volume成交量,amount成交金额,mv总市值,fmv流通市值,eps每股收益,zdf涨跌幅,zf震幅,hsl换手率,pe市盈率 | |
| 21 | 21 | getcsataq:{ /ex: getcsataq[] or getcsataq `000001.SZ or getcsataq `600036.SH | |
@@ -26,31 +26,31 @@ getcsitaq:{ /ex: getcsitaq[] or getcsitaq[`000001.SH] or getcsitaq[`399001.SZ] | |||
| 26 | 26 | qrystr:$[null x;qs:"CODE:_in_0000001,0000016,0000300,0000905,0000906,0000852,1399001,1399005,1399006,1399106";-11h=type[x];"CODE:_in_",string[sym2necode x];qs]; select dt:"Z"$time,sym:necode2sym each`$code,name,prevclose:yestclose,open,high,low,close:price,volume,amount:turnover,mv:0f,fmv:0f,eps:0f,zdf:percent,zf:zhenfu,hsl:0f,pe:0f from {lower[cols x]xcol x}.j.k[.Q.hg"http://quotes.money.163.com/hs/service/hsindexrank.php?host=/hs/service/hsindexrank.php&page=0&query=",qrystr,"&fields=no,TIME,SYMBOL,NAME,PRICE,UPDOWN,PERCENT,zhenfu,VOLUME,TURNOVER,YESTCLOSE,OPEN,HIGH,LOW&sort=SYMBOL&order=asc&count=25&type=query"]`list}; | |
| 27 | 27 | ||
| 28 | 28 | /中金所行情 | |
| 29 | - getcfebar1d:{[mydate]if[-14h<>type mydate;:`error_para];et:flip`date`sym`open`high`low`close`volume`amount`openint!"DSFFFFFFF"$\:(); | ||
| 29 | + getcfebar:{[mydate]if[-14h<>type mydate;:`error_para];et:flip`date`sym`open`high`low`close`volume`amount`openint!"DSFFFFFFF"$\:(); | ||
| 30 | 30 | if[mydate<2010.04.16;:et];datestr:string[mydate]_/ 4 6;monthstr:6#datestr;daystr:-2#datestr; | |
| 31 | 31 | `date xcols update date:mydate from{update {`$string[x],".CFE"}each sym,0f^open,0f^high,0f^low,0f^close,amount*10000.0 from select from x where sym like "*[0-9]"} | |
| 32 | 32 | `sym`open`high`low`close xcols`sym`open`high`low`volume`amount`openint`close xcol("S",7#"F";enlist",")0: | |
| 33 | 33 | .Q.hg"http://www.cffex.com.cn/sj/hqsj/rtj/",monthstr,"/",daystr,"/",datestr,"_1.csv"}; | |
| 34 | 34 | ||
| 35 | 35 | /上期所行情 | |
| 36 | - getshfbar1d:{[mydate]if[-14h<>type mydate;:`error_para];et:flip`date`sym`open`high`low`close`volume`amount`openint!"DSFFFFFFF"$\:(); | ||
| 37 | - r:@[.j.k;.Q.hg"http://www.shfe.com.cn/data/dailydata/kx/kx",(string[mydate]_/4 6),".dat";`]; | ||
| 36 | + getshfbar:{[mydate]if[-14h<>type mydate;:`error_para];et:flip`date`sym`open`high`low`close`volume`amount`openint!"DSFFFFFFF"$\:(); | ||
| 37 | + r:@[.j.k;ssr[;":\"\",";":0,"].Q.hg"http://www.shfe.com.cn/data/dailydata/kx/kx",(string[mydate]_/4 6),".dat";`]; | ||
| 38 | 38 | :$[99h=type r; | |
| 39 | - {select from x where sym like "*[0-9].SHF"}select date:mydate,sym:(`$(upper -2_/:trim PRODUCTID),'DELIVERYMONTH,\:".SHF"),open:{$[y~"";0f;y]}\[OPENPRICE],high:{$[y~"";0f;y]}\[HIGHESTPRICE],low:{$[y~"";0f;y]}\[LOWESTPRICE],close:{$[y~"";0f;y]}\[CLOSEPRICE],volume:{$[y~"";0f;y]}\[VOLUME],amount:0f,openint:{$[y~"";0f;y]}\[OPENINTEREST] from r`o_curinstrument; | ||
| 39 | + {select from x where sym like "*[0-9].SHF"}select date:mydate,sym:(`$(upper -2_/:trim PRODUCTID),'DELIVERYMONTH,\:".SHF"),open:OPENPRICE,high:HIGHESTPRICE,low:LOWESTPRICE,close:CLOSEPRICE,volume:VOLUME,amount:0f,openint:OPENINTEREST from select from r[`o_curinstrument] where (10h=type each DELIVERYMONTH)&10h=type each PRODUCTID; | ||
| 40 | 40 | et]; | |
| 41 | 41 | }; | |
| 42 | 42 | ||
| 43 | 43 | /上期能源行情 | |
| 44 | - getinebar1d:{[mydate]if[-14h<>type mydate;:`error_para];et:flip`date`sym`open`high`low`close`volume`amount`openint!"DSFFFFFFF"$\:(); | ||
| 44 | + getinebar:{[mydate]if[-14h<>type mydate;:`error_para];et:flip`date`sym`open`high`low`close`volume`amount`openint!"DSFFFFFFF"$\:(); | ||
| 45 | 45 | if[mydate<2018.03.26;:et]; | |
| 46 | - r:@[.j.k;.Q.hg"http://www.ine.cn/data/dailydata/kx/kx",(string[mydate]_/4 6),".dat";`]; | ||
| 46 | + r:@[.j.k;ssr[;":\"\",";":0,"] .Q.hg"http://www.ine.cn/data/dailydata/kx/kx",(string[mydate]_/4 6),".dat";`]; | ||
| 47 | 47 | :$[99h=type r; | |
| 48 | - {select from x where sym like "*[0-9].INE"}select date:mydate,sym:(`$(upper -2_/:trim PRODUCTID),'DELIVERYMONTH,\:".INE"),open:{$[y~"";0f;y]}\[OPENPRICE],high:{$[y~"";0f;y]}\[HIGHESTPRICE],low:{$[y~"";0f;y]}\[LOWESTPRICE],close:{$[y~"";0f;y]}\[CLOSEPRICE],volume:{$[y~"";0f;y]}\[VOLUME],amount:0f,openint:{$[y~"";0f;y]}\[OPENINTEREST] from r`o_curinstrument; | ||
| 48 | + {select from x where sym like "*[0-9].INE"}select date:mydate,sym:(`$(upper -2_/:trim PRODUCTID),'DELIVERYMONTH,\:".INE"),open:OPENPRICE,high:HIGHESTPRICE,low:LOWESTPRICE,close:CLOSEPRICE,volume:VOLUME,amount:0f,openint:OPENINTEREST from select from r[`o_curinstrument] where (10h=type each DELIVERYMONTH)&10h=type each PRODUCTID; | ||
| 49 | 49 | et]; | |
| 50 | 50 | }; | |
| 51 | 51 | ||
| 52 | 52 | /大商所行情 | |
| 53 | - getdcebar1d:{[mydate]if[-14h<>type mydate;:`error_para]; | ||
| 53 | + getdcebar:{[mydate]if[-14h<>type mydate;:`error_para]; | ||
| 54 | 54 | dceprod:`name xkey select `$ssr[;"[0-9]";""]each sym,`$ssr[;"[0-9]";""]each name from | |
| 55 | 55 | {select from x where sym like "*[0-9][0-9][0-9][0-9]"}flip`sym`name`id!flip last last .j.k 1_-2_ | |
| 56 | 56 | .Q.hg"http://webftcn.hermes.hexun.com/shf/sortlist?block=431&number=1000&title=1&commodityid=0&direction=0&start=0&column=code,name"; /大商所品种及其名称 | |
@@ -65,7 +65,7 @@ czchttp:{[path] r:`:http://www.czce.com.cn "GET ",path," HTTP/1.1\r\nHost: www.c | |||
| 65 | 65 | r:`:http://www.czce.com.cn "GET ",path," HTTP/1.1\r\nHost: www.czce.com.cn\r\nAccept-Encoding: identity\r\n",(.czce.Cookie::4_first ck),"\r\n\r\n"]; | |
| 66 | 66 | :(vs[" ";first "\r\n" vs first["\r\n\r\n" vs r]][1]; (first[ss[r;"\r\n\r\n"]]+4)_r); /(status;body) | |
| 67 | 67 | }; | |
| 68 | - getczcbar1d:{[mydate]if[-14h<>type mydate;:`error_para];dstr:string[mydate]_/4 6; et:flip`date`sym`open`high`low`close`volume`amount`openint!"DSFFFFFFF"$\:(); | ||
| 68 | + getczcbar:{[mydate]if[-14h<>type mydate;:`error_para];dstr:string[mydate]_/4 6; et:flip`date`sym`open`high`low`close`volume`amount`openint!"DSFFFFFFF"$\:(); | ||
| 69 | 69 | :`date xcols update date:mydate from{[mydate;x]select {[d;s]s:string[s];i:0;while[(i<9)&(`month$d)>"M"$"20",yymm:string[i],(-3#s);i+:1];`$(-3_s),yymm,".CZC"}[mydate]each sym,open,high,low,close,volume,amount*10000f,openint from x where sym like "*[0-9]"}[mydate] | |
| 70 | 70 | $[mydate>2015.09.18; | |
| 71 | 71 | [r:czchttp["/cn/DFSStaticFiles/Future/",(4#dstr),"/",dstr,"/FutureDataDaily.txt"]; | |
@@ -101,44 +101,44 @@ gethxbar:{[mysym;startdate;num;bartype] /"num:x or -x,x<=1000; bartype:`1m`5m` | |||
| 101 | 101 | select date:"D"$8#/:string[`long$time],sym:mysym,time:`timespan$"T"$-6#/:string[`long$time],prevclose:lastclose%rr[4],open%rr[4],high%rr[4],low%rr[4],close%rr[4],volume,amount,openint:openinterest from rrr]; | |
| 102 | 102 | }; | |
| 103 | 103 | ||
| 104 | - /下载数据并以分列表形式保存在hdb : setcsbar1d[] | ||
| 105 | - setcsbar1d:{0N!(.z.T;`start...); | ||
| 104 | + /下载数据并以分列表形式保存在hdb : setcsbar[] | ||
| 105 | + setcsbar:{0N!(.z.T;`start...); | ||
| 106 | 106 | hdbpath:hsym `$hdbp:ssr[getenv`QHOME;"\\";"/"],"/../hdb"; /hdb路径,如果没有定义QHOME需要修改 | |
| 107 | 107 | @[.Q.chk;hdbpath;`];@[system;"l ",hdbp;`]; | |
| 108 | - newdatelist:exec date from gettrddt[;.z.D] 1+$[`csbar1d in key `.;2010.01.01^exec last date from select max date from csbar1d;2010.01.01]; | ||
| 108 | + newdatelist:exec date from gettrddt[;.z.D] 1+$[`csbar in key `.;2010.01.01^exec last date from select max date from csbar;2010.01.01]; | ||
| 109 | 109 | if[0=count newdatelist;:`no.upd.required]; | |
| 110 | 110 | dt:exec first dt from getcsitaq[`000001.SH]; | |
| 111 | 111 | if[(1=count[newdatelist])&(last[newdatelist]=`date$dt)&(15:01:00<`time$dt); | |
| 112 | 112 | t:select date:`date$dt,sym,prevclose,open,high,low,close,volume,amount,mv,fmv from getcsataq[],getcsitaq[]; | |
| 113 | - if[(98h=type t)&(0<count t);(` sv (hdbpath;`csbar1d;`) ) upsert .Q.en[hdbpath] `sym xasc t;0N!(.z.T;`date$dt;`updated.)]; | ||
| 113 | + if[(98h=type t)&(0<count t);(` sv (hdbpath;`csbar;`) ) upsert .Q.en[hdbpath] `sym xasc t;0N!(.z.T;`date$dt;`updated.)]; | ||
| 114 | 114 | 0N!(.z.T;`stop.); | |
| 115 | 115 | :()]; | |
| 116 | 116 | {[mysym;firstdate;lastdate;hdbpath]0N!(.z.T;mysym;firstdate;lastdate); | |
| 117 | - (` sv (hdbpath;`csbar1d;`) ) upsert .Q.en[hdbpath]select date,sym,prevclose,open,high,low,close,volume,amount,mv,fmv from getcsbar1d[mysym;firstdate;lastdate]; | ||
| 117 | + (` sv (hdbpath;`csbar;`) ) upsert .Q.en[hdbpath]select date,sym,prevclose,open,high,low,close,volume,amount,mv,fmv from getcsbar[mysym;firstdate;lastdate]; | ||
| 118 | 118 | }[;first newdatelist;last newdatelist;hdbpath]each asc distinct exec sym from getcsisyms[],getcsasyms[]; | |
| 119 | - @[` sv (hdbpath;`csbar1d;`);`date`sym;`g#]; | ||
| 119 | + @[` sv (hdbpath;`csbar;`);`date`sym;`g#]; | ||
| 120 | 120 | 0N!(.z.T;`stop.); | |
| 121 | 121 | }; | |
| 122 | 122 | ||
| 123 | - /将分列表csbar1d保存为分区表csbar1dp(..p=partitioned) | ||
| 124 | - setcsbar1dp:{[startdate;enddate]0N!(.z.T;`start...); | ||
| 123 | + /将分列表csbar保存为分区表csbarp(..p=partitioned) | ||
| 124 | + setcsbarp:{[startdate;enddate]0N!(.z.T;`start...); | ||
| 125 | 125 | hdbpath:hsym `$hdbp:ssr[getenv`QHOME;"\\";"/"],"/../hdb"; /hdb路径,如果没有定义QHOME需要修改 | |
| 126 | 126 | .Q.chk hdbpath;system "l ",hdbp; | |
| 127 | 127 | {[dt;hdbpath]0N!(.z.T;dt;hdbpath); | |
| 128 | - (` sv (hdbpath;`$string dt;`csbar1dp;`) ) set .Q.en[hdbpath]`sym xasc select sym,prevclose,open,high,low,close,volume,amount,mv,fmv from csbar1d where date=dt; | ||
| 129 | - }[;hdbpath]each exec distinct date from csbar1d where date within (startdate;enddate); | ||
| 128 | + (` sv (hdbpath;`$string dt;`csbarp;`) ) set .Q.en[hdbpath]`sym xasc select sym,prevclose,open,high,low,close,volume,amount,mv,fmv from csbar where date=dt; | ||
| 129 | + }[;hdbpath]each exec distinct date from csbar where date within (startdate;enddate); | ||
| 130 | 130 | }; | |
| 131 | 131 | ||
| 132 | - /下载期货行情数据并以分列表形式保存在hdb : setcfbar1d[] | ||
| 133 | - setcfbar1d:{0N!(.z.T;`start...); | ||
| 132 | + /下载期货行情数据并以分列表形式保存在hdb : setcfbar[] | ||
| 133 | + setcfbar:{0N!(.z.T;`start...); | ||
| 134 | 134 | hdbpath:hsym `$hdbp:ssr[getenv`QHOME;"\\";"/"],"/../hdb"; /hdb路径,如果没有定义QHOME需要修改 | |
| 135 | 135 | @[.Q.chk;hdbpath;`];@[system;"l ",hdbp;`]; | |
| 136 | - newdatelist:exec date from gettrddt[;.z.D] 1+$[`cfbar1d in key `.;2010.01.01^exec last date from select max date from cfbar1d;2010.01.01]; | ||
| 136 | + newdatelist:exec date from gettrddt[;.z.D] 1+$[`cfbar in key `.;2010.01.01^exec last date from select max date from cfbar;2010.01.01]; | ||
| 137 | 137 | if[0=count newdatelist;:`no.upd.required]; | |
| 138 | 138 | {[dt;hdbpath]0N!(.z.T;dt;hdbpath); | |
| 139 | - (` sv (hdbpath;`cfbar1d;`) ) upsert .Q.en[hdbpath]`sym xasc select date,sym,open,high,low,close,volume,amount,openint from | ||
| 140 | - getcfebar1d[dt],getshfbar1d[dt],getinebar1d[dt],getdcebar1d[dt],getczcbar1d[dt]; | ||
| 139 | + (` sv (hdbpath;`cfbar;`) ) upsert .Q.en[hdbpath]`sym xasc select date,sym,open,high,low,close,volume,amount,openint from | ||
| 140 | + getcfebar[dt],getshfbar[dt],getinebar[dt],getdcebar[dt],getczcbar[dt]; | ||
| 141 | 141 | }[;hdbpath]each newdatelist; | |
| 142 | - @[` sv (hdbpath;`cfbar1d;`);`date`sym;`g#]; | ||
| 142 | + @[` sv (hdbpath;`cfbar;`);`date`sym;`g#]; | ||
| 143 | 143 | 0N!(.z.T;`stop.); | |
| 144 | 144 | }; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments