现在的位置: 首页 > 综合 > 正文

实习流水帐

2018年10月21日 ⁄ 综合 ⁄ 共 3139字 ⁄ 字号 评论关闭

1.华泰柏瑞沪深300ETF申购赎回清单

libname yugao "E:\yugao\work\htbr300ETF";
data yugao.ht120531;
   infile "Z:\300_0531.ETF" dlm="|" firstobs=15 obs=300 lrecl=1024;

   retain fundid fundname fundnum cashrep premise fixamount;
   length fundid $6 fundname $8 fundnum 4.  cashrep $1 premise 7. fixamount 8.;

   input fundid fundname fundnum cashrep premise fixamount;

   
   Fundid1="510301";
   CreationRedemptionUnit=900000;
   MaxCashRatio=0.30000;
   Publish="1";
   CreationRedemption="1";
   Recordnum=300;
   EstimateCashComponent=-17975.00;
   TradingDay="20120530";
   PreTradingDay="20120529";
   CashComponent=-17875.00;
   NAVperCU=2386394.00;
   NAV=2.652;

label 
       fundid="股票代码"
       fundname="股票名称"
	   fundnum="股票数量"
	   cashrep="现金替代标志"
	   premise="现金替代溢价比例"
	   fixamount="固定替代金额"


       Fundid1="一级市场基金代码"
       CreationRedemptionUnit="最小申购、赎回单位(单位:份)" 
	   MaxCashRatio="现金替代比例上限?"
	   Publish="是否需要公布IOPV?"
	   CreationRedemption="申购、赎回的允许情况?"
	   Recordnum="申购数量"
	   EstimateCashComponent="预估现金部分(单位:元) "
	   TradingDay="交易日期"
	   PreTradingDay="交易前一期"
	   CashComponent="现金差额(单位:元) "
       NAVperCU="最小申购、赎回单位资产净值(单位:元)"
       NAV="基金份额净值(单位:元)";
run;

proc compare base=yugao.ht120530 compare=yugao.ht120531;
    var fundnum;
run;
quit;

2.分红派息

关键词:除权价

data test;
   input fundid $6. fundnum spj xjhl sgl;
   label fundid      =  "股票代码"
         fundnum     =  "股票数量"
         spj         =  "收盘价" 
         xjhl        =  "现金红利派息"
         sgl         =  "送股转股比率"
;
   cards;
600143 500 10.82 0.24  0.6
600123 200 48.45 0.49  1.0
600183 300 8.040 0.288 0.3
600276 300 26.12 0.008 0.1 
002304 100 32.87 1.35  0.2
600528 300 8.22  0.09   0
600008 500 5.40  0.117  0
600026 300 5.89  0.09   0
600037 300 8.32  0.09   0
600518 700 12.67 0.045  0
600694 100 32.87 0.27   0
;run;
data test1;
   set test;
   if sgl^=0 then do;
      cqj=(spj-xjhl)/(1+sgl);end;
   else cqj=0;
run;

proc print data=test1;run;

proc sql; 
      create table test2 as
         select *,
	         sum(xjhl*fundnum) as xjhl_tot,
			 fundnum*(1+sgl) as fundnum_new
         from test1;
quit;
proc print data=test2;run;

3.沪深300与上证50点差计算

*从数据库读数据;
libname base oledb provider=sqloledb 
properties=("data source" = "IP"
            "user id"     = "用户"
			"password"    = "密码"
			"initial catalog" = "数据库名");
*读取分时数据,沪深300和上证50;
data a;
  set base.oneminsh000300;
  keep time close;
run;
data b;
   set base.oneminsz000016 (rename=(close=close1));
   keep time close1;
run;
*合并两数据;
proc sql;
   create table new as
   select *
   from  a left join b
   on a.time=b.time;
quit;
*数据进行标准化;
proc standard data=new mean=0 std=1 out=new1;
   var close close1;
run;
*计算差值;
proc sql;
   create table new2 as
   select time,
          (close-close1) as _n_close
    from new1;
quit;
*作图;
ods graphics on;
proc timeseries data=sasuser.new2 out=need plot=(series);
   id time interval=minute accumulate=median;
   var _n_close;
run;
ods graphics off;

4.轮动情况

*读取中证500指数一天的分秒数据,计算5日均线
5日均线由前四天价格和该天实时价格平均所得;
data timesellsz399905;
   set sasuser.timesellsz399905;
   m5_price=(14641.593+price)/5;
run;
*比较5日均线和改天实时数据的轮动情况,考察是否穿越,以判断
时候开仓平仓等交易行为;
proc sgplot data=timesellsz399905;
   series x=time y=price;
   series x=time y=m5_price;
run;

5.ETF与股指点差

*数据准备;
data jiashi;
   set sasuser.jiashi_etf(rename=(open=open1 high=high1 low=low1 close=close1));
   date=put(datepart(time),yymmdd10.);
   keep date open1 high1 low1 close1 amount; 
run;

data hs300;
   set sasuser.hs300;
   date=put(datepart(time),yymmdd10.);
   keep date open high low close; 
   if date>="2012-05-28";
run;

data need;
   merge jiashi  hs300 (in=a);
   by date;
   if a=1 then output; 
run;

data need_1;
   set need;
   if _n_=1 then amount=open*300/open1;
   else amount=808389.90536;
run;


data need1;
   set need_1;
   dif_open=(amount*open1-300*open)/300;
   dif_high=(amount*high1-300*high)/300;
   dif_low= (amount*low1-300*low)/300;
   dif_close=(amount*close1-300*close)/300;
   keep date dif_open dif_high dif_low dif_close;
run;

 

 

抱歉!评论已关闭.