santoshlite / EigenLedger

An Open Source Portfolio Backtesting Engine for Everyone | 面向所有人的开源投资组合回测引擎
https://eigenledger.gitbook.io/documentation
Apache License 2.0
942 stars 128 forks source link

Error with stocks data #115

Closed sebvalton67116 closed 1 month ago

sebvalton67116 commented 1 year ago

First and foremost, I wanted to let you know how much I adore your work and how big of a fan I am of your Empyrial library on Python! I use it quite often for my analyses.

I'm reaching out today because I've been facing an issue when running the code, regardless of the date I choose: it indicates there's a data problem. The specific issue is as follows:

ValueError Traceback (most recent call last) in <cell line: 27>() 25 ) 26 benchmark=["SPY"] ---> 27 empyrial(portfolio) 28 29

1 frames /usr/local/lib/python3.10/dist-packages/empyrial/main.py in get_returns(stocks, wts, start_date, end_date) 148 initial_alloc = wts/assets.iloc[0] 149 if initial_alloc.isna().any(): --> 150 raise ValueError("Some stock is not available at initial state!") 151 portfolio_value = (assets * initial_alloc).sum(axis=1) 152 returns = portfolio_value.pct_change()[1:]

ValueError: Some stock is not available at initial state!

I've tried to resolve it by using more recent dates to download titles, but it still doesn't work.

santoshlite commented 1 year ago

Could you give a minimal reproducible example, please?

dvolosh commented 5 months ago

Make sure the tickers are NYSE/NASDAQ and not international. Was getting the same error

santoshlite commented 5 months ago

Actually if they are tickers that can be found on yfinance in general they should work. You can also use custom data if needed (check the doc!)