2

I am new to financial mathematics and trying to do a homework about backtest with R:

library(FinancialInstrument)

start.date <- '2017-01-01'
end.date <- '2019-12-30'

HSI <- getSymbols(Symbols="^HSI",src="yahoo",from=start.date,to=end.date,index.class="POSIXct",adjust=T, auto.assign = F)
HSI <- HSI %>% na.omit()

currency(primary_id='HKD')

stock(primary_id=HSI,currency='HKD',multiplier=500,tick_size=0.05)

But I receive the following Error: C stack usage 7971792 is too close to the limit

My R session:

Cstack_info()
  size    current  direction eval_depth 
  7969177      13136          1          2 

I saw there is similar post but no one answer: Error: C stack usage is too close to the limit in R

Is there anyone can advise about the Cstack error ?

Peter Chung
  • 1,010
  • 1
  • 13
  • 31
  • 1
    Considering that the error comes from a much simpler code in the other linked question you found, my best guess would be that there's a bug somewhere in the `FinancialInstrument` code. My suggestion would be to file an Issue at their GitHub repo: https://github.com/braverock/FinancialInstrument/issues EDIT: Actually, looks like that was already done, and it may be that you are using the function incorrectly. Looks like the `stock()` function is going to expect a character vector of length one as the identifier; see https://github.com/braverock/FinancialInstrument/issues/2 for more details – duckmayr Apr 28 '20 at 14:27
  • HSI should be "HSI". It is to define the stocks. – Mohanasundaram Apr 28 '20 at 14:47

1 Answers1

0

Don't use auto.assign.

getSymbols(Symbols="2800.HK",src="yahoo", from=start.date,to=end.date,index.class="POSIXct",adjust=T)

`2800.HK` <- `2800.HK` %>% na.omit()

currency(primary_id='HKD')

stock(primary_id='2800.HK',currency='HKD',multiplier=500,tick_size=0.05)
Peter Chung
  • 1,010
  • 1
  • 13
  • 31