Add FastAPI scanner service with 1Hz web dashboard#1
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Add FastAPI scanner service with 1Hz web dashboard#1devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Co-Authored-By: harlequincariotta <harlequincariotta@wshu.net>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The repo was previously empty. This PR introduces a small FastAPI service that polls a public crypto exchange once per second, detects market "situations", and serves a self-contained web dashboard that refreshes the data every second (per the original request).
app/scanner.py—MarketScannerbackground task. Each tick it fetches the Binance 24h ticker, keeps a rolling in-memory history (HISTORY_LEN=120samples) for the topTOP_N_BY_VOLUME=30USDT pairs (selected on first tick), and produces aScannerStatesnapshot.price_spike_up_1m/price_spike_down_1m— ≥1% move in the last ~60s.volume_surge— last-minute quote volume ≥2× the 10-minute baseline (estimated from the cumulative 24hquoteVolumedelta).new_24h_high/new_24h_low— last price touches the daily extreme.app/main.py— FastAPI app wiring the scanner into a lifespan, plus three routes:/(HTML),/api/state(JSON snapshot),/healthz.app/static/{index.html,styles.css,app.js}— vanilla HTML/JS dashboard.app.jspolls/api/statein a loop using the server-providedpoll_interval_seconds(defaults to 1.0s), flashes price cells green/red on change, and renders a "situations" panel and a tickers table.pyproject.toml/poetry.lock/README.md/.gitignore— project bootstrap (Poetry, Python ≥3.10).Data source: I'm using
https://data-api.binance.vision/api/v3/ticker/24hr(Binance's read-only data mirror) instead ofapi.binance.combecause the main API returned HTTP 451 (geo-blocked) from the dev VM. The mirror exposes the same response shape.Stack choice rationale: the user picked "На ваше усмотрение" — I went with FastAPI + plain HTML/JS so everything runs from a single
uvicornprocess with no build step.Review & Testing Checklist for Human
data-api.binance.visionis Binance's read-only mirror; if you'll deploy this somewhere whereapi.binance.comis reachable, you may want to pointBINANCE_TICKER_URL(or theMarketScanner(ticker_url=...)arg) back at the main API. Also confirm the once-per-second poll of the full 24h ticker payload (~600 KB, ~3000 symbols) is acceptable for your rate-limit budget — fetching only the tracked symbols would be cheaper.volume_surgeuses deltas of the cumulative 24hquoteVolumeas a per-minute proxy; that's only a rough estimate and the baseline window only fills once history has ≥10 minutes of samples.new_24h_high/new_24h_lowfire wheneverprice >= high_24h/price <= low_24h. Because the latest price is itself included in the exchange's 24h extreme, this can trigger every second when the market is at the rolling boundary. You may want a debounce or a "strictly new" check.poetry install && poetry run uvicorn app.main:app --port 8000, then open http://localhost:8000. Check that tickers populate, prices flash on change, the "Last update" timestamp ticks once per second, andcurl http://localhost:8000/api/statereturns a JSON snapshot withtickersandsituations.Notes
/healthzreturns 200,/api/statereturns 30 tickers witherror: nullafter the mirror swap, and onenew_24h_highsituation fired immediately on the boundary check (see the second bullet above)..github/workflows/blank.ymlis unchanged — CI is still just the scaffold "Hello world" job, so a green CI here doesn't validate the new code.pytestcoverage ofSymbolHistory.price_change_pct,recent_volume_delta, and_detect_situationsif you want.Link to Devin session: https://app.devin.ai/sessions/2eb7aa7344844b0a841c827cba7ab0fa
Requested by: @evgetos