maodeng
发表于 2013-1-25 13:15:49
如果我想看最近 一个月,三个月 六个月 的成本,怎么修改程序啊,谢谢大师了
maodeng
发表于 2013-1-25 13:18:55
我用同样的方法导出数据,发现有的能生成,有的就不行,不知道问题在哪儿,比如300236就生成不了,我的邮箱是19860225gaoyuan@163.com,麻烦大师了
maodeng
发表于 2013-1-28 13:13:51
. hello 300236
statement out of context
r(119);
大师 就是这个
sergio
发表于 2013-1-28 21:11:43
这贴实在!
awer
发表于 2013-2-5 14:40:59
maodeng 发表于 2013-1-28 13:13 static/image/common/back.gif
. hello 300236
statement out of context
r(119);
抱歉,最近太忙了
300236 我用下面的程序试过,没问题
你把 D:\stock\test\source 改成你导出的数据存放的目录,再试一试
capture program drop hello
program hello
quietly {
clear
cd D:\stock\test\source
insheet using `1'.txt
keep if v5>0
gen vt=_n
tsset vt
gen zf=D1.v5
gsort -v1
gen avol=v7/v5
keep if avol>0
drop vt
gen vt=_n
tsset vt
sum v5
gen amean=r(mean) in 1
* 总加权平均值 amean
keep in 1/240
sum v5
gen mean240=r(mean) in 1
*240加权平均值 mean240
set obs 500
kdensity v5 ,gaussian n(500) generate(dx240 dy240) nograph
*240 kdensity(dx240 dy240)
sum dy240
gen yxis=r(max) in 1
gen yxis2=yxis/2
*yxis
gen dy240max=r(max)
gen dy240minp=r(min)
gen vtt=_n
tsset vtt
gen ddy240=D1.dy240/D1.dx240
sum ddy240
gen ddy240max=r(max)
gen ddy240min=r(min)
gen ddy240g=ddy240*(dy240max-dy240min)/(ddy240max-ddy240min)
sum ddy240g
gen yxis3=r(min) in 1
gen yxis4=0 in 1
*ddy240g
preserve
sum v5
keep if dx240<r(mean)
sum ddy240
if r(min)<0 {
keep if ddy240<=0
count
if r(N)>2 {
pkexamine dx240 dy240
local tempminp=r(tomc)
restore
}
else {
di "cannot find minp"
restore
sum dx240
local tempminp=r(mean)
}
}
else {
keep if ddy240<=r(min)
sum dx240
local tempminp=r(min)
restore
}
gen minp=`tempminp' in 1
*240 minp
preserve
sum v5
keep if dx240>r(mean)
sum ddy240
if r(max)>0 {
keep if ddy240>=0
count
if r(N)>2 {
pkexamine dx240 dy240
local tempmaxp=r(tomc)
restore
}
else {
restore
di "cannot find maxp"
sum dx240
local tempmaxp=r(mean)
}
}
else {
keep if ddy240>=r(max)
sum dx240
local tempmaxp=r(max)
restore
}
gen maxp=`tempmaxp' in 1
*240maxp
*-------------ddy240pminp左侧高峰值-----
preserve
keep if dx240<`tempminp'
keep if ddy240>0
count
if r(N)>2 {
pkexamine dx240 ddy240
local tempminphddy240=r(tomc)
restore
}
else {
restore
di "cannot find pminphddy240"
sum dx240
local tempminphddy240=r(mean)
}
gen pminphddy240=`tempminphddy240' in 1
*-------------ddy240pminp右侧低峰值 -----------------
preserve
keep if dx240>`tempminp'
keep if dx240<`tempmaxp'
keep if ddy240<0
gen temddy240=-ddy240
count
if r(N)>2 {
pkexamine dx240 temddy240
local tempminplddy240=r(tomc)
restore
}
else {
di "cannot find pminplddy240"
restore
sum dx240
local tempminplddy240=r(mean)
}
gen pminplddy240=`tempminplddy240' in 1
*-------------ddy240pmaxp左侧高峰值 -------------------
preserve
keep if dx240>`tempminp'
keep if dx240<`tempmaxp'
keep if ddy240>0
count
if r(N)>2 {
pkexamine dx240 ddy240
local tempmaxphddy240=r(tomc)
restore
}
else {
di "cannot find pmaxphddy240"
restore
sum dx240
local tempmaxphddy240=r(mean)
}
gen pmaxphddy240=`tempmaxphddy240' in 1
*-------------ddy240pmaxp右侧低峰值 -------------------
preserve
keep if dx240>`tempmaxp'
gen temddy240=-ddy240
keep if temddy240>0
count
if r(N)>2 {
pkexamine dx240 temddy240
local tempmaxplddy240=r(tomc)
restore
}
else {
restore
di "cannot find pmaxlhddy240"
sum dx240
local tempmaxplddy240=r(mean) in 1
}
gen pmaxplddy240=`tempmaxphddy240' in 1
*-------------------------------------
gen price5d=v5 in 1/20
gen price5yy=_n in 1/20
gen price5y=price5yy*(dy240max-dy240min)/20
*price5y &price5d
gen priceny=price5y in 1
gen pricen=v5 in 1
*priceny &pricen
*-------------------------graph------------------
tw(line dy240 ddy240g dx240)(spike yxis mean240, lc(red))(spike yxis maxp, lp(-) lc(black))(spike yxis minp, lc(black)) (scatter yxis2 mean240,lc(red) msymbol(+) mlabel(mean240) lc(red))(scatter yxis maxp,msymbol(+) mlabel(maxp) lc(black))(scatter yxis minp, msymbol(+) mlabel(minp) lc(black))(scatter yxis4 pminphddy240, msymbol(O) c(l[-]) mlabel(pminphddy240))(scatter yxis3 pminplddy240, msymbol(O) c(l[-]) mlabel(pminplddy240))(scatter yxis4 pmaxphddy240, msymbol(O) c(l[-]) mlabel(pmaxphddy240))(scatter yxis3 pmaxplddy240, msymbol(O) c(l[-]) mlabel(pmaxplddy240))(scatter price5y price5d, msymbol(O) mfc(black) mlc(black) c(l[-])) (scatter priceny pricen, msymbol(O) mfc(red) mlc(red)), title("`f'") xtitle("`1'") ytitle("density") legend(off)
* ---------可选项目----------------------
*(spike yxis amean,lc(blue))(scatter yxis2 amean, lc(blue) msymbol(+) mlabel(amean))
}
end
maodeng
发表于 2013-2-7 00:03:44
awer 发表于 2013-2-5 14:40 static/image/common/back.gif
抱歉,最近太忙了
300236 我用下面的程序试过,没问题
哇,谢谢,我仔细看看,这些字母数字代码晕了
喜欢喝冰茶
发表于 2013-2-7 04:05:03
stata是不是商用的,R里应该有类似的东西吧
喜欢喝冰茶
发表于 2013-2-8 07:16:33
awer老虎推荐的一个处理数据的软件,很小,只有10m左右,很好用发表于 5 小时前
这东西是开源的?知道有个统计软件叫stata,不过要收钱。
汉水云潇
发表于 2013-4-17 17:14:44
准备试一试
先找Stata软件
汉水云潇
发表于 2013-4-17 22:21:02
本帖最后由 汉水云潇 于 2013-4-17 22:27 编辑
晕呀
论坛复制程序代码
乱码夹杂在其中
很烦
对了两次
以为没问题了
结果
执行后
还是出现
r 199
的错误
汉水云潇
发表于 2013-4-18 07:50:56
试验成功,下面是三一重工的图
peterbev
发表于 2013-4-26 12:46:50
先用用试一试,不知道准确不
中秋不圆
发表于 2016-3-12 15:46:06
噢。。。这个帖子好,比较直观。
bknite
发表于 2016-3-21 23:51:14
这个帖子值得学习。
jeanny
发表于 2016-3-22 10:41:13
感谢!!!
Hubert2000
发表于 2016-3-23 10:23:05
明月回春 发表于 2011-8-13 20:17
程序写的不错.
不过有一点要注意.通达信导出的数据,只对价格复权,并没有对成交量复权.所以数据需要手工处理 ...
老哥,也是山寨这篇文章找不到了,不知为何?
axiutime
发表于 2016-8-3 13:28:29