Skip to content
Merged
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
24 changes: 24 additions & 0 deletions apps/pipeline_worker/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,30 @@
"PostgreSQL URL used for durable realtime watermarks. Empty keeps the local "
"in-memory repository for development only.",
),
(
"PIPELINE_WORKER_MARKET_HISTORY_REDIS_URI",
False,
"",
"TLS Redis URI used only by --sync-market-history for the read-model projection.",
),
(
"PIPELINE_WORKER_MARKET_HISTORY_REDIS_KEY_PREFIX",
False,
"i2s",
"Plain Redis hash-tag prefix shared with backend market-data reads.",
),
(
"PIPELINE_WORKER_MARKET_HISTORY_LIMIT",
False,
"400",
"Recent adjusted bars retained per instrument and strategy timeframe.",
),
(
"MARKET_DATA_BUCKET",
False,
"",
"Versioned canonical S3 bucket used by scheduled market-history sync.",
),
(
"PIPELINE_WORKER_CORPORATE_ACTION_APPROVAL",
False,
Expand Down
25 changes: 23 additions & 2 deletions apps/pipeline_worker/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ def build_parser() -> argparse.ArgumentParser:
"Requires PIPELINE_WORKER_DATABASE_URL."
),
)
parser.add_argument(
"--sync-market-history",
action="store_true",
help=(
"Publish missing adjusted daily history, project recent AVAILABLE "
"bars to Redis, advance watermarks, and exit."
),
)
return parser


Expand All @@ -66,16 +74,29 @@ def main(
return EXIT_OK

if arguments.publish_manifest_watermarks:
from apps.pipeline_worker.publish_manifest_watermarks import execute
from apps.pipeline_worker.publish_manifest_watermarks import (
execute as publish_manifest_watermarks,
)

try:
result = execute([], environment)
result = publish_manifest_watermarks([], environment)
except (OSError, RuntimeError, ValueError) as error:
print(f"publish-manifest-watermarks failed: {error}", file=sys.stderr)
return EXIT_RUNTIME_FAILURE
print(json.dumps(result, indent=2, sort_keys=True))
return EXIT_OK

if arguments.sync_market_history:
from apps.pipeline_worker.sync_market_history import execute as sync_market_history

try:
result = sync_market_history(environment)
except (OSError, RuntimeError, ValueError) as error:
print(f"sync-market-history failed: {error}", file=sys.stderr)
return EXIT_RUNTIME_FAILURE
print(json.dumps(result, indent=2, sort_keys=True))
return EXIT_OK

try:
config = WorkerConfig.from_environment(environment)
except ConfigurationError as error:
Expand Down
Loading