HTML, CSS, and JavaScript project focused on practical trading workflows, form handling, validation, and useful pre-trade logic.
Current status: v1.0.0, finalized as a first stable portfolio release.
Public portfolio positioning:
- repository description centered on a pre-trade risk workbench
- website pointing to the GitHub Pages deployment
- topics aligned with trading, risk management, JavaScript, C++, and QuantLab
Today, this repository should be read primarily as a reusable and bounded pre-trade risk workbench:
- the browser remains an operator-facing surface
- calculations live in a shared core
- trade plans are exported deterministically in JSON and CSV
- the headless CLI provides a reproducible path without depending on the DOM
- the C++ version acts as an alternate runtime for parity and cross-validation
This repo:
- plans trades
- generates deterministic artifacts
- exports a bounded handoff toward QuantLab
This repo does not own:
ExecutionPolicyExecutionIntent- approval or submit flows
- broker adapters
- paper or live execution
Base rule:
- the calculator plans
- QuantLab validates
- QuantLab decides
- QuantLab executes
Short repo roadmap:
docs/pretrade-workbench-roadmap.mddocs/portfolio-final-checklist.mdCHANGELOG.md
- Trade form with capital, risk per trade, entry, stop loss, and target price
- Optional fees and slippage in the main calculator
- Risk amount and estimated position size calculation
- Potential profit and risk/reward ratio
- Canonical trade plan with estimated costs and net outcomes
- Table for comparing saved scenarios
- Scenario persistence via
localStorage - History with timestamp, strategy, and notes
- Filters and search over saved trades
- CSV export for saved scenarios
- CSV export for full trade history
- Trade plan JSON/CSV export from the web app
- Visual mini backtester with moving averages, commission, slippage, and equity curve
- GitHub Pages workflow for automatic deployment from
main - C++ console version of the calculation engine with CSV/JSON export
- Shared test cases between JS and C++ for metrics and trade plans
- Frontend structure ready to grow without rebuilding the base
npm ci
npm run devThen open:
http://127.0.0.1:4173
To run the main verification suite:
npm testindex.html: application structurestyles.css: responsive stylingrisk-core.js: reusable core for risk, cost, and trade-plan exportsweb/shared.js: formatting, form reading, persistence, and downloadsweb/risk-ui.js: calculator, scenarios, history, and web exportsweb/backtest-ui.js: visual mini backtester and chart/table renderingweb/main.js: final browser bootstrapcli/trade-plan.js: headless CLI for deterministic trade-plan generation without a browserpackage.json: CLI entry point and developer scriptspackage-lock.json: dependency lockfile for local and CI reproducibilityplaywright.config.js: browser/UI test configurationscripts/serve-static.js: minimal static server for browser testing and local previewscripts/clean-local-artifacts.js: optional cleanup for ignored local artifactsdocs/pretrade-workbench-roadmap.md: positioning, boundaries, and short roadmapdocs/quantlab-handoff-contract.md: boundary and handoff contract toward QuantLabdocs/portfolio-final-checklist.md: final checklist for the portfolio-readyv1.0.0stateexamples/quantlab_handoff_request.json: example request for the headless path.github/workflows/deploy-pages.yml: automatic GitHub Pages deployment.github/workflows/contract-parity-ci.yml: contract and parity CIcpp/main.cpp: console application entry pointcpp/risk_engine.cpp: shared C++ calculation enginecpp/risk_case_runner.cpp: C++ runner for parity checks against shared fixturescpp/trade_plan_runner.cpp: C++ runner for canonical trade-plan parity checkscpp/CMakeLists.txt: minimal CMake configurationtests/risk_cases.csv: shared fixtures for risk calculationstests/fixtures/expected_trade_plan.json: canonical trade-plan fixturetests/fixtures/expected_trade_plan.csv: canonical trade-plan CSV fixturetests/fixtures/expected_quantlab_handoff.json: canonical QuantLab handoff fixturetests/run_js_tests.js: JS test runnertests/run_cross_tests.js: JS/C++ parity teststests/run_trade_plan_cross_tests.js: trade-plan parity tests between JS and C++tests/run_cli_tests.js: headless/CLI teststests/run_contract_fixture_tests.js: fixture verification against real CLI output
- Run
npm run devor openindex.htmldirectly in your browser. - Fill in the trade inputs.
- Click
Calcular riesgo. - If you want to save it, click
Guardar escenario. - Active scenarios can be exported to CSV and cleared without losing history.
- The history keeps date, strategy, and notes, and can be filtered or searched.
- The full history can also be exported to CSV.
- The current trade plan can be exported to JSON and CSV.
- In the mini backtester, you can paste prices, choose parameters, and inspect signals, trades, metrics, and the equity curve.
The site is ready to be published with GitHub Pages through GitHub Actions.
Expected public URL:
https://whiteks1.github.io/calculadora_riesgo_trading/
If this is the first time you enable Pages for the repository, make sure the Pages source is set to GitHub Actions.
The console version can calculate multiple trades in one run, validate setups more strictly, and export:
escenarios_cpp.csvtrade_plan_cpp.jsontrade_plans_cpp.csv
g++ -std=c++17 -O2 -o trading_risk_calculator cpp/main.cpp cpp/risk_engine.cpp./trading_risk_calculatorAt the end, the app generates escenarios_cpp.csv, trade_plan_cpp.json, and trade_plans_cpp.csv.
cmake -S cpp -B cpp/build
cmake --build cpp/build --config Releasenpm ci
npm testIf you want to run only part of the suite:
npm run test:js
npm run test:cli
npm run test:contract-fixtures
npm run test:uig++ -std=c++17 -O2 -o risk_case_runner.exe cpp/risk_case_runner.cpp cpp/risk_engine.cpp
g++ -std=c++17 -O2 -o trade_plan_runner.exe cpp/trade_plan_runner.cpp cpp/risk_engine.cpp
node tests/run_cross_tests.js
node tests/run_trade_plan_cross_tests.jsThe repository includes a GitHub Actions workflow in:
.github/workflows/contract-parity-ci.yml
That workflow validates:
- core and CLI syntax
- JS and headless CLI tests
- basic browser/UI coverage for the main flow
- canonical trade-plan and QuantLab handoff fixtures
- parity between JS and C++ for metrics and trade plans
This gives the repo the following baseline:
- versioned fixtures in source control
- automated parity across runtimes
- real browser smoke tests for the main interface
- visible drift before anything is integrated into QuantLab
The GitHub Pages deployment publishes:
index.htmlstyles.cssrisk-core.js- the full
web/directory
That prevents the public site from breaking when the frontend uses split browser modules.
If you want to remove ignored local artifacts generated during development:
npm run clean:artifacts- Keep the handoff boundary and contract stable.
- Extend downstream QuantLab intake only when it is actually needed.
- Keep extra UX or backtester ideas outside the critical path unless they support the pre-trade boundary directly.
Example with a JSON input file:
node cli/trade-plan.js --input-file request.json --json-out outputs/trade_plan.json --csv-out outputs/trade_plan.csvExample with direct flags:
node cli/trade-plan.js --capital 1000 --risk-percent 1 --entry-price 2000 --stop-loss 1950 --exit-price 2100 --fee-percent 0.1 --slippage-percent 0.05 --strategy-name "ETH breakout" --trade-notes "Headless smoke"The CLI:
- does not depend on the DOM or
localStorage - reuses
risk-core.js - prints the canonical trade plan JSON to
stdout - can write deterministic JSON and CSV outputs
- returns a non-zero exit code when the setup is invalid
The intended integration with QuantLab is deliberately bounded:
- this app proposes
- QuantLab validates
- QuantLab decides
- QuantLab executes
The documented contract lives in:
docs/quantlab-handoff-contract.md
Optional handoff export:
node cli/trade-plan.js \
--input-file examples/quantlab_handoff_request.json \
--stdout-format quantlab-handoff \
--quantlab-handoff-out outputs/quantlab_handoff.json