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 ?

2
  • 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: 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 github.com/braverock/FinancialInstrument/issues/2 for more details
    – duckmayr
    Apr 28, 2020 at 14:27
  • HSI should be "HSI". It is to define the stocks. Apr 28, 2020 at 14:47

1 Answer 1

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.