A python library for referencing and localizing US stock trading hours
Project description
markethours overview
We created market markethours and the markethours.info API because we couldn’t find other free tools for accessing stock trading hours, and we wanted to provide this library to help others experiencing siliar issues.
markethours features include:
Reference stock trading hours by date
Automatically localize to Eastern Standard time
Easily check whether market has opened or closed
No user accounts needed
Getting started with markethours
In order to access the E-Trade API, you’ll need to follow the 4 steps detailed on the E-Trade developer getting started page then request an API key through the linked page. It’s also recommended that you enable real-time data in the the subscription center so that you don’t receive delayed quotes.
Installation
pip install markethours
Example usage
from markethours import MarketHours
def main():
todays_hours = MarketHours()
# Check if the market has opened
print(todays_hours.market_has_opened())
# Check if the market has closed
print(todays_hours.market_has_closed())
# Wait for the market to open
todays_hours.wait_for_market_open()
# See the number of seconds until open
print(todays_hours.seconds_till_open())
# Do something if there's less than a minute before
# close. Something like this could be used in a loop
if todays_hours.seconds_till_close() < 60:
print('Hurry up!')
# Show open, close, and current time in EST
print(todays_hours.open)
print(todays_hours.close)
print(todays_hours.now_est())
if __name__ == '__main__':
main()
Disclaimer: markethours comes with no warranty of any kind, and its authors accept no responsibility for any damage that might stem from use of this package. See the LICENSE file for more details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for markethours-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be3af3201bc9e6bf16a5e8596e1b650088f5f967d08ca5aa02481ba54c6a723b |
|
MD5 | f9f2d4d1170cd22a8c715915f3615d13 |
|
BLAKE2b-256 | 9874af307ee8f88dbc7790e7eed9c301140949951a79539373e0865ebea456b1 |