FinStreamKit is a deliberately small, dependency-free Swift package that demonstrates production-oriented patterns for a real-time financial iOS feature:
- strict Swift 6 concurrency;
- actor-owned market state;
AsyncStreamquote subscriptions with cancellation cleanup;- sequence-aware ingestion that rejects stale updates;
- deterministic order-risk decisions using integer price units;
- idempotency-aware order requests;
- atomic local snapshots;
- XCTest coverage and GitHub Actions CI.
It is a portfolio sample, not a trading product and not financial advice.
The interesting part of a trading screen is not drawing a green or red number. It is preserving explicit state and safety under duplicated events, out-of-order updates, reconnects, cancellation and stale prices.
FinStreamKit keeps those concerns outside the UI:
transport events
-> QuoteBook actor
-> sequence/freshness rules
-> immutable MarketQuote snapshots
-> OrderRiskPolicy
-> explicit approved/rejected decision
-> @MainActor presentation model
xcrun swift-format lint --recursive --configuration .swift-format Sources Tests Package.swift
xcrun swift test --parallel
xcrun swift build -c releaseThe package supports iOS 17+ and macOS 14+, has no third-party dependencies and currently contains 13 XCTest cases.
An actor that owns the latest quote per symbol. It rejects out-of-order sequence numbers and exposes cancellation-aware AsyncStream subscriptions buffered to the newest value.
A pure, deterministic validator. It checks quote freshness, spread, quantity, notional limits and optional limit-price deviation. Prices use scaled integers rather than floating point.
An actor that encodes Codable & Sendable values and writes them atomically to a caller-provided directory.
A @MainActor observable model showing how an iOS screen can consume the quote stream while cancellation remains tied to view-model lifecycle.
- No global singleton: dependencies are explicit.
- No floating-point money:
ScaledPricestores integer micros. - No fake transaction result: this package validates requests but never infers execution success from connectivity.
- No unstructured background work: subscriptions use structured tasks and cooperative cancellation.
- No hidden persistence location: the caller supplies the snapshot directory.
See docs/architecture.md for failure modes and extension points. See VERIFICATION.md for the latest local QA record.
Before publishing:
- Create a new public repository named
FinStreamKit. - Push this directory as its root.
- Enable branch protection and require the
swift-testcheck. - Add the repository to LinkedIn Featured after CI is green.
Exact repository metadata and the safe publication sequence are in PUBLISHING.md.