1

我正在尝试使用 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")

对于百分比回报。但是,当我使用利润(处理更大的数字)时,图形窗口甚至不显示任何表格,也不会产生错误或警告消息。

我的 pdrawdown 数据的结构如下:

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 的下限是多少。然而,有了回报,这个 ylim 项按预期工作,固定了图的轴。

4

1 回答 1

0

由于没有人能够给出答案,我将发布我的最佳解决方案,以防其他人将来遇到这个问题。

据我所知,这个问题(正如预期的那样)仅仅是因为回撤 PnL 太大而引起的。我解决此问题的“技巧”是将数据表除以一个导致所有值都低于 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%)。

于 2017-08-22T08:13:49.427 回答