DeltaCalc (DeltaCalc v0.3.0)

Copy Markdown View Source

Pure-Decimal calculation engine for leveraged crypto trading.

Salvaged from the retired TradingDashboard app (TradingDashboard.Risk.* + the hedging formulas in its Portfolio context) into a standalone, headless library so the rebuild does not reinvent the math. Every function is a pure value-in / value-out Decimal computation — no Ecto, no Phoenix, no I/O.

Modules

Agent surface

Every manifest module's public function is annotated with an api/3 declaration (via Descripex), so the engine is discoverable and callable by AI agents (__api__/0, JSON Schema, MCP tools via Descripex.MCP.tools/1, aggregated by DeltaCalc.Manifest). A trading agent can plan a position or size a hedge by calling DeltaCalc as a tool.

Manifest

DeltaCalc.Manifest.build/0 aggregates the full agent surface; DeltaCalc.Manifest.tools/0 exposes the same APIs as MCP tool definitions for trading agents.

Discovery

describe/0..2 is the progressive-disclosure entry point over the same module list — an agent narrows from library to module to function without reading source:

DeltaCalc.describe()                          # L1: every module, namespace, function count
DeltaCalc.describe("hedging")                 # L2: that module's functions, arity, spec
DeltaCalc.describe("hedging", :check_hedge_coverage)   # L3: params, kinds, returns, errors

Short names are the module's last segment underscored (DeltaCalc.DCAPlanner"dca_planner"), accepted as a string or an atom; the full module atom works too.

Summary

Functions

Return the list of modules registered with this library.

Return a Level 1 overview of all modules in this library.

Return Level 2 function list for a module (by full atom, or short name as string or atom).

Return Level 3 function detail (or nil if not found).

Functions

__descripex_modules__()

@spec __descripex_modules__() :: [module()]

Return the list of modules registered with this library.

describe()

@spec describe() :: [map()]

Return a Level 1 overview of all modules in this library.

describe(mod_or_short)

@spec describe(module() | atom() | String.t()) :: [map()]

Return Level 2 function list for a module (by full atom, or short name as string or atom).

describe(mod_or_short, func_name)

@spec describe(module() | atom() | String.t(), atom()) :: map() | nil

Return Level 3 function detail (or nil if not found).