arthurp36
arthurp36

Reputation: 1

Arch model in python is returning "Buffer dtype mismatch, expected 'double' but got 'float'"

I am trying to develop a Volatility model for some stock indexes using python and the arch model. I am comparing the solution developed by this third party library with some proprietary code I have. Unofrtunately, when using the fit method on the ARCH model, it breaks and raises the following error.

ValueError: Buffer dtype mismatch, expected 'double' but got 'float'

I am not sure what to do.

I want to fit a garch model to see if my calculations do match the code by 3rd party library.

import yfinance as yf
from arch import arch_model
import numpy as np

SPX = yf.download('^GSPC', start = '2005-01-01', interval = '1d')
SPX['log_returns'] = np.log(SPX['Adj Close']) - np.log(SPX['Adj Close'].shift(1))
arch_mSPX = arch_model(SPX['log_returns'][1:] * 100, mean = 'Zero', vol = 'GARCH')
arch_mSPX = arch_mSPX.fit()

Upvotes: 0

Views: 135

Answers (1)

thetaco
thetaco

Reputation: 1672

Is SPX a dataframe? Perhaps try to cast your data explicitly as a double:

SPX = yf.download('^GSPC', start = '2005-01-01', interval = '1d')
SPX = SPX.astype('double')
SPX['log_returns'] = np.log(SPX['Adj Close']) - np.log(SPX['Adj Close'].shift(1))
arch_mSPX = arch_model(SPX['log_returns'][1:] * 100, mean = 'Zero', vol = 'GARCH')
arch_mSPX = arch_mSPX.fit()

EDIT: He simply uninstalled arch 6.2.0 and reinstalled arch 6.1.0, and the issue was resolved

Upvotes: 0

Related Questions