amor71 / LiuAlgoTrader

Framework for algorithmic trading

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to Run quickstart Strategy Code

iguy0 opened this issue · comments

commented

Describe the bug
After installing LiuAlgoTrader via git, configuring environment variables and attempting to run the quickstart strategy I'm greeted with: AttributeError: module 'main' has no attribute 'spec'

To Reproduce
Steps to reproduce the behavior:

  1. Install Ubuntu 22.04 Server
    $ python3 --version
    -> Python 3.10.4
    python3 -m pip install virtualenv
    git clone https://github.com/amor71/LiuAlgoTrader.git
    cd LiuAlgoTrader
    -> Configure env variables
    source .venv/bin/activate
    python3 setup.py install
    -> Go to examples/quickstart
    $ trader
(.venv) v2@ubuntu:~/LiuAlgoTrader/examples/quickstart$ trader
[motd()][3016]2022-09-05 13:06:33.862920:++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[motd()][3016]2022-09-05 13:06:33.862987:++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[motd()][3016]2022-09-05 13:06:33.863006:trader v0.4.29 starting
[motd()][3016]2022-09-05 13:06:33.863043:unique id: 74cdcf81-1d99-4140-ae46-88d44da1b59f
[motd()][3016]2022-09-05 13:06:33.863067:----------------------------------------------------------
[motd()][3016]2022-09-05 13:06:33.863091:----------------------------------------------------------
{'events': ['second', 'minute', 'trade', 'quote'], 'scanners': {'momentum': {'provider': 'alpaca', 'min_volume': 30000, 'min_gap': 3.5, 'min_last_dv': 500000, 'max_share_price': 20.0, 'min_share_price': 2.0, 'from_market_open': 15, 'recurrence': 5}}, 'strategies': {'MomentumLongV3': {'filename': './momentum_long_simplified.py', 'schedule': [{'duration': 60, 'start': 15}]}}}
[<module>()][3016]2022-09-05 13:06:33.864189:loaded configuration file from ./tradeplan.toml
[calc_num_consumer_processes()][3016]2022-09-05 13:06:38.870648:Total CPU Load:0.0, num_cpu:8
[<module>()][3016]2022-09-05 13:06:38.870722:Starting 40 consumer processes
Traceback (most recent call last):
  File "/home/v2/LiuAlgoTrader/.venv/bin/trader", line 4, in <module>
    __import__('pkg_resources').run_script('liualgotrader==0.4.29', 'trader')
  File "/home/v2/LiuAlgoTrader/.venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 672, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/home/v2/LiuAlgoTrader/.venv/lib/python3.10/site-packages/pkg_resources/__init__.py", line 1479, in run_script
    exec(script_code, namespace, namespace)
  File "/home/v2/LiuAlgoTrader/.venv/lib/python3.10/site-packages/liualgotrader-0.4.29-py3.10.egg/EGG-INFO/scripts/trader", line 89, in <module>
  File "/usr/lib/python3.10/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
  File "/usr/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "/usr/lib/python3.10/multiprocessing/context.py", line 284, in _Popen
    return Popen(process_obj)
  File "/usr/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/usr/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/usr/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 42, in _launch
    prep_data = spawn.get_preparation_data(process_obj._name)
  File "/usr/lib/python3.10/multiprocessing/spawn.py", line 183, in get_preparation_data
    main_mod_name = getattr(main_module.__spec__, "name", None)
AttributeError: module '__main__' has no attribute '__spec__'

Expected behavior
The trader command would successfully launch the quickstart strategy.

Desktop (please complete the following information):

  • OS:
    $ lsb_release -a
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description: Ubuntu 22.04.1 LTS
    Release: 22.04
    Codename: jammy

Additional info:

`$ pip list <- From venv
Package Version


aiohttp 3.8.1
aiosignal 1.2.0
alpaca-trade-api 2.3.0
altair 4.2.0
async-timeout 4.0.2
asyncpg 0.26.0
attrs 22.1.0
blinker 1.5
cachetools 5.2.0
certifi 2022.6.15
cffi 1.15.1
charset-normalizer 2.1.1
click 8.1.3
commonmark 0.9.1
cycler 0.11.0
decorator 5.1.1
Deprecated 1.2.13
deprecation 2.1.0
empyrical 0.5.5
entrypoints 0.4
exchange-calendars 4.2
finnhub-python 2.4.13
fire 0.4.0
fonttools 4.37.1
frozenlist 1.3.1
gitdb 4.0.9
GitPython 3.1.27
idna 3.3
importlib-metadata 4.12.0
iso8601 1.0.2
Jinja2 3.1.2
jsonschema 4.15.0
kiwisolver 1.4.4
korean-lunar-calendar 0.2.1
liualgotrader 0.4.29
lxml 4.9.1
MarkupSafe 2.1.1
matplotlib 3.5.2
msgpack 1.0.3
multidict 6.0.2
multitasking 0.0.11
nest-asyncio 1.5.5
numpy 1.23.1
packaging 21.3
pandas 1.5.0rc0
pandas-datareader 0.10.0
pandas-market-calendars 3.5
parsedatetime 2.6
Pillow 9.2.0
pip 22.2.2
polygon-api-client 1.1.1
protobuf 3.20.1
psutil 5.9.1
pyarrow 9.0.0
pycparser 2.21
pydeck 0.8.0b1
pygit2 1.9.2
Pygments 2.13.0
pyluach 2.0.1
Pympler 1.0.1
pyparsing 3.0.9
pyrsistent 0.18.1
python-dateutil 2.8.2
pytz 2022.2.1
pytz-deprecation-shim 0.1.0.post0
PyYAML 6.0
QuantStats 0.0.59
requests 2.28.1
rich 12.5.1
scipy 1.9.0
seaborn 0.12.0rc0
semver 3.0.0.dev3
setuptools 65.3.0
six 1.16.0
smmap 5.0.0
stockstats 0.4.1
streamlit 1.11.1
tabulate 0.8.10
termcolor 1.1.0
toml 0.10.2
toolz 0.12.0
tornado 6.2
tqdm 4.64.0
typing_extensions 4.3.0
tzdata 2022.2
tzlocal 4.2
urllib3 1.26.11
validators 0.20.0
watchdog 2.1.9
websocket-client 1.4.1
websockets 10.3
wheel 0.37.1
wrapt 1.14.1
yarl 1.8.1
yfinance 0.1.74
zipp 3.8.1
`

I appreciate all the help.

Thank you for joining LiuAlgoTrader community and submitting your first issue. Feel free to check out Liu community: https://gitter.im/LiuAlgoTrader/community

@iguy0 I'm unable to reproduce the issue. It looks like your setup fails to SPAWN a consumer process. However, I am a bit confused with the order of the things you're trying to do. Do you have a database setup? Did you run liu quickstart before trying to run trader?

commented

You are correct! I had configured it incorrectly. I've redeployed the stack using Ubuntu 20.04 and installed following the instructions from here: https://liualgotrader.readthedocs.io/en/latest/Troubleshooting.html

I appreciate all your effort on this project. Congrats on the excellent solution!