Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse filesFiles changed (3)
- README.md+13-7
- app.pyAdded+146
- requirements.txtAdded+4
1234567891011121314---title: Data Exploreremoji: 🏆colorFrom: pinkcolorTo: greensdk: gradiosdk_version: 6.24.0python_version: '3.12'app_file: app.pypinned: falseshort_description: data-explorer---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference1234567891011121314151617181920---title: cruscy data — L2 exploreremoji: 📊colorFrom: graycolorTo: bluesdk: gradiosdk_version: 6.24.0app_file: app.pypinned: falseshort_description: Real Binance L2 microstructure — obfuscated live sample---# cruscy data — live L2 explorerDemo Space for [data.cruscy.com](https://data.cruscy.com/?ref=hf): real Binancespot market microstructure (trades, order-book depth, derived features) with anin-platform SQL console, backtest runner and MCP access for AI agents.This Space renders the public obfuscated sample from[GOD111111111/synthetic-timeseries-data](https://huggingface.co/datasets/GOD111111111/synthetic-timeseries-data).
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146"""cruscy data — demo explorer.
Public obfuscated sample (3 days of real Binance spot microstructure).Full platform: https://data.cruscy.com"""from functools import lru_cache
try: import spaces # noqa: F401 ZeroGPU-harness; демо CPU-only, GPU не зовёмexcept ImportError: pass
import gradio as grimport matplotlibimport pandas as pd
matplotlib.use("Agg")import matplotlib.pyplot as plt
REPO = "GOD111111111/synthetic-timeseries-data"DAYS = ["day_01", "day_02", "day_03"]FG, GRID, UP, DN, ACC = "#d7dde4", "#2a3038", "#26a269", "#c0392b", "#4f9cf9"
@lru_cache(maxsize=8)def load(kind: str, day: str) -> pd.DataFrame: from huggingface_hub import hf_hub_download path = hf_hub_download(REPO, f"{kind}/{day}.parquet", repo_type="dataset") return pd.read_parquet(path)
def _fig(nrows=1, height=4.6, ratios=None): fig, axes = plt.subplots( nrows, 1, figsize=(11, height), dpi=110, sharex=True, gridspec_kw={"height_ratios": ratios or [1] * nrows}) fig.patch.set_facecolor("#14181d") for ax in (axes if nrows > 1 else [axes]): ax.set_facecolor("#14181d") ax.tick_params(colors=FG, labelsize=8) for s in ax.spines.values(): s.set_color(GRID) ax.grid(color=GRID, linewidth=0.4, alpha=0.6) fig.tight_layout(pad=1.4) return fig, axes
def candles(day: str, tf: str): df = load("trades", day) tf_ms = {"1m": 60_000, "5m": 300_000, "15m": 900_000}[tf] g = df.groupby(df.sensor_c // tf_ms) o, h = g.sensor_a.first(), g.sensor_a.max() l, c = g.sensor_a.min(), g.sensor_a.last() v = g.sensor_b.sum() t = o.index * tf_ms / 3_600_000 # hours since day start up = c >= o fig, (ax, axv) = _fig(2, 5.6, [4, 1]) w = tf_ms / 3_600_000 * 0.75 ax.vlines(t, l, h, color="#5c6670", linewidth=0.7) ax.bar(t[up], (c - o)[up], w, o[up], color=UP) ax.bar(t[~up], (c - o)[~up], w, o[~up], color=DN) ax.set_ylabel("relative price (day open = 1000)", color=FG, fontsize=9) axv.bar(t, v, w, color="#3d78c9", alpha=0.8) axv.set_ylabel("volume", color=FG, fontsize=9) axv.set_xlabel("hours (UTC day)", color=FG, fontsize=9) ax.set_title(f"{day} · {tf} candles from {len(df):,} raw trades", color=FG, fontsize=11, loc="left") return fig
def cvd(day: str): df = load("trades", day) delta = df.sensor_b.where(df.sensor_d == 1, -df.sensor_b) m = delta.groupby(df.sensor_c // 60_000).sum().cumsum() px = df.groupby(df.sensor_c // 60_000).sensor_a.last() t = m.index / 60.0 fig, (ax, ax2) = _fig(2, 5.6, [1, 1]) ax.plot(t, px, color=FG, linewidth=1.0) ax.set_ylabel("price", color=FG, fontsize=9) ax.set_title(f"{day} · price vs cumulative volume delta (CVD)", color=FG, fontsize=11, loc="left") ax2.plot(t, m, color=ACC, linewidth=1.1) ax2.fill_between(t, 0, m, color=ACC, alpha=0.18) ax2.axhline(0, color=GRID, linewidth=0.8) ax2.set_ylabel("CVD (mean-size units)", color=FG, fontsize=9) ax2.set_xlabel("hours (UTC day)", color=FG, fontsize=9) return fig
def flow(day: str): ob = load("flow", day) t = ob.sensor_c / 3_600_000 fig, (ax, ax2) = _fig(2, 5.6, [2, 1]) ax.fill_between(t, ob.sensor_i_lo, ob.sensor_i_hi, color=ACC, alpha=0.15, label="5-min range") ax.plot(t, ob.sensor_i, color=ACC, linewidth=1.2, label="mean imbalance") ax.axhline(0, color=GRID, linewidth=0.8) ax.set_ylim(-1.05, 1.05) ax.set_ylabel("book imbalance (−1…1)", color=FG, fontsize=9) ax.legend(loc="upper right", fontsize=8, facecolor="#14181d", edgecolor=GRID, labelcolor=FG) ax.set_title(f"{day} · order-book imbalance & spread (from raw L2)", color=FG, fontsize=11, loc="left") ax2.plot(t, ob.sensor_s, color="#e8a33d", linewidth=1.1) ax2.set_ylabel("spread, bps", color=FG, fontsize=9) ax2.set_xlabel("hours (UTC day)", color=FG, fontsize=9) return fig
CSS = """.gradio-container {max-width: 1080px !important}#hero {margin-bottom: 4px}"""
with gr.Blocks(css=CSS, theme=gr.themes.Base(), title="cruscy data — L2 explorer") as demo: gr.Markdown( "# cruscy data — live L2 explorer\n" "Real Binance spot microstructure — every trade, full order-book depth, " "derived features and regime labels, recorded with sequence-gap auditing " "and daily integrity manifests.\n\n" "This Space renders an **obfuscated 3-day sample** (relative prices, " "normalized sizes; instrument & dates stripped). The full feed is " "explored *inside* the platform: SQL console, backtest runner on real " "L2, notebook workspace, and **MCP access for AI agents**.\n\n" "**[→ Full access: data.cruscy.com](https://data.cruscy.com/?ref=hf)**", elem_id="hero") day = gr.Dropdown(DAYS, value=DAYS[-1], label="Sample day") with gr.Tab("Candles"): tf = gr.Radio(["1m", "5m", "15m"], value="5m", label="Timeframe") p1 = gr.Plot(show_label=False) with gr.Tab("Volume delta (CVD)"): p2 = gr.Plot(show_label=False) with gr.Tab("Book imbalance"): p3 = gr.Plot(show_label=False) gr.Markdown( "Sample dataset: " "[synthetic-timeseries-data](https://huggingface.co/datasets/GOD111111111/synthetic-timeseries-data) " "· ~400k trades/day · schema in the dataset card")
def render_all(d, t): return candles(d, t), cvd(d), flow(d)
day.change(render_all, [day, tf], [p1, p2, p3]) tf.change(candles, [day, tf], p1) demo.load(render_all, [day, tf], [p1, p2, p3])
demo.launch()1234pandaspyarrowmatplotlibhuggingface_hubREADME.md+13-7
app.pyAdded+146
requirements.txtAdded+4