fmilthaler / FinQuant

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

example/Example-Build-Portfolio-from-web.py fails #74

Closed levous closed 1 year ago

levous commented 1 year ago

Running the example without edit fails.

(.venv) vagrant@linux:~/dev/FinQuant/example$ python3 Example-Build-Portfolio-from-web.py 
/home/vagrant/dev/FinQuant/.venv/lib/python3.8/site-packages/FinQuant-0.2.2-py3.8.egg/finquant/portfolio.py:260: FutureWarning: The frame.append method is deprecated and will be removed from pandas in a future version. Use pandas.concat instead.
Traceback (most recent call last):
  File "Example-Build-Portfolio-from-web.py", line 85, in <module>
    pf = build_portfolio(
  File "/home/vagrant/dev/FinQuant/.venv/lib/python3.8/site-packages/FinQuant-0.2.2-py3.8.egg/finquant/portfolio.py", line 1170, in build_portfolio
  File "/home/vagrant/dev/FinQuant/.venv/lib/python3.8/site-packages/FinQuant-0.2.2-py3.8.egg/finquant/portfolio.py", line 939, in _build_portfolio_from_api
  File "/home/vagrant/dev/FinQuant/.venv/lib/python3.8/site-packages/FinQuant-0.2.2-py3.8.egg/finquant/portfolio.py", line 1051, in _build_portfolio_from_df
  File "/home/vagrant/dev/FinQuant/.venv/lib/python3.8/site-packages/FinQuant-0.2.2-py3.8.egg/finquant/portfolio.py", line 267, in add_stock
  File "/home/vagrant/dev/FinQuant/.venv/lib/python3.8/site-packages/FinQuant-0.2.2-py3.8.egg/finquant/portfolio.py", line 282, in _update
  File "/home/vagrant/dev/FinQuant/.venv/lib/python3.8/site-packages/FinQuant-0.2.2-py3.8.egg/finquant/portfolio.py", line 202, in totalinvestment
ValueError: Total investment must be a float or integer.
maximus12793 commented 1 year ago

This is just a bug with the example. Convert to a float and this should work. Ex:

d = {
    0: {"Name": "GOOG", "Allocation": 20.0},
    1: {"Name": "AMZN", "Allocation": 10.0},
    2: {"Name": "MCD", "Allocation": 15.0},
    3: {"Name": "DIS", "Allocation": 18.0},
}