A web application for pricing cryptocurrency options and other financial derivatives. Built with Haskell and TypeScript (with Effect) for high-performance quantitative finance calculations with end-to-end type safety and robust error handling.
Quanty provides an intuitive interface for pricing crypto options using industry-standard models. Start with simple manual parameter input and basic Black-Scholes pricing, then expand to support multiple pricing models, exotic options, real-time market data, and advanced analytics.
See SPEC.md for architecture details and ROADMAP.md for the development plan.
Price European options using the classic Black-Scholes model:
API Endpoint: POST /black-scholes
curl -X POST http://localhost:8080/black-scholes \
-H "Content-Type: application/json" \
-d '{
"spot": 111000,
"strike": 115000,
"timeToExpiry": { "days": 30 },
"volatility": 0.45,
"riskFreeRate": 0.039,
"kind": "Call"
}'
Clone the repository:
git clone [email protected]:0xgleb/quanty.git
cd quanty
Enter development environment:
direnv allow # or: nix develop --impure
This provides GHC, Stack, Node.js, pnpm, and all necessary tools.
Install dependencies:
stack build --fast # Backend dependencies
cd frontend && pnpm install # Frontend dependencies
Run the development servers:
# Terminal 1: Backend API server
stack run quanty-exe
# Terminal 2: Frontend dev server
cd frontend && pnpm dev
Access the application: Open http://localhost:5173 in your browser.
stack build --fast # Build the project
stack test --fast # Run tests
stack exec quanty-exe # Start API server (after building)
fourmolu --mode inplace <file>.hs # Format code
hlint <file>.hs # Lint code
Tip: Use --fast flag during development for faster feedback:
stack build --fast and stack test --fast skip optimizationsTesting: The project uses hspec with automatic test discovery via
hspec-discover:
test/ directorySpec.hs and export a spec :: Spec bindinghspec-wai for testing Servant applicationsstack test --fast during developmentAll frontend commands must be run from the frontend/ directory:
cd frontend
pnpm dev # Start dev server with HMR
pnpm build # Build for production
pnpm preview # Preview production build
pnpm test # Run tests
pnpm lint # Lint code
pnpm format # Format code
pnpm generate-client # Generate TypeScript API client from OpenAPI spec
The frontend TypeScript API client is automatically generated from the Haskell backend's OpenAPI specification. This ensures type-safe end-to-end communication between frontend and backend.
When to regenerate the client:
Full regeneration workflow:
# 1. Generate OpenAPI spec from Haskell API
stack exec generate-openapi
# 2. Generate TypeScript client from OpenAPI spec
cd frontend && pnpm generate-client
What gets generated:
frontend/src/lib/api/generated/types.gen.ts - TypeScript types for all API
modelsfrontend/src/lib/api/generated/sdk.gen.ts - Fully-typed API client functionsfrontend/src/lib/api/client.ts - Configured client wrapper (manual, not
generated)Usage in components:
import { getHealth, getPlaceholder } from "$lib/api/client";
import type { HealthResponse, PlaceholderResponse } from "$lib/api/client";
// Fully typed API calls
const health = await getHealth(); // health: HealthResponse
const data = await getPlaceholder(); // data: PlaceholderResponse
Pre-commit hooks (configured in flake.nix) automatically run on staged files:
Manual usage:
pre-commit run -a # Run all hooks on all files
pre-commit run fourmolu # Run specific hook
pre-commit run --files src/Api.hs # Run on specific file
Hooks run automatically on git commit. To bypass (not recommended):
git commit --no-verify