diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2025-04-27 22:41:14 -0600 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2025-04-27 22:41:14 -0600 |
commit | f32142947b853076889801913d47b8c2c0f4f456 (patch) | |
tree | 20981c0c2b79c2ba9cc58eece69591cfbe5b21ff /server/create_db.py | |
parent | ba700c31fceb4554ccbb3181f0e5747fcf5c3259 (diff) |
format using black
Diffstat (limited to 'server/create_db.py')
-rw-r--r-- | server/create_db.py | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/server/create_db.py b/server/create_db.py index ca2f818..4142acf 100644 --- a/server/create_db.py +++ b/server/create_db.py @@ -8,6 +8,7 @@ from zoneinfo import ZoneInfo NEW_ENGLAND_TZ = ZoneInfo("America/New_York") + def init_db(): Base.metadata.create_all(bind=engine) db = SessionLocal() @@ -23,10 +24,15 @@ def init_db(): print("Default user already exists.") # Insert dummy bids for 2025-04-25 - existing_bids = db.query(Bid).filter(Bid.timestamp.between( - datetime(2025, 4, 25, 0, 0), - datetime(2025, 4, 25, 23, 59) - )).all() + existing_bids = ( + db.query(Bid) + .filter( + Bid.timestamp.between( + datetime(2025, 4, 25, 0, 0), datetime(2025, 4, 25, 23, 59) + ) + ) + .all() + ) if not existing_bids: print("Inserting dummy bids for 2025-04-25...") @@ -47,7 +53,7 @@ def init_db(): user_id=user.id, market="ISONE", status="Submitted", - pnl=None + pnl=None, ) dummy_bids.append(bid) @@ -59,13 +65,17 @@ def init_db(): # Insert one dummy bid for today at 11:00PM local time today_local = datetime.now(NEW_ENGLAND_TZ).date() - bid_time_local = datetime.combine(today_local, datetime.min.time(), tzinfo=NEW_ENGLAND_TZ).replace(hour=23) + bid_time_local = datetime.combine( + today_local, datetime.min.time(), tzinfo=NEW_ENGLAND_TZ + ).replace(hour=23) bid_time_utc = bid_time_local.astimezone(timezone.utc) existing_bid_today = db.query(Bid).filter(Bid.timestamp == bid_time_utc).first() if not existing_bid_today: - print(f"Inserting dummy bid for today at {bid_time_local.strftime('%Y-%m-%d %I:%M %p')} local time...") + print( + f"Inserting dummy bid for today at {bid_time_local.strftime('%Y-%m-%d %I:%M %p')} local time..." + ) today_bid = Bid( timestamp=bid_time_utc, quantity=20.0, @@ -73,7 +83,7 @@ def init_db(): user_id=user.id, market="ISONE", status="Submitted", - pnl=None + pnl=None, ) db.add(today_bid) db.commit() @@ -83,5 +93,6 @@ def init_db(): db.close() + if __name__ == "__main__": init_db() |