-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from r0fls/rd/constant-percentage-state-fixes
fix constant percentage strategy state issues
- Loading branch information
Showing
6 changed files
with
133 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,4 +109,3 @@ | |
session.add_all(fake_accounts) | ||
session.commit() | ||
print("Fake account data inserted into the database.") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from datetime import datetime, time | ||
import pytz | ||
|
||
def is_market_open(): | ||
# Define market open and close times (e.g., 9:30 AM to 4:00 PM Eastern Time) | ||
market_open = time(9, 30) | ||
market_close = time(16, 0) | ||
|
||
# Get current time in Eastern Time | ||
eastern = pytz.timezone('US/Eastern') | ||
current_time = datetime.now(eastern).time() | ||
|
||
# Check if today is a weekend | ||
current_date = datetime.now(eastern).date() | ||
if current_date.weekday() >= 5: # 5 = Saturday, 6 = Sunday | ||
return False | ||
|
||
# Check if current time is within market hours | ||
if market_open <= current_time <= market_close: | ||
return True | ||
|
||
return False |