楼主: wanwanle2
3333 3

[程序分享] 基于SAS平台的证券K线图 [推广有奖]

  • 1关注
  • 22粉丝

博士生

87%

还不是VIP/贵宾

-

威望
0
论坛币
323 个
通用积分
294.6629
学术水平
16 点
热心指数
18 点
信用等级
14 点
经验
286983 点
帖子
307
精华
0
在线时间
370 小时
注册时间
2011-4-13
最后登录
2024-4-23

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
把以前的程序改了下,价格和成交量可以分块显示。
主要的问题是程序不能实现数据量和图形字符大小的匹配问题,两者动其一,第二个就要求调试去匹配,才能很好的展示。

整体有点粗略,高手可以改进。

  1. data StockData;
  2. input Datetemp yymmdd10. Open High Low Close Volume;
  3. format Datetemp yymmdd10.;
  4. cards;
  5. 2006-2-6 1013.42 1033.35 1012.81 1033.23 25038771
  6. 2006-2-7 1034.68 1038.5 1019.94 1029.94 32954787
  7. 2006-2-8 1028.44 1033.4 1022.94 1033.07 26986729
  8. 2006-2-9 1033.19 1033.19 1017.05 1019.6 23839601
  9. 2006-2-10 1019.42 1032.6 1018.48 1032.34 22024453
  10. 2006-2-13 1034.38 1034.64 1021.84 1031.61 22157298
  11. 2006-2-14 1032.65 1038.81 1030.46 1038.53 18556220
  12. 2006-2-15 1040.33 1048.34 1038.74 1041.66 24784628
  13. 2006-2-16 1041.67 1041.67 1019.21 1020.12 26159892
  14. 2006-2-17 1020.06 1028.57 1015.99 1020.37 21026875
  15. 2006-2-20 1020.74 1030.05 1020.02 1021.64 18818883
  16. 2006-2-21 1020.98 1038.94 1014.66 1038.82 23678039
  17. 2006-2-22 1039.65 1046.45 1036.38 1037.89 25380704
  18. 2006-2-23 1038.25 1041.59 1029.25 1041.37 19785037
  19. 2006-2-24 1041.97 1049.69 1041.97 1049.44 19676104
  20. 2006-2-27 1055.95 1057.22 1045.97 1047.84 22872099
  21. 2006-2-28 1046.71 1053.72 1033.66 1053.01 19353267
  22. 2006-3-1 1051.76 1057.69 1049.64 1056.62 19425730
  23. 2006-3-2 1055.86 1056.05 1034.68 1038.67 24877861
  24. 2006-3-3 1037.99 1043.42 1029.56 1041.68 21200539
  25. 2006-3-6 1041.66 1044.42 1036.11 1038.87 17870963
  26. 2006-3-7 1037.93 1037.98 1013.14 1014.97 19336516
  27. 2006-3-8 1012.58 1014.97 999.93 1009.27 17463055
  28. 2006-3-9 1006.97 1010.91 1002.2 1004.34 12735099
  29. 2006-3-10 1004.75 1011.76 1004.69 1008.9 11887983
  30. 2006-3-13 1008.8 1020.88 1008.51 1019.86 11765911
  31. 2006-3-14 1020.47 1021.65 1012.11 1018.27 11348030
  32. 2006-3-15 1018.15 1028.96 1017.08 1028.96 14842068
  33. 2006-3-16 1028.96 1029.81 1025.52 1027.62 14784339
  34. 2006-3-17 1027.64 1029.56 1021.08 1024.02 15001924
  35. 2006-3-20 1024.5 1037.91 1019.65 1037.66 15389912
  36. 2006-3-21 1037.95 1047.05 1036.23 1040.76 19077662
  37. 2006-3-22 1041.141 1047.941 1036.71 1047.671 18640575
  38. 2006-3-23 1047.351 1049.321 1042.821 1048.541 20467885
  39. 2006-3-24 1049.12 1051.76 1041.23 1042.6 20098237
  40. 2006-3-27 1042.63 1050.71 1037.08 1050.71 17134070
  41. 2006-3-28 1050.07 1056.52 1048.64 1055.98 22273999
  42. 2006-3-29 1058.74 1074.041 1057.68 1065.291 30526345
  43. 2006-3-30 1065.841 1067.991 1055.141 1055.631 22012494
  44. 2006-3-31 1053.851 1061.471 1050.221 1061.091 22276190
  45. ;
  46. run;
  47. data CandleData;
  48. set StockData;
  49. if Open<Close then do;
  50.   Date=Datetemp; y1=Open; output;
  51.   Date=Datetemp; y1=High; output;
  52.   Date=Datetemp; y1=Low; output;
  53.   Date=Datetemp; y1=Close; output;
  54.   Date=Datetemp; v1=Volume; output;
  55. end;
  56. if Open>=Close then do;
  57.   Date=Datetemp; y2=Open; output;
  58.   Date=Datetemp; y2=High; output;
  59.   Date=Datetemp; y2=Low; output;
  60.   Date=Datetemp; y2=Close; output;
  61.   Date=Datetemp; v2=Volume; output;
  62. end;
  63. format Date yymmdd10.;
  64. run;
  65. goptions htitle=2 htext=1.5 ;
  66. goptions reset=global gunit=pct cback=black border ftext=swissb ;
  67. axis1 label=("Date") color=red;
  68. axis2 label=("Price") color=red;
  69. axis3 label=("Volume") color=red;
  70. ;
  71. proc gplot data=CandleData ;
  72. plot v1*Date=1 v2*Date=2/ overlay vaxis=axis3 haxis=axis1 des = "" name = "volume1";
  73. symbol1 c=red i=needle;
  74. symbol2 c=green i=needle;
  75. run;
  76. quit;   
  77. proc gplot data=CandleData;
  78. plot y1*Date=3 y2*Date=4 / overlay grid vaxis=axis2 haxis=axis1 des = "" name = "price1";
  79. symbol3 c=red i=candle;
  80. symbol4 c=green i=candle;
  81. title "IF300";
  82. run;
  83. quit;
  84. goptions display;
  85. goptions xpixels=1000 ypixels=500;
  86. goptions border;

  87. ODS LISTING CLOSE;
  88. ODS HTML path="D:\" body="Candle.html"
  89. (title="my test K figure") style=minimal;
  90. /* *** Now, put it all together onto one page, using proc greplay */
  91. %let greout=white;
  92. proc greplay tc=tempcat nofs igout=work.gseg;
  93.   tdef dashbrd des='USAA Investment Dashboard'

  94.    1/llx =1    lly = 30
  95.      ulx =1    uly = 100
  96.      urx =100  ury = 100
  97.      lrx =100  lry = 30
  98.    2/llx =1    lly = 1
  99.      ulx =1    uly = 30
  100.      urx =100  ury = 30
  101.      lrx =100  lry = 1

  102. ;
  103. template = dashbrd;
  104. treplay
  105.     1:price1
  106.     2:volume1
  107. des='' name="IF300 Candel";
  108. run;
  109. quit;
  110. ODS HTML CLOSE;
  111. ODS LISTING;
复制代码

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:SAS平台 K线图 Investment Dashboard investmen 平台 证券

本帖被以下文库推荐

沙发
davil2000 发表于 2012-12-24 14:55:01 |只看作者 |坛友微信交流群
very good!  tks for share.
R是万能的,SAS是不可战胜的!

使用道具

藤椅
liuliutao 发表于 2013-3-30 21:57:57 |只看作者 |坛友微信交流群
学习了

使用道具

板凳
luijb 在职认证  发表于 2013-3-30 22:43:34 |只看作者 |坛友微信交流群
这个问题,我曾经花很长时间研究。有2个问题是解决不了的。
1 图形始终周六周日 占位
2 无法自动确定k线的宽度
西格玛临床统计服务工作室http://www.sigma-stat.com/,luijb@163.com

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-3 00:27