Skip to content

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

@WillForan

Description

@WillForan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions