santoshlite / EigenLedger

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

Unable to run sample `Usage` code #16

Closed spinGreekGod closed 3 years ago

spinGreekGod commented 3 years ago
  1. I installed the package empyrial and it is showing multiple errors
  2. I am running python 3.9.0 and I installed plotly for the visualizations
  3. I am running the sample Usage code
    
    from empyrial import empyrial, Engine

portfolio = Engine(
start_date= "2020-06-09", portfolio= ["BABA", "RELIANCE.NS", "KO", "^DJI","^IXIC"], weights = [0.2, 0.2, 0.2, 0.2, 0.2], #equal weighting by default benchmark = ["SPY"] )

empyrial(portfolio)


<img width="614" alt="Screen Shot 2021-06-08 at 8 55 13 PM" src="https://user-images.githubusercontent.com/49564726/121276093-ff153c80-c89b-11eb-99e2-c0b069a1f744.png">
santoshlite commented 3 years ago

Hey,

So you can see the error given is NameError: name 'display' undefined.

To show the final dataframe, Empyrial uses the display function. I found this post that can help you : https://stackoverflow.com/questions/49328447/display-in-python

So basically I think it gives an errror because you're not in a jupyter notebook/google colab.

To solve this you will need to:

1) Install IPython (if it's not already done)

pip install IPython

or if you are running pip3:

pip3 install IPython

2) When the installation is completed, add this import at the beginning of your code:

from IPython.display import display

Tell me if works.

I'm going to solve this as soon as possible thanks for raising the problem!

spinGreekGod commented 3 years ago

Tried it in a jupyter notebook and it worked! thank you.