實習流水帳

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;



 


 

發佈了122 篇原創文章 · 獲贊 20 · 訪問量 44萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章