Skip to content

added check if market is open at this moment in utils #288

Merged
Graeme22 merged 3 commits intotastyware:masterfrom
Quenos:master
Dec 18, 2025
Merged

added check if market is open at this moment in utils #288
Graeme22 merged 3 commits intotastyware:masterfrom
Quenos:master

Conversation

@Quenos
Copy link
Contributor

@Quenos Quenos commented Dec 7, 2025

Description

Related issue(s)

Added a util not a fix

Pre-merge checklist

  • Code formatted correctly (check with make lint)
  • [-] Code implemented for both sync and async
  • Passing tests locally (check with make test, make sure you have TT_REFRESH, TT_SECRET, and TT_ACCOUNT environment variables set)
    -- Only tested the added util. Very simple code, shouldn't break anything. tastytrade.utils completely tested including new fucntion
  • New tests added (if applicable)

Please note that, in order to pass the tests, you'll need to set up your Tastytrade credentials as repository secrets on your local fork. Read more at CONTRIBUTING.md.

Returns:
bool: True if market is open now, False otherwise
"""
now_est = datetime.now(TZ)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be just now_in_new_york()

bool: True if market is open now, False otherwise
"""
now_est = datetime.now(TZ)
return is_market_open_on(now_est.date()) and (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work when there are half days. Perhaps prefer using the already included market_sessions module?

@Quenos
Copy link
Contributor Author

Quenos commented Dec 9, 2025

@Graeme22 changes implemented as suggested. Works now also on half-days like Black Friday. Tests are updated as well.

@Graeme22 Graeme22 merged commit 622615a into tastyware:master Dec 18, 2025
0 of 5 checks passed
@Graeme22
Copy link
Member

Thanks, sorry for the delay!

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