ReMe/reme/steps/proactive/data_connectors/btc_quotes.py
jinliyl ae55e2e570
Some checks are pending
CI / Python packages / Build and verify distributions (push) Waiting to run
CI / Python quality / GitHub Actions (push) Waiting to run
CI / Python quality / Pre-commit (push) Waiting to run
CI / Python tests / Hermes embedded - ubuntu-latest (push) Waiting to run
CI / Python tests / Hermes embedded - windows-latest (push) Waiting to run
CI / Python tests / Unit Tests - py3.11 (push) Waiting to run
CI / Python tests / Unit Tests - py3.12 (push) Waiting to run
CI / Python tests / Unit Tests - py3.13 (push) Waiting to run
CI / Python tests / Unit Tests - py3.14 (push) Waiting to run
CI / ReMe Studio / Studio checks (push) Waiting to run
CI / Windows / CLI smoke - py3.11 (push) Waiting to run
Deploy / Documentation / Build documentation (push) Waiting to run
Deploy / Documentation / deploy (push) Blocked by required conditions
Security / CodeQL / Analyze javascript-typescript (push) Waiting to run
Security / CodeQL / Analyze python (push) Waiting to run
feat!: split proactive runtimes and add Studio backend management (#776)
* refactor(proactive)!: separate runtime ownership and unify delivery

* refactor(proactive): finish runtime and Studio migration

* test(proactive): make scheduled skip coverage deterministic

* refactor(studio): unify navigation and notebook resource loading

* feat(studio): edit workspace documents and update proactive task names

* refactor(studio): simplify task settings and navigation

* feat(studio): secure and supervise backend settings

* feat(studio): unify workbench timelines and refine desktop updates

Use shared timeline panes for notebook, memory, and resources. Add Todo creation ordering, persist companion visibility, and align desktop update handling and release artifacts.

Recheck editor file versions at read and publication boundaries. Retry reminder detail requests from the resource view.

* fix(studio): support unsigned GitHub preview releases

* fix: verify container state and isolate proactive view errors

Mount private supervisor state in Docker smoke tests and verify token and settings persistence. Exercise Studio startup with a loopback-only model fixture, and exclude packaged desktop output from Docker contexts.

Keep Remy subscriptions and healthy tasks available when an individual task has an invalid workspace path or session history.

* fix(home): align candidate Docker context exclusions

* chore(deps): update openai-codex dependency to v0.172.0

- Bump openai-codex from version 0.169.0 to 0.172.0 in pyproject.toml
- Keep other dependencies unchanged
- Ensure compatibility with latest openai-codex features and fixes

* fix(daemon): discover parent dotenv and isolate listeners

Restore parent-directory environment discovery in workers while retaining system precedence. Partition the default supervisor profile and lock by the configured bind address and port.
2026-11-25 21:33:16 +08:00

49 lines
1.9 KiB
Python

"""Collect BTC/USDT spot quotes continuously through Binance's public market-data endpoint."""
from datetime import datetime, timezone
import json
import httpx
from ._finance import QuoteCollectorStep
from ....core.registry import R
from ....schema.finance import CryptoQuote
_URL = "https://data-api.binance.vision/api/v3/ticker/24hr"
@R.register("btc_quotes_step")
class BtcQuotesStep(QuoteCollectorStep):
"""Publish changed spot statistics around the clock, including weekends."""
source = "btc_quotes"
filename = "btc.jsonl"
quote_model = CryptoQuote
description = (
"BTC/USDT spot statistics from Binance. Read btc.jsonl; change_24h_percent is the rolling 24-hour change, "
"and prices are in USDT. Use window_end and collected_at for freshness."
)
def fetch_quote(self, client: httpx.Client) -> CryptoQuote:
payload = json.loads(self.request(client, _URL, params={"symbol": "BTCUSDT"}))
if not isinstance(payload, dict) or payload.get("symbol") != "BTCUSDT":
raise ValueError("Binance returned missing or invalid BTCUSDT statistics")
opening = float(payload["openPrice"])
if opening <= 0:
raise ValueError("Invalid BTCUSDT 24-hour opening price")
price = float(payload["lastPrice"])
return CryptoQuote(
price=price,
open_24h=opening,
change_24h_percent=round((price / opening - 1) * 100, 4),
window_start=datetime.fromtimestamp(int(payload["openTime"]) / 1000, timezone.utc),
window_end=datetime.fromtimestamp(int(payload["closeTime"]) / 1000, timezone.utc),
collected_at=self.received_at(),
)
@staticmethod
def changed(quote, previous):
return quote.window_end >= previous.window_end and (quote.price, quote.open_24h) != (
previous.price,
previous.open_24h,
)