Code Monkey home page Code Monkey logo

Comments (5)

enzbus avatar enzbus commented on June 29, 2024

Hello! Can you please post the output of

import cvxportfolio as cvx

md = cvx.MarketSimulator(['NVDA']).market_data

md.returns.loc[md.returns['NVDA'].isnull()]

on my machine there are no missing values for NVDA in 2001, there might have been a yfinance download issue on your end?

from cvxportfolio.

ammargilani avatar ammargilani commented on June 29, 2024

Thanks, I didn't get any warnings. This is the output:

Updating data
.
NVDA USDOLLAR
Date
2001-09-10 NaN 0.000137
2001-09-12 NaN 0.000139
2023-09-21 NaN NaN

from cvxportfolio.

enzbus avatar enzbus commented on June 29, 2024

from cvxportfolio.

enzbus avatar enzbus commented on June 29, 2024

I'm working on a fix, the Yahoo finance interface is not up to standards. I have done most testing on recent data (say, after 2010) and large cap US stocks. On those there are very rarely (I haven't seen any) missing rows in the data. I have seen bugs like this on low cap or foreign stocks, but this is the first time it is reported on a large cap US stock in recent history.

In the 2016 examples we were heavily filtering (any stock with missing data was excluded), at the time with quandl data (now defunct). The goal is to have an interface modular enough to plug a new data source with minimal code (alpha vantage, bloomberg, ...). Yahoo finance however is the only one that works without subscription (to my knowledge) and has acceptable quality, so I want to keep it as default (also for the examples). By the way, you can always use Cvxportfolio with user-provided returns and volumes (as it was done in the original interface), and filter in any way you wish.

What's your suggestion for dealing with a missing row like the one you had? All default estimators (expected return, covariances, transaction cost model parameters, ...) are robust to missing data, they are OK. The simulator however needs to make an assumption there. Do we propagate the last closing price (so on the missing days the returns are zero, but on the day before it might be larger in absolute value)? Do we just refuse to use that stock? (Which is basically what happens now.) Another possible fix from the user side is to do resampling (e.g., monthly) with the trading_frequency option to the simulator, which makes it robust to (some) missing data rows.

Thanks!

from cvxportfolio.

ammargilani avatar ammargilani commented on June 29, 2024

Thank you. It looks like a data download issue, it probably originated in a dependency package. We definitely need stricter checks on the downloaded data quality. In the meantime you can delete your cache folder $HOME/cvxportfolio_data, or just the NVDA file, and re-run the script.

I see, thanks.

from cvxportfolio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.