Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Error in mktdata[, keep] : number of dimensions incorrect " due to stock "T" referring to TRUE?
    primarykey
    data
    text
    <p>I have a problem when trying to run an example of quantstrat on the stock AT&amp;T referred with the symbole "T". I believe it is because R is somewhere thinking this T is refering to TRUE. Here is my code:</p> <pre><code>library(quantstrat) ticker="T" total_hist.start = as.Date("2006-06-22") total_hist.end = as.Date("2008-06-20") total_hist = total_hist.end - total_hist.start currency("USD") stock(ticker,currency="USD",multiplier=1) getSymbols(ticker,from=total_hist.start,to=total_hist.end,to.assign=TRUE) init.date = initDate=total_hist.start-1 strat.name&lt;- "MyStrat" port.name &lt;- "MyPort" acct.name &lt;- "MyAcct" TradeSize = 1000 initEq=as.numeric( TradeSize*max(Ad(get(ticker)) ) ) port &lt;- initPortf(port.name,ticker,initDate=init.date) acct &lt;- initAcct(acct.name,portfolios=port.name, initDate=init.date, initEq=initEq) ords &lt;- initOrders(portfolio=port.name,initDate=init.date) strat&lt;- strategy(strat.name) strat&lt;- add.indicator(strategy = strat, name = "SMA", arguments = list(x=quote(Ad(mktdata)), n=20),label= "ma20" ) strat&lt;- add.indicator(strategy = strat, name = "SMA", arguments = list(x=quote(Ad(mktdata)), n=50),label= "ma50") strat&lt;- add.signal(strat,name="sigCrossover",arguments = list(columns=c("ma20","ma50"),relationship="gte"),label="ma20.gt.ma50") strat&lt;- add.signal(strat,name="sigCrossover",arguments = list(column=c("ma20","ma50"),relationship="lt"),label="ma20.lt.ma50") strat&lt;- add.rule(strategy = strat,name='ruleSignal', arguments = list(sigcol="ma20.gt.ma50",sigval=TRUE, orderqty=TradeSize, ordertype='market', orderside='long', pricemethod='market'),type='enter', path.dep=TRUE) strat&lt;- add.rule(strategy = strat,name='ruleSignal', arguments = list(sigcol="ma20.lt.ma50",sigval=TRUE, orderqty='all', ordertype='market', orderside='long', pricemethod='market'),type='exit', path.dep=TRUE) out&lt;-try(applyStrategy(strategy=strat, portfolios=port.name)) </code></pre> <p>I now get this error message:</p> <pre><code>Error in mktdata[, keep] : nombre de dimensions incorrect </code></pre> <p>I tried with another stock like Agilent Technologies who's symbol is "A" and I don't get this error so I am almost sure the problem is coming from the fact T is like TRUE. Thanks for the help!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload