r - 如何在 R 中计算 maxDrawdown
问题描述
我在 PerformanceAnalytics 包中使用 maxDrawdown 函数
我选择了一个日期列和一个类型双列来绘制这些时期的 maxdrawdown。
例如
period p/l
2020-11-02 12.34
2020-11-02 34.32
2020-11-03 -0.23
... ..
我已经运行了代码
maxDrawdown(select(Data,dt,pl))
但返回此错误:
Error in checkData(R) :
The data cannot be converted into a time series. If you are trying to pass in names from a data object with one column, you should use the form 'data[rows, columns, drop = FALSE]'. Rownames should have standard date formats, such as '1985-03-15'.
解决方案
也许:
library(xts)
x <- xts(Data$pl, Data$date)
maxDrawdown(x)
推荐阅读
- flask - Cloud Run 中部署的烧瓶 API 中的请求不起作用
- json - 快速解码 JSON 文件时遇到问题
- python - 两个不同长度的numpy数组的笛卡尔求和
- python - os.listdir 显示 25000 个输入,但只能加载 10685 个文件
- python - 如果两个dict中的列表元素共享任何元组,则获取键值
- java - 如何在约束布局中添加浮动按钮
- authorize.net - 如何在授权前进行信用卡验证
- javascript - 为什么 esprima 在在线浏览器演示中运行良好,但在本地失败
- opencv - 如何构建只支持解码jpeg的opencv?
- c - 有限状态机硬件/软件事件触发