Skip to content

Commit

Permalink
Print exchange hours in table
Browse files Browse the repository at this point in the history
Also reorder imports w/ pre-commit
  • Loading branch information
brndnmtthws committed Jan 25, 2025
1 parent ddd0cc6 commit 280558c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ repos:
# Run the linter.
- id: ruff
args: [--fix]
# Reorder imports.
- id: ruff
args: [check, --select, I, --fix]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/astral-sh/uv-pre-commit
Expand Down
3 changes: 2 additions & 1 deletion stubs/schema/contextlib2/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@ This type stub file was generated by pyright.

from types import TracebackType
from typing import (
IO,
Any,
AsyncContextManager,
AsyncIterator,
Awaitable,
Callable,
ContextManager,
IO,
Iterator,
Optional,
Type,
TypeVar,
overload,
)

from typing_extensions import ParamSpec, Protocol

AbstractContextManager = ContextManager
Expand Down
11 changes: 10 additions & 1 deletion thetagang/exchange_hours.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import exchange_calendars as xcals
import pandas as pd
from rich import box
from rich.table import Table

from thetagang import log
from thetagang.config import ExchangeHoursConfig
Expand All @@ -22,7 +24,14 @@ def determine_action(config: ExchangeHoursConfig, now: datetime) -> str:
start = open + pd.Timedelta(seconds=config.delay_after_open)
end = close - pd.Timedelta(seconds=config.delay_before_close)

log.info(f"Exchange hours open={open}, close={close}, start={start}, end={end}")
table = Table(box=box.SIMPLE)
table.add_column("Exchange Hours")
table.add_column(config.exchange)
table.add_row("Open", str(open))
table.add_row("Close", str(close))
table.add_row("Start", str(start))
table.add_row("End", str(end))
log.print(table)

if start <= now <= end:
# Exchange is open
Expand Down

0 comments on commit 280558c

Please sign in to comment.