Skip to content

Commit

Permalink
Merge pull request #44 from alpacahq/orderLoggingPatch
Browse files Browse the repository at this point in the history
add debug logging for order submissions and inform user of symbol in order failure logs
  • Loading branch information
ttt733 authored Nov 5, 2018
2 parents ad6c141 + a582890 commit 49b9456
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pylivetrader/backend/alpaca.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,17 @@ def order(self, asset, amount, style):

zp_order_id = self._new_order_id()

log.debug(
('submitting {} order for {} - '
'qty:{}, side:{}, limit_price:{}, stop_price:{}').format(
order_type,
symbol,
qty,
side,
limit_price,
stop_price
)
)
try:
order = self._api.submit_order(
symbol=symbol,
Expand All @@ -263,7 +274,10 @@ def order(self, asset, amount, style):
zp_order = self._order2zp(order)
return zp_order
except APIError as e:
log.warning('order is rejected {}'.format(e))
log.warning('order for symbol {} is rejected {}'.format(
symbol,
e
))
return None

@property
Expand Down

0 comments on commit 49b9456

Please sign in to comment.