(R,Blotter)使用chart.Posn()API时,如何更改图表上交易标记的颜色?

时间:2012-08-29 01:54:10

标签: r quantmod blotter

上下文: 我有一个csv文件中的事务(交易)列表。我想将这些交易导入R,然后在图表上绘制交易,以便我可以直观地看到条目和退出。我终于想出了导入部分(来自印刷演示中的amzn_test.R)但很难改变图表上绘制的商标的颜色。

我注意到图表的源代码中的交易标记的颜色目前是固定的.Posn.R(包装:吸墨纸)。 (文件名:chart.Posn.R,代码网址:https://r-forge.r-project.org/scm/viewvc.php/pkg/blotter/R/chart.Posn.R?view=markup&root=blotter

if(!is.null(nrow(Buys)) && nrow(Buys) >=1 ) (add_TA(Buys,pch=2,type='p',col='green', on=1));
    if(!is.null(nrow(Sells)) && nrow(Sells) >= 1) (add_TA(Sells,pch=6,type='p',col='red', on=1));

问题: 有什么办法可以覆盖这些颜色吗?如果我不能有任何方法可以将背景图表主题更改为黑色,以便更好地看到交易标记?我尝试了各种方法来设置图表主题,但遇到了错误。

要重现错误,请执行以下印迹amzn_test演示代码片段,然后执行自定义代码。

演示代码:

require(blotter)

# Remove portfolio and account data if run previously
try(rm("portfolio.amzn_port","account.amzn_acct",pos=.blotter))

# load the example data
data("amzn")
currency("USD")
stock("amzn",currency="USD",multiplier=1)
# Initialize the Portfolio
initPortf("amzn_port",symbols="amzn",initDate="2010-01-14")
initAcct("amzn_acct",portfolios="amzn_port",initDate="2010-01-14", initEq=10000)
# look at the transactions data
amzn.trades
# Add the transactions to the portfolio
blotter:::addTxns("amzn_port","amzn",TxnData=amzn.trades,verbose=TRUE)

# update the portfolio stats
updatePortf("amzn_port",Dates="2010-01-14")

# update the account P&L
updateAcct("amzn_acct",Dates="2010-01-14")

# and look at it
chart.Posn("amzn_port","amzn",Dates="2010-01-14")

自定义代码:

> black_theme = chartTheme("black")
> chart.Posn("amzn_port","amzn",Dates="2010-01-14", theme=chartTheme("black"))
Error in if (theme$lylab) { : argument is of length zero
> 

如果有人能指导我如何解决这个问题,我非常感激。

此致

0 个答案:

没有答案