Hello, QuantConnect Community
i'm trying to run python script in research environment, python code works fine in notebook, but not working if running from command line like this:
`python test.py`
test.py
from AlgorithmImports import *
import pandas as pd
from datetime import date
import json
qb = QuantBook()
stock = qb.AddEquity('AAPL')
history = qb.History(stock.Symbol, date(2021, 1, 1), date(2021, 4, 1), Resolution.Daily)
df = history.reset_index().assign(date=lambda x: (x.time - pd.Timestamp('1970-01-01'))//pd.Timedelta('1ms'))
df1 = df[['date','open','high','low','close']]
ohlc = df1.values.tolist()
df2 = df[['date','volume']]
volume = df2.values.tolist()
result = {'ohlc': ohlc,'volume': volume}
str = json.dumps(result)
print(str)
there's error message:
# python test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
from AlgorithmImports import *
File "/Lean/Launcher/bin/Debug/AlgorithmImports.py", line 23, in <module>
from clr import AddReference
File "/Lean/Launcher/bin/Debug/clr.py", line 6, in <module>
load()
File "/Lean/Launcher/bin/Debug/pythonnet/__init__.py", line 36, in load
set_default_runtime()
File "/Lean/Launcher/bin/Debug/pythonnet/__init__.py", line 22, in set_default_runtime
set_runtime(clr_loader.get_mono())
File "/opt/miniconda3/lib/python3.8/site-packages/clr_loader/__init__.py", line 19, in get_mono
libmono = find_libmono(sgen)
File "/opt/miniconda3/lib/python3.8/site-packages/clr_loader/util/find.py", line 71, in find_libmono
raise RuntimeError("Could not find libmono")
RuntimeError: Could not find libmono
it seems i missed some sort of setup, how can i make this work?
thank you!
Regards
Jin Yang
Louis Szeto
Hi Yang
This line works only with LEAN installed and compiled locally. If you're using the CLI, you need to run on docker container in an virtual environment with LEAN. Instead, run this command line under the CLI root folder:
Best
Louis
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Yang Jin
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!