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

add missing order statuses #48

Merged
merged 1 commit into from
May 30, 2023
Merged

add missing order statuses #48

merged 1 commit into from
May 30, 2023

Conversation

MaxxRK
Copy link
Contributor

@MaxxRK MaxxRK commented May 30, 2023

These status were missing and causing errors when I would input an order.

@Graeme22
Copy link
Contributor

Thanks for the contribution! Could you also post the code that errored for you so I can verify?

@MaxxRK
Copy link
Contributor Author

MaxxRK commented May 30, 2023

I am not sure how much you need, but here is a snippet of the code I ran.

if action == 'buy':
      order_type = ['Market', 'Debit', 'Buy to Open']
      stock_price = D(stock_quote[0].askPrice)
      new_order = order_setup(tt, order_type, stock_price, stock, amount)
  elif action == 'sell':
      order_type = ['Market', 'Credit', 'Sell to Close']
      stock_price = D(stock_quote[0].bidPrice)
      new_order = order_setup(tt, order_type, stock_price, stock, amount)
  placed_order = accounts[index].place_order(tt, new_order, dry_run=DRY)
  if placed_order.order.status.value == "Routed":
      message = f"Tastytrade account {acct.account_number}: {action} {amount} of {stock}"
      print(message)
      if ctx and loop:
          asyncio.ensure_future(ctx.send(message), loop=loop)

the error it produced:

Individual
Traceback (most recent call last):
File "C:\Users\autoRSA.py", line 70, in fun_run
globals()[fun_name](self.logged_in[index], self.action, self.stock, self.amount, self.price, self.time, self.dry, ctx, loop)
File "C:\Users\tastyAPI.py", line 296, in tastytrade_transaction
asyncio.run(tastytrade_execute(tt, action, stock, amount, price, time, DRY, ctx, loop))
File "C:\Users\scoop\apps\python\current\Lib\asyncio\runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "C:\Users\scoop\apps\python\current\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\scoop\apps\python\current\Lib\asyncio\base_events.py", line 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "C:\Users\Documents\auto-rsa_rewrite\tastyAPI.py", line 199, in tastytrade_execute
placed_order = accounts[index].place_order(tt, new_order, dry_run=DRY)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\scoop\apps\python\current\Lib\site-packages\tastytrade\account.py", line 931, in place_order
return PlacedOrderResponse(**data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "pydantic\main.py", line 341, in pydantic.main.BaseModel.init
pydantic.error_wrappers.ValidationError: 1 validation error for PlacedOrderResponse
order -> status
value is not a valid enumeration member; permitted: 'Received', 'Cancelled', 'Filled', 'Expired', 'Live', 'Rejected', 'Contingent' (type=type_error.enum; enum_values=[<OrderStatus.RECEIVED: 'Received'>, <OrderStatus.CANCELLED: 'Cancelled'>, <OrderStatus.FILLED: 'Filled'>, <OrderStatus.EXPIRED: 'Expired'>, <OrderStatus.LIVE: 'Live'>, <OrderStatus.REJECTED: 'Rejected'>, <OrderStatus.CONTINGENT: 'Contingent'>])

Error in tastytrade_transaction with tastytrade
Self:
Action: sell
Amount: 1
Stock: BTOG
Time: day
Price: market
Brokers: ['tastytrade']
Not Brokers: []
Dry: False
Holdings: False
Logged In: [<tastytrade.session.Session object at 0x00000263F684AD50>]

an example of it running withe the changes and printing out the Status:

Tastytrade: Error: preflight_check_failure: One or more preflight checks failed short_sell_not_allowed: Account not approved for selling stock short Individual OrderStatus.ROUTED

and finally where I got all of the statuses from tastytrades official API:

https://developer.tastytrade.com/#error-codes

image

@Graeme22 Graeme22 merged commit a29daf5 into tastyware:master May 30, 2023
@Graeme22
Copy link
Contributor

Thanks! I think I missed that part of the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants