Skip to content
Open
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
3 changes: 2 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def _init_state(self):
if self._position is not None:
if self._order is None:
self._state = 'TO_SELL'
self._submit_sell() # we should trigger sell, otherwise the stock is stuck in TO_SELL state until EOD
else:
self._state = 'SELL_SUBMITTED'
if self._order.side != 'sell':
Expand Down Expand Up @@ -78,7 +79,7 @@ def checkup(self, position):
order = self._order
if (order is not None and
order.side == 'buy' and now -
pd.Timestamp(order.submitted_at, tz='America/New_York') > pd.Timedelta('2 min')):
pd.Timestamp(order.submitted_at).tz_convert('America/New_York') > pd.Timedelta('2 min')):
last_price = self._api.get_last_trade(self._symbol).price
self._l.info(
f'canceling missed buy order {order.id} at {order.limit_price} '
Expand Down