fmilthaler / FinQuant

A program for financial portfolio management, analysis and optimisation.
MIT License
1.38k stars 190 forks source link

"Could not find column labels in given dataframe." #36

Closed JoePierce96 closed 4 years ago

JoePierce96 commented 4 years ago

When trying to get data from Quandl I get the an error (made sure ticker names are correct beforehand):

`d = { 0: {"Name": "XLON/BP_", "Allocation": 1000000}, 1: {"Name": "XLON/III", "Allocation": 1000000}, 2: {"Name": "XLON/GSK", "Allocation": 1000000}, 3: {"Name": "XLON/OCDO", "Allocation": 1000000}, 4: {"Name": "XLON/RBS", "Allocation": 2000000}, 5: {"Name": "XLON/SVT", "Allocation": 1000000}, }

pf_allocation = pd.DataFrame.from_dict(d, orient="index")

set list of names based on names

names = pf_allocation["Name"].values.tolist()`

This is the error message:

`runfile('C:/Users/Joe Shiafa Pierce/.spyder-py3/FinQuant POM project.py', wdir='C:/Users/Joe Shiafa Pierce/.spyder-py3') Traceback (most recent call last):

File "", line 1, in runfile('C:/Users/Joe Shiafa Pierce/.spyder-py3/FinQuant POM project.py', wdir='C:/Users/Joe Shiafa Pierce/.spyder-py3')

File "C:\Users\Joe Shiafa Pierce\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 786, in runfile execfile(filename, namespace)

File "C:\Users\Joe Shiafa Pierce\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/Joe Shiafa Pierce/.spyder-py3/FinQuant POM project.py", line 40, in names=names, pf_allocation=pf_allocation, start_date=start, end_date=end

File "C:\Users\Joe Shiafa Pierce\Anaconda3\lib\site-packages\finquant\portfolio.py", line 1153, in build_portfolio pf = _build_portfolio_from_api(**kwargs)

File "C:\Users\Joe Shiafa Pierce\Anaconda3\lib\site-packages\finquant\portfolio.py", line 935, in _build_portfolio_from_api pf = _build_portfolio_from_df(data, pf_allocation)

File "C:\Users\Joe Shiafa Pierce\Anaconda3\lib\site-packages\finquant\portfolio.py", line 1035, in _build_portfolio_from_df data = _get_stocks_data_columns(data, pf_allocation.Name.values, datacolumns)

File "C:\Users\Joe Shiafa Pierce\Anaconda3\lib\site-packages\finquant\portfolio.py", line 869, in _get_stocks_data_columns raise ValueError("Could not find column labels in given dataframe.")

ValueError: Could not find column labels in given dataframe.`

Thanks for your help,

fmilthaler commented 4 years ago

Hi and thanks for bringing this to my attention. So far FinQuant only supports "WIKI/..." data from Quandl. That should clearly be changed.

fmilthaler commented 4 years ago

Started working on it in a feature branch. Gotta do something else now, but will continue later today.

fmilthaler commented 4 years ago

Hi @JoePierce96 , please download the updated master branch and check if it is working now. I just pushed a fix.