简体   繁体   English

使用R中的quantmod计算特定时期的最高高价

[英]Calculating highest high price during specific period using quantmod in R

I am trying to calculate the highest high price and lowest low price during the last 144 days for one stock. 我正在尝试计算过去144天中一只股票的最高价和最低价。

I have been thinking for a while and finally I came up with the following two means, but these are still not exactly what I want. 我已经思考了一段时间,最后我想出了以下两种方法,但这仍然不是我想要的。

This is because the highest(high_price, 144) and lowest(low_price, 144) is a series that would probably change over time. 这是因为最高(high_price,144)和最低(low_price,144)是可能随时间变化的序列。

data <- getSymbols("300343.SZ",auto.assign=FALSE)

#highest price so far
seriesHi(data)

# find the maximum highest price each week
max_price_weekly <- period.apply(data,endpoints(data,on='weeks'), FUN=function(x) { max(Hi(x)) } ) 

candleChart(data,subset='2012::2013')

Someone can give some help? 有人可以帮忙吗?

If you just want the highest or lowest price over the previous 144 days, you can do this 如果您只想要过去144天的最高价或最低价,则可以这样做

runMax(Hi(data), 144)
runMin(Lo(data), 144)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM