Skip to content

Commit

Permalink
fix keyerror on order placement
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxxrk committed Feb 15, 2024
1 parent 3a223e4 commit bd974b6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tastyAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from decimal import Decimal as D

from dotenv import load_dotenv
from helperAPI import Brokerage, maskString, printAndDiscord, printHoldings, stockOrder
from tastytrade import ProductionSession
from tastytrade.account import Account
from tastytrade.dxfeed.event import EventType
Expand All @@ -21,8 +22,6 @@
from tastytrade.streamer import DXFeedStreamer
from tastytrade.utils import TastytradeError

from helperAPI import Brokerage, maskString, printAndDiscord, printHoldings, stockOrder


def order_setup(tt: ProductionSession, order_type, stock_price, stock, amount):
symbol = Equity.get_equity(tt, stock)
Expand Down Expand Up @@ -192,7 +191,7 @@ async def tastytrade_execute(tt_o: Brokerage, orderObj: stockOrder, loop=None):
f"{key} Error placing order: {placed_order.order.id} on account {print_account}: {order_status}",
loop=loop,
)
except TastytradeError as te:
except (TastytradeError, KeyError) as te:
printAndDiscord(f"{key} {print_account}: Error: {te}", loop=loop)


Expand Down

0 comments on commit bd974b6

Please sign in to comment.