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

bug: qty can be float #260

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pylivetrader/backend/alpaca.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def positions(self):
z_position = zp.Position(symbol_lookup(symbol))
except SymbolNotFound:
continue
z_position.amount = int(pos.qty)
z_position.amount = float(pos.qty)
z_position.cost_basis = float(pos.cost_basis) / float(pos.qty)
z_position.last_sale_price = None
z_position.last_sale_date = None
Expand Down Expand Up @@ -284,7 +284,7 @@ def _order2zp(self, order):
zp_order = ZPOrder(
id=order.client_order_id,
asset=symbol_lookup(order.symbol),
amount=int(order.qty) if order.side == 'buy' else -int(order.qty),
amount=float(order.qty) if order.side == 'buy' else -float(order.qty),
stop=float(order.stop_price) if order.stop_price else None,
limit=float(order.limit_price) if order.limit_price else None,
dt=order.submitted_at,
Expand All @@ -297,7 +297,7 @@ def _order2zp(self, order):
zp_order._status = ZP_ORDER_STATUS.REJECTED
if order.filled_at:
zp_order._status = ZP_ORDER_STATUS.FILLED
zp_order.filled = int(order.filled_qty)
zp_order.filled = float(order.filled_qty)
return zp_order

def _new_order_id(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_backend/test_alpaca.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_orders():
'exchange': 'NASDAQ',
'lastday_price': '200',
'market_value': '200',
'qty': '1',
'qty': '1.0',
'side': 'long',
'symbol': 'AAPL',
'unrealized_intraday_pl': '0',
Expand Down