我正在尝试使用Performance Analytics软件包绘制每日利润的下拉图。我已经设法使用代码执行此操作:
cols = rainbow(ncol(pdrawdown),s=0.7, v=0.8, alpha= 0.7)
chart.Drawdown(pdrawdown, legend.loc = "bottomleft",colorset = cols,
main = "Drawdown Chart", xlab ="Date", ylab = "Drawdown")
返回百分比。但是,当我使用利润(处理更大的数字)时,图形窗口甚至不会显示任何表格,也不会产生错误或警告消息。
我的提取数据结构如下:
structure(list(Arbitrage = c(-410344.36040002, 43186613.0914002,
-56243745.8289002, 33212085.9369, 2685633.86650004, 52056396.8137002
), Cmdty = c(-5661740.59000004, -12816611.3327999, -15271367.5797001,
30328698.7996001, 2346206.95040001, -20111667.3121), Cnvt = c(-0.448500000005879,
-4.09389999999985, -3.76900000000023, -4.46530000000348, 9.47310000000289,
5.57809999999154), FI = c(-4959851.92789985, 51301719.2496983,
19347533.8012021, -45928596.3382014, -126566982.481699, 7039919.16710053
), IndexArb = c(465514.007300064, 712460.314099789, -1241298.64239982,
859103.288600107, -9142.46960010222, 1670160.15220016), OptVolD = c(3207463.8402,
-2645827.2004, 1917467.1194, -1645717.199, 1346643.9976, 1249267.9222
), OptVolG = c(1809178.81009999, -1247076.75579998, 1208738.92329999,
-998966.340099988, 474978.958799993, 2312496.41480001), Other = c(3121114.45319998,
-7558428.4574, 28751941.5262, -8287057.41060003, -5057308.97439997,
25541692.1845), RVG = c(107064420.2606, 41122417.5658004, -33634242.2959002,
-25318480.7920002, -9396822.53510034, 69874891.7186005), SAAsia = c(-31022426.4966,
-1381533.43030003, 21484053.8479001, 15456037.1175, 11307323.7993999,
8081090.74740009)), .Names = c("Arbitrage", "Cmdty", "Cnvt",
"FI", "IndexArb", "OptVolD", "OptVolG", "Other", "RVG", "SAAsia"
), row.names = c("2015-08-03", "2015-08-04", "2015-08-05", "2015-08-06",
"2015-08-07", "2015-08-10"), class = "data.frame")
更新:设定ylim值,即
cols = rainbow(ncol(pdrawdown),s=0.7, v=0.8, alpha= 0.7)
chart.Drawdown(pdrawdown, legend.loc = "bottomleft",colorset = cols,
main = "Drawdown Chart", xlab ="Date", ylab = "Drawdown",ylim = c(-1,0))
导致图形出现,但无论我的下限是什么,它仍然有效地显示无意义的数据。然而,对于回报,这个ylim术语按预期工作,修复了图的轴。
答案 0 :(得分:0)
由于没有人能够给出答案,我会发布我最好的解决方案,以防将来有其他人遇到这个问题。
据我所知,问题是(正如预期的那样)仅仅因为缩减PnL太大而引起。我的" hack"解决这个问题的方法是将数据分成一个数字,使所有值都低于1.在我的情况下,这意味着我的y比例如此数十亿:
pdrawdown = pdrawdown/1000000000 # PnL displays in billions (set units here)
cols = rainbow(ncol(pdrawdown),s=0.7, v=0.8, alpha= 0.7)
chart.Drawdown(pdrawdown, legend.loc = "bottomleft",colorset = cols,
main = "Drawdown Chart", xlab ="Date", ylab = "Drawdown ($billions)
除以较小的数字只会给出一个非常奇怪的图形,其中大量的跳跃与相同数据的返回图形不相似。
我怀疑这是因为缩减图是针对百分比而设计的,因此只能处理介于0和-1之间的数字(百分比的最大缩幅当然是-100%)。