Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dependencies = [
"pandas_market_calendars",
"pytz",
"requests",
"quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@5d0714201f3813f68a9833083cd21f6d61e5b702",
"quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@00168a617d45205f6f685090a4197592995935b3",
"us-equity-strategies @ git+https://github.com/QuantStrategyLab/UsEquityStrategies.git@c31f28484b8489a1ecda8e595a6d2afd3bce8185",
]
license = "MIT"
Expand Down Expand Up @@ -68,5 +68,5 @@ include_namespace_packages = true

[tool.uv]
override-dependencies = [
"quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@5d0714201f3813f68a9833083cd21f6d61e5b702",
"quant-platform-kit @ git+https://github.com/QuantStrategyLab/QuantPlatformKit.git@00168a617d45205f6f685090a4197592995935b3",
]
2 changes: 1 addition & 1 deletion qsl.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ upgrade_ring = "ring_d"
allow_legacy = false

[qsl.requires]
quant_platform_kit = "5d0714201f3813f68a9833083cd21f6d61e5b702"
quant_platform_kit = "00168a617d45205f6f685090a4197592995935b3"
us_equity_strategies = "c31f28484b8489a1ecda8e595a6d2afd3bce8185"

[qsl.compat]
Expand Down
24 changes: 6 additions & 18 deletions src/firstrade_platform/entrypoints/cloud_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,14 @@

from __future__ import annotations

from datetime import datetime

import pandas_market_calendars as mcal
import pytz
from quant_platform_kit.markets import is_market_open_now as _qpk_is_market_open_now


def is_market_open_now(*, calendar_name="NYSE", timezone_name="America/New_York"):
"""Return whether the US equity regular session is open right now."""
try:
calendar = mcal.get_calendar(calendar_name)
market_tz = pytz.timezone(timezone_name)
now_market = datetime.now(market_tz)
schedule = calendar.schedule(start_date=now_market.date(), end_date=now_market.date())
if schedule.empty:
return False, None
try:
return calendar.open_at_time(schedule, now_market), None
except ValueError as exc:
if "not covered by the schedule" not in str(exc):
raise
return False, None
except Exception as exc:
return False, exc
return _qpk_is_market_open_now(
calendar_name=calendar_name,
timezone_name=timezone_name,
calendar_factory=mcal.get_calendar,
)
6 changes: 3 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading