Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError: invalid literal for int() with base 10 (backend/alpaca.py: int(pos.qty) should be float ?) #259

Open
WillForan opened this issue Oct 4, 2022 · 0 comments

Comments

@WillForan
Copy link

using context.portfolio.positions gives

ValueError: invalid literal for int() with base 10: '418.8667'

from https://github.com/alpacahq/pylivetrader/blob/master/pylivetrader/backend/alpaca.py#L244

  File "alpaca_short_bsf46.py", line 145, in close_previous_day
    for sec in context.portfolio.positions:
  File "/usr/local/lib/python3.6/site-packages/pylivetrader/algorithm.py", line 512, in portfolio
    self._portfolio = self._backend.portfolio
  File "/usr/local/lib/python3.6/site-packages/pylivetrader/backend/alpaca.py", line 268, in portfolio
    z_portfolio.positions = self.positions
  File "/usr/local/lib/python3.6/site-packages/pylivetrader/backend/alpaca.py", line 244, in positions
    z_position.amount = int(pos.qty)
ValueError: invalid literal for int() with base 10: '418.8667'

changing int(pos.qty) to float in backend/alpaca.py gets past this error

pip show pylivetrader
Name: pylivetrader
Version: 0.7.1
Summary: simple live trading framework
Home-page: https://github.com/alpacahq/pylivetrader.git
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant