@ruaruababa/vibe-kit 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CATALOG.md +317 -0
- package/README.md +121 -0
- package/aliases.json +65 -0
- package/bin/vibe.js +2 -0
- package/bundles.json +265 -0
- package/catalog.json +1560 -0
- package/dist/antigravity-skills/bin/cli.js +438 -0
- package/dist/antigravity-skills/lib/skill-utils.js +158 -0
- package/dist/antigravity-skills/scripts/build-catalog.js +305 -0
- package/dist/antigravity-skills/scripts/normalize-frontmatter.js +144 -0
- package/dist/antigravity-skills/scripts/validate-skills.js +230 -0
- package/dist/bin/vibe.js +2 -0
- package/dist/dist/src/cli/index.js +26 -0
- package/dist/lib/skill-utils.js +158 -0
- package/dist/scripts/build-catalog.js +50 -0
- package/dist/scripts/normalize-frontmatter.js +144 -0
- package/dist/scripts/validate-skills.js +56 -0
- package/dist/src/cli/index.js +146 -0
- package/dist/src/types/index.js +13 -0
- package/dist/src/utils/fs.js +1 -0
- package/package.json +43 -0
- package/skills/accessibility-compliance-accessibility-audit/SKILL.md +42 -0
- package/skills/accessibility-compliance-accessibility-audit/resources/implementation-playbook.md +502 -0
- package/skills/agent-orchestration-improve-agent/SKILL.md +349 -0
- package/skills/agent-orchestration-multi-agent-optimize/SKILL.md +239 -0
- package/skills/agent-orchestrator/SKILL.md +24 -0
- package/skills/ai-engineer/SKILL.md +171 -0
- package/skills/airflow-dag-patterns/SKILL.md +41 -0
- package/skills/airflow-dag-patterns/resources/implementation-playbook.md +509 -0
- package/skills/angular-migration/SKILL.md +428 -0
- package/skills/anti-reversing-techniques/SKILL.md +42 -0
- package/skills/anti-reversing-techniques/resources/implementation-playbook.md +539 -0
- package/skills/api-design-principles/SKILL.md +37 -0
- package/skills/api-design-principles/assets/api-design-checklist.md +155 -0
- package/skills/api-design-principles/assets/rest-api-template.py +182 -0
- package/skills/api-design-principles/references/graphql-schema-design.md +583 -0
- package/skills/api-design-principles/references/rest-best-practices.md +408 -0
- package/skills/api-design-principles/resources/implementation-playbook.md +513 -0
- package/skills/api-documenter/SKILL.md +184 -0
- package/skills/api-testing-observability-api-mock/SKILL.md +46 -0
- package/skills/api-testing-observability-api-mock/resources/implementation-playbook.md +1327 -0
- package/skills/application-performance-performance-optimization/SKILL.md +154 -0
- package/skills/architect-review/SKILL.md +174 -0
- package/skills/architecture-decision-records/SKILL.md +441 -0
- package/skills/architecture-patterns/SKILL.md +37 -0
- package/skills/architecture-patterns/resources/implementation-playbook.md +479 -0
- package/skills/arm-cortex-expert/SKILL.md +306 -0
- package/skills/async-python-patterns/SKILL.md +39 -0
- package/skills/async-python-patterns/resources/implementation-playbook.md +678 -0
- package/skills/attack-tree-construction/SKILL.md +38 -0
- package/skills/attack-tree-construction/resources/implementation-playbook.md +671 -0
- package/skills/auth-implementation-patterns/SKILL.md +39 -0
- package/skills/auth-implementation-patterns/resources/implementation-playbook.md +618 -0
- package/skills/backend-architect/SKILL.md +333 -0
- package/skills/backend-development-feature-development/SKILL.md +180 -0
- package/skills/backend-security-coder/SKILL.md +156 -0
- package/skills/backtesting-frameworks/SKILL.md +39 -0
- package/skills/backtesting-frameworks/resources/implementation-playbook.md +647 -0
- package/skills/bash-defensive-patterns/SKILL.md +43 -0
- package/skills/bash-defensive-patterns/resources/implementation-playbook.md +517 -0
- package/skills/bash-pro/SKILL.md +310 -0
- package/skills/bats-testing-patterns/SKILL.md +34 -0
- package/skills/bats-testing-patterns/resources/implementation-playbook.md +614 -0
- package/skills/bazel-build-optimization/SKILL.md +397 -0
- package/skills/billing-automation/SKILL.md +42 -0
- package/skills/billing-automation/resources/implementation-playbook.md +544 -0
- package/skills/binary-analysis-patterns/SKILL.md +450 -0
- package/skills/blockchain-developer/SKILL.md +208 -0
- package/skills/business-analyst/SKILL.md +182 -0
- package/skills/c-pro/SKILL.md +56 -0
- package/skills/c4-architecture-c4-architecture/SKILL.md +389 -0
- package/skills/c4-code/SKILL.md +244 -0
- package/skills/c4-component/SKILL.md +153 -0
- package/skills/c4-container/SKILL.md +171 -0
- package/skills/c4-context/SKILL.md +150 -0
- package/skills/changelog-automation/SKILL.md +38 -0
- package/skills/changelog-automation/resources/implementation-playbook.md +538 -0
- package/skills/cicd-automation-workflow-automate/SKILL.md +51 -0
- package/skills/cicd-automation-workflow-automate/resources/implementation-playbook.md +1333 -0
- package/skills/clean-markdown/SKILL.md +23 -0
- package/skills/cloud-architect/SKILL.md +135 -0
- package/skills/code-documentation-code-explain/SKILL.md +46 -0
- package/skills/code-documentation-code-explain/resources/implementation-playbook.md +802 -0
- package/skills/code-documentation-doc-generate/SKILL.md +48 -0
- package/skills/code-documentation-doc-generate/resources/implementation-playbook.md +640 -0
- package/skills/code-refactoring-context-restore/SKILL.md +179 -0
- package/skills/code-refactoring-refactor-clean/SKILL.md +51 -0
- package/skills/code-refactoring-refactor-clean/resources/implementation-playbook.md +879 -0
- package/skills/code-refactoring-tech-debt/SKILL.md +386 -0
- package/skills/code-review-ai-ai-review/SKILL.md +450 -0
- package/skills/code-review-excellence/SKILL.md +40 -0
- package/skills/code-review-excellence/resources/implementation-playbook.md +515 -0
- package/skills/code-reviewer/SKILL.md +178 -0
- package/skills/codebase-cleanup-deps-audit/SKILL.md +51 -0
- package/skills/codebase-cleanup-deps-audit/resources/implementation-playbook.md +766 -0
- package/skills/codebase-cleanup-refactor-clean/SKILL.md +51 -0
- package/skills/codebase-cleanup-refactor-clean/resources/implementation-playbook.md +879 -0
- package/skills/codebase-cleanup-tech-debt/SKILL.md +386 -0
- package/skills/competitive-landscape/SKILL.md +34 -0
- package/skills/competitive-landscape/resources/implementation-playbook.md +494 -0
- package/skills/comprehensive-review-full-review/SKILL.md +146 -0
- package/skills/comprehensive-review-pr-enhance/SKILL.md +46 -0
- package/skills/comprehensive-review-pr-enhance/resources/implementation-playbook.md +691 -0
- package/skills/conductor-implement/SKILL.md +388 -0
- package/skills/conductor-manage/SKILL.md +39 -0
- package/skills/conductor-manage/resources/implementation-playbook.md +1120 -0
- package/skills/conductor-new-track/SKILL.md +433 -0
- package/skills/conductor-revert/SKILL.md +372 -0
- package/skills/conductor-setup/SKILL.md +426 -0
- package/skills/conductor-status/SKILL.md +338 -0
- package/skills/conductor-validator/SKILL.md +62 -0
- package/skills/content-marketer/SKILL.md +170 -0
- package/skills/context-driven-development/SKILL.md +400 -0
- package/skills/context-management-context-restore/SKILL.md +179 -0
- package/skills/context-management-context-save/SKILL.md +177 -0
- package/skills/context-manager/SKILL.md +185 -0
- package/skills/cost-optimization/SKILL.md +286 -0
- package/skills/cpp-pro/SKILL.md +59 -0
- package/skills/cqrs-implementation/SKILL.md +35 -0
- package/skills/cqrs-implementation/resources/implementation-playbook.md +540 -0
- package/skills/csharp-pro/SKILL.md +59 -0
- package/skills/customer-support/SKILL.md +170 -0
- package/skills/data-engineer/SKILL.md +224 -0
- package/skills/data-engineering-data-driven-feature/SKILL.md +182 -0
- package/skills/data-engineering-data-pipeline/SKILL.md +201 -0
- package/skills/data-quality-frameworks/SKILL.md +40 -0
- package/skills/data-quality-frameworks/resources/implementation-playbook.md +573 -0
- package/skills/data-scientist/SKILL.md +199 -0
- package/skills/data-storytelling/SKILL.md +465 -0
- package/skills/database-admin/SKILL.md +165 -0
- package/skills/database-architect/SKILL.md +268 -0
- package/skills/database-cloud-optimization-cost-optimize/SKILL.md +44 -0
- package/skills/database-cloud-optimization-cost-optimize/resources/implementation-playbook.md +1441 -0
- package/skills/database-migration/SKILL.md +436 -0
- package/skills/database-migrations-migration-observability/SKILL.md +420 -0
- package/skills/database-migrations-sql-migrations/SKILL.md +53 -0
- package/skills/database-migrations-sql-migrations/resources/implementation-playbook.md +499 -0
- package/skills/database-optimizer/SKILL.md +167 -0
- package/skills/dbt-transformation-patterns/SKILL.md +34 -0
- package/skills/dbt-transformation-patterns/resources/implementation-playbook.md +547 -0
- package/skills/debugger/SKILL.md +49 -0
- package/skills/debugging-strategies/SKILL.md +34 -0
- package/skills/debugging-strategies/resources/implementation-playbook.md +511 -0
- package/skills/debugging-toolkit-smart-debug/SKILL.md +197 -0
- package/skills/defi-protocol-templates/SKILL.md +466 -0
- package/skills/dependency-management-deps-audit/SKILL.md +44 -0
- package/skills/dependency-management-deps-audit/resources/implementation-playbook.md +766 -0
- package/skills/dependency-upgrade/SKILL.md +421 -0
- package/skills/deployment-engineer/SKILL.md +170 -0
- package/skills/deployment-pipeline-design/SKILL.md +371 -0
- package/skills/deployment-validation-config-validate/SKILL.md +496 -0
- package/skills/devops-troubleshooter/SKILL.md +161 -0
- package/skills/distributed-debugging-debug-trace/SKILL.md +44 -0
- package/skills/distributed-debugging-debug-trace/resources/implementation-playbook.md +1307 -0
- package/skills/distributed-tracing/SKILL.md +450 -0
- package/skills/django-pro/SKILL.md +180 -0
- package/skills/docs-architect/SKILL.md +98 -0
- package/skills/documentation-generation-doc-generate/SKILL.md +48 -0
- package/skills/documentation-generation-doc-generate/resources/implementation-playbook.md +640 -0
- package/skills/dotnet-architect/SKILL.md +197 -0
- package/skills/dotnet-backend-patterns/SKILL.md +37 -0
- package/skills/dotnet-backend-patterns/assets/repository-template.cs +523 -0
- package/skills/dotnet-backend-patterns/assets/service-template.cs +336 -0
- package/skills/dotnet-backend-patterns/references/dapper-patterns.md +544 -0
- package/skills/dotnet-backend-patterns/references/ef-core-best-practices.md +355 -0
- package/skills/dotnet-backend-patterns/resources/implementation-playbook.md +799 -0
- package/skills/dummy-skill/SKILL.md +5 -0
- package/skills/dx-optimizer/SKILL.md +83 -0
- package/skills/e2e-testing-patterns/SKILL.md +41 -0
- package/skills/e2e-testing-patterns/resources/implementation-playbook.md +531 -0
- package/skills/elixir-pro/SKILL.md +59 -0
- package/skills/embedding-strategies/SKILL.md +491 -0
- package/skills/employment-contract-templates/SKILL.md +39 -0
- package/skills/employment-contract-templates/resources/implementation-playbook.md +493 -0
- package/skills/error-debugging-error-analysis/SKILL.md +47 -0
- package/skills/error-debugging-error-analysis/resources/implementation-playbook.md +1143 -0
- package/skills/error-debugging-error-trace/SKILL.md +43 -0
- package/skills/error-debugging-error-trace/resources/implementation-playbook.md +1361 -0
- package/skills/error-debugging-multi-agent-review/SKILL.md +216 -0
- package/skills/error-detective/SKILL.md +53 -0
- package/skills/error-diagnostics-error-analysis/SKILL.md +47 -0
- package/skills/error-diagnostics-error-analysis/resources/implementation-playbook.md +1143 -0
- package/skills/error-diagnostics-error-trace/SKILL.md +48 -0
- package/skills/error-diagnostics-error-trace/resources/implementation-playbook.md +1371 -0
- package/skills/error-diagnostics-smart-debug/SKILL.md +197 -0
- package/skills/error-handling-patterns/SKILL.md +35 -0
- package/skills/error-handling-patterns/resources/implementation-playbook.md +635 -0
- package/skills/event-sourcing-architect/SKILL.md +58 -0
- package/skills/event-store-design/SKILL.md +449 -0
- package/skills/fastapi-pro/SKILL.md +192 -0
- package/skills/fastapi-templates/SKILL.md +32 -0
- package/skills/fastapi-templates/resources/implementation-playbook.md +566 -0
- package/skills/final-test/SKILL.md +5 -0
- package/skills/firmware-analyst/SKILL.md +320 -0
- package/skills/flutter-expert/SKILL.md +200 -0
- package/skills/framework-migration-code-migrate/SKILL.md +48 -0
- package/skills/framework-migration-code-migrate/resources/implementation-playbook.md +1052 -0
- package/skills/framework-migration-deps-upgrade/SKILL.md +48 -0
- package/skills/framework-migration-deps-upgrade/resources/implementation-playbook.md +755 -0
- package/skills/framework-migration-legacy-modernize/SKILL.md +132 -0
- package/skills/frontend-developer/SKILL.md +171 -0
- package/skills/frontend-mobile-development-component-scaffold/SKILL.md +403 -0
- package/skills/frontend-mobile-security-xss-scan/SKILL.md +322 -0
- package/skills/frontend-security-coder/SKILL.md +170 -0
- package/skills/full-stack-orchestration-full-stack-feature/SKILL.md +135 -0
- package/skills/gdpr-data-handling/SKILL.md +33 -0
- package/skills/gdpr-data-handling/resources/implementation-playbook.md +615 -0
- package/skills/git-advanced-workflows/SKILL.md +412 -0
- package/skills/git-pr-workflows-git-workflow/SKILL.md +140 -0
- package/skills/git-pr-workflows-onboard/SKILL.md +416 -0
- package/skills/git-pr-workflows-pr-enhance/SKILL.md +48 -0
- package/skills/git-pr-workflows-pr-enhance/resources/implementation-playbook.md +701 -0
- package/skills/github-actions-templates/SKILL.md +345 -0
- package/skills/gitlab-ci-patterns/SKILL.md +283 -0
- package/skills/gitops-workflow/SKILL.md +303 -0
- package/skills/gitops-workflow/references/argocd-setup.md +134 -0
- package/skills/gitops-workflow/references/sync-policies.md +131 -0
- package/skills/go-concurrency-patterns/SKILL.md +33 -0
- package/skills/go-concurrency-patterns/resources/implementation-playbook.md +654 -0
- package/skills/godot-gdscript-patterns/SKILL.md +33 -0
- package/skills/godot-gdscript-patterns/resources/implementation-playbook.md +804 -0
- package/skills/golang-pro/SKILL.md +179 -0
- package/skills/grafana-dashboards/SKILL.md +381 -0
- package/skills/graphql-architect/SKILL.md +182 -0
- package/skills/haskell-pro/SKILL.md +56 -0
- package/skills/helm-chart-scaffolding/SKILL.md +34 -0
- package/skills/helm-chart-scaffolding/assets/Chart.yaml.template +42 -0
- package/skills/helm-chart-scaffolding/assets/values.yaml.template +185 -0
- package/skills/helm-chart-scaffolding/references/chart-structure.md +500 -0
- package/skills/helm-chart-scaffolding/resources/implementation-playbook.md +543 -0
- package/skills/helm-chart-scaffolding/scripts/validate-chart.sh +244 -0
- package/skills/hr-pro/SKILL.md +126 -0
- package/skills/hybrid-cloud-architect/SKILL.md +168 -0
- package/skills/hybrid-cloud-networking/SKILL.md +238 -0
- package/skills/hybrid-search-implementation/SKILL.md +32 -0
- package/skills/hybrid-search-implementation/resources/implementation-playbook.md +567 -0
- package/skills/incident-responder/SKILL.md +213 -0
- package/skills/incident-response-incident-response/SKILL.md +168 -0
- package/skills/incident-response-smart-fix/SKILL.md +29 -0
- package/skills/incident-response-smart-fix/resources/implementation-playbook.md +838 -0
- package/skills/incident-runbook-templates/SKILL.md +395 -0
- package/skills/ios-developer/SKILL.md +219 -0
- package/skills/istio-traffic-management/SKILL.md +337 -0
- package/skills/java-pro/SKILL.md +177 -0
- package/skills/javascript-pro/SKILL.md +57 -0
- package/skills/javascript-testing-patterns/SKILL.md +35 -0
- package/skills/javascript-testing-patterns/resources/implementation-playbook.md +1024 -0
- package/skills/javascript-typescript-typescript-scaffold/SKILL.md +361 -0
- package/skills/julia-pro/SKILL.md +209 -0
- package/skills/k8s-manifest-generator/SKILL.md +35 -0
- package/skills/k8s-manifest-generator/assets/configmap-template.yaml +296 -0
- package/skills/k8s-manifest-generator/assets/deployment-template.yaml +203 -0
- package/skills/k8s-manifest-generator/assets/service-template.yaml +171 -0
- package/skills/k8s-manifest-generator/references/deployment-spec.md +753 -0
- package/skills/k8s-manifest-generator/references/service-spec.md +724 -0
- package/skills/k8s-manifest-generator/resources/implementation-playbook.md +510 -0
- package/skills/k8s-security-policies/SKILL.md +346 -0
- package/skills/k8s-security-policies/assets/network-policy-template.yaml +177 -0
- package/skills/k8s-security-policies/references/rbac-patterns.md +187 -0
- package/skills/kpi-dashboard-design/SKILL.md +440 -0
- package/skills/kubernetes-architect/SKILL.md +170 -0
- package/skills/langchain-architecture/SKILL.md +350 -0
- package/skills/legacy-modernizer/SKILL.md +53 -0
- package/skills/legal-advisor/SKILL.md +70 -0
- package/skills/linkerd-patterns/SKILL.md +321 -0
- package/skills/llm-application-dev-ai-assistant/SKILL.md +35 -0
- package/skills/llm-application-dev-ai-assistant/resources/implementation-playbook.md +1236 -0
- package/skills/llm-application-dev-langchain-agent/SKILL.md +246 -0
- package/skills/llm-application-dev-prompt-optimize/SKILL.md +37 -0
- package/skills/llm-application-dev-prompt-optimize/resources/implementation-playbook.md +591 -0
- package/skills/llm-evaluation/SKILL.md +483 -0
- package/skills/machine-learning-ops-ml-pipeline/SKILL.md +314 -0
- package/skills/malware-analyst/SKILL.md +247 -0
- package/skills/market-sizing-analysis/SKILL.md +425 -0
- package/skills/market-sizing-analysis/examples/saas-market-sizing.md +349 -0
- package/skills/market-sizing-analysis/references/data-sources.md +360 -0
- package/skills/memory-forensics/SKILL.md +491 -0
- package/skills/memory-safety-patterns/SKILL.md +33 -0
- package/skills/memory-safety-patterns/resources/implementation-playbook.md +603 -0
- package/skills/mermaid-expert/SKILL.md +59 -0
- package/skills/microservices-patterns/SKILL.md +35 -0
- package/skills/microservices-patterns/resources/implementation-playbook.md +607 -0
- package/skills/minecraft-bukkit-pro/SKILL.md +126 -0
- package/skills/ml-engineer/SKILL.md +168 -0
- package/skills/ml-pipeline-workflow/SKILL.md +257 -0
- package/skills/mlops-engineer/SKILL.md +219 -0
- package/skills/mobile-developer/SKILL.md +205 -0
- package/skills/mobile-security-coder/SKILL.md +184 -0
- package/skills/modern-javascript-patterns/SKILL.md +35 -0
- package/skills/modern-javascript-patterns/resources/implementation-playbook.md +910 -0
- package/skills/monorepo-architect/SKILL.md +61 -0
- package/skills/monorepo-management/SKILL.md +35 -0
- package/skills/monorepo-management/resources/implementation-playbook.md +621 -0
- package/skills/mtls-configuration/SKILL.md +359 -0
- package/skills/multi-cloud-architecture/SKILL.md +189 -0
- package/skills/multi-platform-apps-multi-platform/SKILL.md +203 -0
- package/skills/network-engineer/SKILL.md +169 -0
- package/skills/nextjs-app-router-patterns/SKILL.md +33 -0
- package/skills/nextjs-app-router-patterns/resources/implementation-playbook.md +543 -0
- package/skills/nft-standards/SKILL.md +395 -0
- package/skills/node-expert/SKILL.md +23 -0
- package/skills/nodejs-backend-patterns/SKILL.md +35 -0
- package/skills/nodejs-backend-patterns/resources/implementation-playbook.md +1019 -0
- package/skills/nx-workspace-patterns/SKILL.md +464 -0
- package/skills/observability-engineer/SKILL.md +237 -0
- package/skills/observability-monitoring-monitor-setup/SKILL.md +48 -0
- package/skills/observability-monitoring-monitor-setup/resources/implementation-playbook.md +505 -0
- package/skills/observability-monitoring-slo-implement/SKILL.md +43 -0
- package/skills/observability-monitoring-slo-implement/resources/implementation-playbook.md +1077 -0
- package/skills/on-call-handoff-patterns/SKILL.md +453 -0
- package/skills/openapi-spec-generation/SKILL.md +33 -0
- package/skills/openapi-spec-generation/resources/implementation-playbook.md +1027 -0
- package/skills/payment-integration/SKILL.md +77 -0
- package/skills/paypal-integration/SKILL.md +479 -0
- package/skills/pci-compliance/SKILL.md +478 -0
- package/skills/performance-engineer/SKILL.md +180 -0
- package/skills/performance-testing-review-ai-review/SKILL.md +450 -0
- package/skills/performance-testing-review-multi-agent-review/SKILL.md +216 -0
- package/skills/php-pro/SKILL.md +63 -0
- package/skills/posix-shell-pro/SKILL.md +304 -0
- package/skills/postgresql/SKILL.md +230 -0
- package/skills/postmortem-writing/SKILL.md +386 -0
- package/skills/projection-patterns/SKILL.md +33 -0
- package/skills/projection-patterns/resources/implementation-playbook.md +501 -0
- package/skills/prometheus-configuration/SKILL.md +404 -0
- package/skills/prompt-engineer/SKILL.md +272 -0
- package/skills/prompt-engineering-patterns/SKILL.md +213 -0
- package/skills/prompt-engineering-patterns/assets/few-shot-examples.json +106 -0
- package/skills/prompt-engineering-patterns/assets/prompt-template-library.md +246 -0
- package/skills/prompt-engineering-patterns/references/chain-of-thought.md +399 -0
- package/skills/prompt-engineering-patterns/references/few-shot-learning.md +369 -0
- package/skills/prompt-engineering-patterns/references/prompt-optimization.md +414 -0
- package/skills/prompt-engineering-patterns/references/prompt-templates.md +470 -0
- package/skills/prompt-engineering-patterns/references/system-prompts.md +189 -0
- package/skills/prompt-engineering-patterns/scripts/optimize-prompt.py +279 -0
- package/skills/protocol-reverse-engineering/SKILL.md +29 -0
- package/skills/protocol-reverse-engineering/resources/implementation-playbook.md +509 -0
- package/skills/python-development-python-scaffold/SKILL.md +331 -0
- package/skills/python-packaging/SKILL.md +36 -0
- package/skills/python-packaging/resources/implementation-playbook.md +869 -0
- package/skills/python-performance-optimization/SKILL.md +36 -0
- package/skills/python-performance-optimization/resources/implementation-playbook.md +868 -0
- package/skills/python-pro/SKILL.md +158 -0
- package/skills/python-testing-patterns/SKILL.md +37 -0
- package/skills/python-testing-patterns/resources/implementation-playbook.md +906 -0
- package/skills/quant-analyst/SKILL.md +53 -0
- package/skills/rag-implementation/SKILL.md +421 -0
- package/skills/react-modernization/SKILL.md +34 -0
- package/skills/react-modernization/resources/implementation-playbook.md +512 -0
- package/skills/react-native-architecture/SKILL.md +33 -0
- package/skills/react-native-architecture/resources/implementation-playbook.md +670 -0
- package/skills/react-state-management/SKILL.md +441 -0
- package/skills/reference-builder/SKILL.md +188 -0
- package/skills/reverse-engineer/SKILL.md +173 -0
- package/skills/risk-manager/SKILL.md +61 -0
- package/skills/risk-metrics-calculation/SKILL.md +33 -0
- package/skills/risk-metrics-calculation/resources/implementation-playbook.md +554 -0
- package/skills/ruby-pro/SKILL.md +56 -0
- package/skills/rust-async-patterns/SKILL.md +33 -0
- package/skills/rust-async-patterns/resources/implementation-playbook.md +516 -0
- package/skills/rust-pro/SKILL.md +178 -0
- package/skills/saga-orchestration/SKILL.md +496 -0
- package/skills/sales-automator/SKILL.md +55 -0
- package/skills/sast-configuration/SKILL.md +212 -0
- package/skills/scala-pro/SKILL.md +82 -0
- package/skills/screen-reader-testing/SKILL.md +33 -0
- package/skills/screen-reader-testing/resources/implementation-playbook.md +544 -0
- package/skills/search-specialist/SKILL.md +80 -0
- package/skills/secrets-management/SKILL.md +364 -0
- package/skills/security-auditor/SKILL.md +169 -0
- package/skills/security-compliance-compliance-check/SKILL.md +55 -0
- package/skills/security-compliance-compliance-check/resources/implementation-playbook.md +963 -0
- package/skills/security-requirement-extraction/SKILL.md +33 -0
- package/skills/security-requirement-extraction/resources/implementation-playbook.md +676 -0
- package/skills/security-scanning-security-dependencies/SKILL.md +43 -0
- package/skills/security-scanning-security-dependencies/resources/implementation-playbook.md +544 -0
- package/skills/security-scanning-security-hardening/SKILL.md +147 -0
- package/skills/security-scanning-security-sast/SKILL.md +495 -0
- package/skills/seo-authority-builder/SKILL.md +136 -0
- package/skills/seo-cannibalization-detector/SKILL.md +123 -0
- package/skills/seo-content-auditor/SKILL.md +83 -0
- package/skills/seo-content-planner/SKILL.md +108 -0
- package/skills/seo-content-refresher/SKILL.md +118 -0
- package/skills/seo-content-writer/SKILL.md +96 -0
- package/skills/seo-keyword-strategist/SKILL.md +95 -0
- package/skills/seo-meta-optimizer/SKILL.md +92 -0
- package/skills/seo-snippet-hunter/SKILL.md +114 -0
- package/skills/seo-structure-architect/SKILL.md +108 -0
- package/skills/service-mesh-expert/SKILL.md +58 -0
- package/skills/service-mesh-observability/SKILL.md +395 -0
- package/skills/shellcheck-configuration/SKILL.md +466 -0
- package/skills/similarity-search-patterns/SKILL.md +33 -0
- package/skills/similarity-search-patterns/resources/implementation-playbook.md +557 -0
- package/skills/slo-implementation/SKILL.md +341 -0
- package/skills/solidity-security/SKILL.md +34 -0
- package/skills/solidity-security/resources/implementation-playbook.md +524 -0
- package/skills/spark-optimization/SKILL.md +427 -0
- package/skills/sql-optimization-patterns/SKILL.md +35 -0
- package/skills/sql-optimization-patterns/resources/implementation-playbook.md +504 -0
- package/skills/sql-pro/SKILL.md +173 -0
- package/skills/startup-analyst/SKILL.md +328 -0
- package/skills/startup-business-analyst-business-case/SKILL.md +487 -0
- package/skills/startup-business-analyst-financial-projections/SKILL.md +353 -0
- package/skills/startup-business-analyst-market-opportunity/SKILL.md +240 -0
- package/skills/startup-financial-modeling/SKILL.md +467 -0
- package/skills/startup-metrics-framework/SKILL.md +34 -0
- package/skills/startup-metrics-framework/resources/implementation-playbook.md +500 -0
- package/skills/stride-analysis-patterns/SKILL.md +33 -0
- package/skills/stride-analysis-patterns/resources/implementation-playbook.md +655 -0
- package/skills/stripe-integration/SKILL.md +454 -0
- package/skills/systems-programming-rust-project/SKILL.md +440 -0
- package/skills/tailwind-design-system/SKILL.md +33 -0
- package/skills/tailwind-design-system/resources/implementation-playbook.md +665 -0
- package/skills/tdd-orchestrator/SKILL.md +205 -0
- package/skills/tdd-workflows-tdd-cycle/SKILL.md +221 -0
- package/skills/tdd-workflows-tdd-green/SKILL.md +73 -0
- package/skills/tdd-workflows-tdd-green/resources/implementation-playbook.md +870 -0
- package/skills/tdd-workflows-tdd-red/SKILL.md +164 -0
- package/skills/tdd-workflows-tdd-refactor/SKILL.md +187 -0
- package/skills/team-collaboration-issue/SKILL.md +37 -0
- package/skills/team-collaboration-issue/resources/implementation-playbook.md +640 -0
- package/skills/team-collaboration-standup-notes/SKILL.md +44 -0
- package/skills/team-collaboration-standup-notes/resources/implementation-playbook.md +768 -0
- package/skills/team-composition-analysis/SKILL.md +413 -0
- package/skills/temporal-python-pro/SKILL.md +370 -0
- package/skills/temporal-python-testing/SKILL.md +170 -0
- package/skills/temporal-python-testing/resources/integration-testing.md +455 -0
- package/skills/temporal-python-testing/resources/local-setup.md +553 -0
- package/skills/temporal-python-testing/resources/replay-testing.md +462 -0
- package/skills/temporal-python-testing/resources/unit-testing.md +328 -0
- package/skills/terraform-module-library/SKILL.md +261 -0
- package/skills/terraform-module-library/references/aws-modules.md +63 -0
- package/skills/terraform-specialist/SKILL.md +166 -0
- package/skills/test-automator/SKILL.md +224 -0
- package/skills/threat-mitigation-mapping/SKILL.md +33 -0
- package/skills/threat-mitigation-mapping/resources/implementation-playbook.md +744 -0
- package/skills/threat-modeling-expert/SKILL.md +60 -0
- package/skills/track-management/SKILL.md +38 -0
- package/skills/track-management/resources/implementation-playbook.md +591 -0
- package/skills/turborepo-caching/SKILL.md +419 -0
- package/skills/tutorial-engineer/SKILL.md +139 -0
- package/skills/typescript-advanced-types/SKILL.md +35 -0
- package/skills/typescript-advanced-types/resources/implementation-playbook.md +716 -0
- package/skills/typescript-pro/SKILL.md +55 -0
- package/skills/ui-minimal/SKILL.md +23 -0
- package/skills/ui-ux-designer/SKILL.md +209 -0
- package/skills/ui-visual-validator/SKILL.md +214 -0
- package/skills/unit-testing-test-generate/SKILL.md +319 -0
- package/skills/unity-developer/SKILL.md +230 -0
- package/skills/unity-ecs-patterns/SKILL.md +33 -0
- package/skills/unity-ecs-patterns/resources/implementation-playbook.md +625 -0
- package/skills/uv-package-manager/SKILL.md +37 -0
- package/skills/uv-package-manager/resources/implementation-playbook.md +830 -0
- package/skills/vector-database-engineer/SKILL.md +60 -0
- package/skills/vector-index-tuning/SKILL.md +42 -0
- package/skills/vector-index-tuning/resources/implementation-playbook.md +507 -0
- package/skills/wcag-audit-patterns/SKILL.md +41 -0
- package/skills/wcag-audit-patterns/resources/implementation-playbook.md +541 -0
- package/skills/web3-testing/SKILL.md +427 -0
- package/skills/workflow-orchestration-patterns/SKILL.md +333 -0
- package/skills/workflow-patterns/SKILL.md +38 -0
- package/skills/workflow-patterns/resources/implementation-playbook.md +621 -0
|
@@ -0,0 +1,647 @@
|
|
|
1
|
+
# Backtesting Frameworks Implementation Playbook
|
|
2
|
+
|
|
3
|
+
This file contains detailed patterns, checklists, and code samples referenced by the skill.
|
|
4
|
+
|
|
5
|
+
## Core Concepts
|
|
6
|
+
|
|
7
|
+
### 1. Backtesting Biases
|
|
8
|
+
|
|
9
|
+
| Bias | Description | Mitigation |
|
|
10
|
+
|------|-------------|------------|
|
|
11
|
+
| **Look-ahead** | Using future information | Point-in-time data |
|
|
12
|
+
| **Survivorship** | Only testing on survivors | Use delisted securities |
|
|
13
|
+
| **Overfitting** | Curve-fitting to history | Out-of-sample testing |
|
|
14
|
+
| **Selection** | Cherry-picking strategies | Pre-registration |
|
|
15
|
+
| **Transaction** | Ignoring trading costs | Realistic cost models |
|
|
16
|
+
|
|
17
|
+
### 2. Proper Backtest Structure
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
Historical Data
|
|
21
|
+
│
|
|
22
|
+
▼
|
|
23
|
+
┌─────────────────────────────────────────┐
|
|
24
|
+
│ Training Set │
|
|
25
|
+
│ (Strategy Development & Optimization) │
|
|
26
|
+
└─────────────────────────────────────────┘
|
|
27
|
+
│
|
|
28
|
+
▼
|
|
29
|
+
┌─────────────────────────────────────────┐
|
|
30
|
+
│ Validation Set │
|
|
31
|
+
│ (Parameter Selection, No Peeking) │
|
|
32
|
+
└─────────────────────────────────────────┘
|
|
33
|
+
│
|
|
34
|
+
▼
|
|
35
|
+
┌─────────────────────────────────────────┐
|
|
36
|
+
│ Test Set │
|
|
37
|
+
│ (Final Performance Evaluation) │
|
|
38
|
+
└─────────────────────────────────────────┘
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### 3. Walk-Forward Analysis
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
Window 1: [Train──────][Test]
|
|
45
|
+
Window 2: [Train──────][Test]
|
|
46
|
+
Window 3: [Train──────][Test]
|
|
47
|
+
Window 4: [Train──────][Test]
|
|
48
|
+
─────▶ Time
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Implementation Patterns
|
|
52
|
+
|
|
53
|
+
### Pattern 1: Event-Driven Backtester
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from abc import ABC, abstractmethod
|
|
57
|
+
from dataclasses import dataclass, field
|
|
58
|
+
from datetime import datetime
|
|
59
|
+
from decimal import Decimal
|
|
60
|
+
from enum import Enum
|
|
61
|
+
from typing import Dict, List, Optional
|
|
62
|
+
import pandas as pd
|
|
63
|
+
import numpy as np
|
|
64
|
+
|
|
65
|
+
class OrderSide(Enum):
|
|
66
|
+
BUY = "buy"
|
|
67
|
+
SELL = "sell"
|
|
68
|
+
|
|
69
|
+
class OrderType(Enum):
|
|
70
|
+
MARKET = "market"
|
|
71
|
+
LIMIT = "limit"
|
|
72
|
+
STOP = "stop"
|
|
73
|
+
|
|
74
|
+
@dataclass
|
|
75
|
+
class Order:
|
|
76
|
+
symbol: str
|
|
77
|
+
side: OrderSide
|
|
78
|
+
quantity: Decimal
|
|
79
|
+
order_type: OrderType
|
|
80
|
+
limit_price: Optional[Decimal] = None
|
|
81
|
+
stop_price: Optional[Decimal] = None
|
|
82
|
+
timestamp: Optional[datetime] = None
|
|
83
|
+
|
|
84
|
+
@dataclass
|
|
85
|
+
class Fill:
|
|
86
|
+
order: Order
|
|
87
|
+
fill_price: Decimal
|
|
88
|
+
fill_quantity: Decimal
|
|
89
|
+
commission: Decimal
|
|
90
|
+
slippage: Decimal
|
|
91
|
+
timestamp: datetime
|
|
92
|
+
|
|
93
|
+
@dataclass
|
|
94
|
+
class Position:
|
|
95
|
+
symbol: str
|
|
96
|
+
quantity: Decimal = Decimal("0")
|
|
97
|
+
avg_cost: Decimal = Decimal("0")
|
|
98
|
+
realized_pnl: Decimal = Decimal("0")
|
|
99
|
+
|
|
100
|
+
def update(self, fill: Fill) -> None:
|
|
101
|
+
if fill.order.side == OrderSide.BUY:
|
|
102
|
+
new_quantity = self.quantity + fill.fill_quantity
|
|
103
|
+
if new_quantity != 0:
|
|
104
|
+
self.avg_cost = (
|
|
105
|
+
(self.quantity * self.avg_cost + fill.fill_quantity * fill.fill_price)
|
|
106
|
+
/ new_quantity
|
|
107
|
+
)
|
|
108
|
+
self.quantity = new_quantity
|
|
109
|
+
else:
|
|
110
|
+
self.realized_pnl += fill.fill_quantity * (fill.fill_price - self.avg_cost)
|
|
111
|
+
self.quantity -= fill.fill_quantity
|
|
112
|
+
|
|
113
|
+
@dataclass
|
|
114
|
+
class Portfolio:
|
|
115
|
+
cash: Decimal
|
|
116
|
+
positions: Dict[str, Position] = field(default_factory=dict)
|
|
117
|
+
|
|
118
|
+
def get_position(self, symbol: str) -> Position:
|
|
119
|
+
if symbol not in self.positions:
|
|
120
|
+
self.positions[symbol] = Position(symbol=symbol)
|
|
121
|
+
return self.positions[symbol]
|
|
122
|
+
|
|
123
|
+
def process_fill(self, fill: Fill) -> None:
|
|
124
|
+
position = self.get_position(fill.order.symbol)
|
|
125
|
+
position.update(fill)
|
|
126
|
+
|
|
127
|
+
if fill.order.side == OrderSide.BUY:
|
|
128
|
+
self.cash -= fill.fill_price * fill.fill_quantity + fill.commission
|
|
129
|
+
else:
|
|
130
|
+
self.cash += fill.fill_price * fill.fill_quantity - fill.commission
|
|
131
|
+
|
|
132
|
+
def get_equity(self, prices: Dict[str, Decimal]) -> Decimal:
|
|
133
|
+
equity = self.cash
|
|
134
|
+
for symbol, position in self.positions.items():
|
|
135
|
+
if position.quantity != 0 and symbol in prices:
|
|
136
|
+
equity += position.quantity * prices[symbol]
|
|
137
|
+
return equity
|
|
138
|
+
|
|
139
|
+
class Strategy(ABC):
|
|
140
|
+
@abstractmethod
|
|
141
|
+
def on_bar(self, timestamp: datetime, data: pd.DataFrame) -> List[Order]:
|
|
142
|
+
pass
|
|
143
|
+
|
|
144
|
+
@abstractmethod
|
|
145
|
+
def on_fill(self, fill: Fill) -> None:
|
|
146
|
+
pass
|
|
147
|
+
|
|
148
|
+
class ExecutionModel(ABC):
|
|
149
|
+
@abstractmethod
|
|
150
|
+
def execute(self, order: Order, bar: pd.Series) -> Optional[Fill]:
|
|
151
|
+
pass
|
|
152
|
+
|
|
153
|
+
class SimpleExecutionModel(ExecutionModel):
|
|
154
|
+
def __init__(self, slippage_bps: float = 10, commission_per_share: float = 0.01):
|
|
155
|
+
self.slippage_bps = slippage_bps
|
|
156
|
+
self.commission_per_share = commission_per_share
|
|
157
|
+
|
|
158
|
+
def execute(self, order: Order, bar: pd.Series) -> Optional[Fill]:
|
|
159
|
+
if order.order_type == OrderType.MARKET:
|
|
160
|
+
base_price = Decimal(str(bar["open"]))
|
|
161
|
+
|
|
162
|
+
# Apply slippage
|
|
163
|
+
slippage_mult = 1 + (self.slippage_bps / 10000)
|
|
164
|
+
if order.side == OrderSide.BUY:
|
|
165
|
+
fill_price = base_price * Decimal(str(slippage_mult))
|
|
166
|
+
else:
|
|
167
|
+
fill_price = base_price / Decimal(str(slippage_mult))
|
|
168
|
+
|
|
169
|
+
commission = order.quantity * Decimal(str(self.commission_per_share))
|
|
170
|
+
slippage = abs(fill_price - base_price) * order.quantity
|
|
171
|
+
|
|
172
|
+
return Fill(
|
|
173
|
+
order=order,
|
|
174
|
+
fill_price=fill_price,
|
|
175
|
+
fill_quantity=order.quantity,
|
|
176
|
+
commission=commission,
|
|
177
|
+
slippage=slippage,
|
|
178
|
+
timestamp=bar.name
|
|
179
|
+
)
|
|
180
|
+
return None
|
|
181
|
+
|
|
182
|
+
class Backtester:
|
|
183
|
+
def __init__(
|
|
184
|
+
self,
|
|
185
|
+
strategy: Strategy,
|
|
186
|
+
execution_model: ExecutionModel,
|
|
187
|
+
initial_capital: Decimal = Decimal("100000")
|
|
188
|
+
):
|
|
189
|
+
self.strategy = strategy
|
|
190
|
+
self.execution_model = execution_model
|
|
191
|
+
self.portfolio = Portfolio(cash=initial_capital)
|
|
192
|
+
self.equity_curve: List[tuple] = []
|
|
193
|
+
self.trades: List[Fill] = []
|
|
194
|
+
|
|
195
|
+
def run(self, data: pd.DataFrame) -> pd.DataFrame:
|
|
196
|
+
"""Run backtest on OHLCV data with DatetimeIndex."""
|
|
197
|
+
pending_orders: List[Order] = []
|
|
198
|
+
|
|
199
|
+
for timestamp, bar in data.iterrows():
|
|
200
|
+
# Execute pending orders at today's prices
|
|
201
|
+
for order in pending_orders:
|
|
202
|
+
fill = self.execution_model.execute(order, bar)
|
|
203
|
+
if fill:
|
|
204
|
+
self.portfolio.process_fill(fill)
|
|
205
|
+
self.strategy.on_fill(fill)
|
|
206
|
+
self.trades.append(fill)
|
|
207
|
+
|
|
208
|
+
pending_orders.clear()
|
|
209
|
+
|
|
210
|
+
# Get current prices for equity calculation
|
|
211
|
+
prices = {data.index.name or "default": Decimal(str(bar["close"]))}
|
|
212
|
+
equity = self.portfolio.get_equity(prices)
|
|
213
|
+
self.equity_curve.append((timestamp, float(equity)))
|
|
214
|
+
|
|
215
|
+
# Generate new orders for next bar
|
|
216
|
+
new_orders = self.strategy.on_bar(timestamp, data.loc[:timestamp])
|
|
217
|
+
pending_orders.extend(new_orders)
|
|
218
|
+
|
|
219
|
+
return self._create_results()
|
|
220
|
+
|
|
221
|
+
def _create_results(self) -> pd.DataFrame:
|
|
222
|
+
equity_df = pd.DataFrame(self.equity_curve, columns=["timestamp", "equity"])
|
|
223
|
+
equity_df.set_index("timestamp", inplace=True)
|
|
224
|
+
equity_df["returns"] = equity_df["equity"].pct_change()
|
|
225
|
+
return equity_df
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### Pattern 2: Vectorized Backtester (Fast)
|
|
229
|
+
|
|
230
|
+
```python
|
|
231
|
+
import pandas as pd
|
|
232
|
+
import numpy as np
|
|
233
|
+
from typing import Callable, Dict, Any
|
|
234
|
+
|
|
235
|
+
class VectorizedBacktester:
|
|
236
|
+
"""Fast vectorized backtester for simple strategies."""
|
|
237
|
+
|
|
238
|
+
def __init__(
|
|
239
|
+
self,
|
|
240
|
+
initial_capital: float = 100000,
|
|
241
|
+
commission: float = 0.001, # 0.1%
|
|
242
|
+
slippage: float = 0.0005 # 0.05%
|
|
243
|
+
):
|
|
244
|
+
self.initial_capital = initial_capital
|
|
245
|
+
self.commission = commission
|
|
246
|
+
self.slippage = slippage
|
|
247
|
+
|
|
248
|
+
def run(
|
|
249
|
+
self,
|
|
250
|
+
prices: pd.DataFrame,
|
|
251
|
+
signal_func: Callable[[pd.DataFrame], pd.Series]
|
|
252
|
+
) -> Dict[str, Any]:
|
|
253
|
+
"""
|
|
254
|
+
Run backtest with signal function.
|
|
255
|
+
|
|
256
|
+
Args:
|
|
257
|
+
prices: DataFrame with 'close' column
|
|
258
|
+
signal_func: Function that returns position signals (-1, 0, 1)
|
|
259
|
+
|
|
260
|
+
Returns:
|
|
261
|
+
Dictionary with results
|
|
262
|
+
"""
|
|
263
|
+
# Generate signals (shifted to avoid look-ahead)
|
|
264
|
+
signals = signal_func(prices).shift(1).fillna(0)
|
|
265
|
+
|
|
266
|
+
# Calculate returns
|
|
267
|
+
returns = prices["close"].pct_change()
|
|
268
|
+
|
|
269
|
+
# Calculate strategy returns with costs
|
|
270
|
+
position_changes = signals.diff().abs()
|
|
271
|
+
trading_costs = position_changes * (self.commission + self.slippage)
|
|
272
|
+
|
|
273
|
+
strategy_returns = signals * returns - trading_costs
|
|
274
|
+
|
|
275
|
+
# Build equity curve
|
|
276
|
+
equity = (1 + strategy_returns).cumprod() * self.initial_capital
|
|
277
|
+
|
|
278
|
+
# Calculate metrics
|
|
279
|
+
results = {
|
|
280
|
+
"equity": equity,
|
|
281
|
+
"returns": strategy_returns,
|
|
282
|
+
"signals": signals,
|
|
283
|
+
"metrics": self._calculate_metrics(strategy_returns, equity)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
return results
|
|
287
|
+
|
|
288
|
+
def _calculate_metrics(
|
|
289
|
+
self,
|
|
290
|
+
returns: pd.Series,
|
|
291
|
+
equity: pd.Series
|
|
292
|
+
) -> Dict[str, float]:
|
|
293
|
+
"""Calculate performance metrics."""
|
|
294
|
+
total_return = (equity.iloc[-1] / self.initial_capital) - 1
|
|
295
|
+
annual_return = (1 + total_return) ** (252 / len(returns)) - 1
|
|
296
|
+
annual_vol = returns.std() * np.sqrt(252)
|
|
297
|
+
sharpe = annual_return / annual_vol if annual_vol > 0 else 0
|
|
298
|
+
|
|
299
|
+
# Drawdown
|
|
300
|
+
rolling_max = equity.cummax()
|
|
301
|
+
drawdown = (equity - rolling_max) / rolling_max
|
|
302
|
+
max_drawdown = drawdown.min()
|
|
303
|
+
|
|
304
|
+
# Win rate
|
|
305
|
+
winning_days = (returns > 0).sum()
|
|
306
|
+
total_days = (returns != 0).sum()
|
|
307
|
+
win_rate = winning_days / total_days if total_days > 0 else 0
|
|
308
|
+
|
|
309
|
+
return {
|
|
310
|
+
"total_return": total_return,
|
|
311
|
+
"annual_return": annual_return,
|
|
312
|
+
"annual_volatility": annual_vol,
|
|
313
|
+
"sharpe_ratio": sharpe,
|
|
314
|
+
"max_drawdown": max_drawdown,
|
|
315
|
+
"win_rate": win_rate,
|
|
316
|
+
"num_trades": int((returns != 0).sum())
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
# Example usage
|
|
320
|
+
def momentum_signal(prices: pd.DataFrame, lookback: int = 20) -> pd.Series:
|
|
321
|
+
"""Simple momentum strategy: long when price > SMA, else flat."""
|
|
322
|
+
sma = prices["close"].rolling(lookback).mean()
|
|
323
|
+
return (prices["close"] > sma).astype(int)
|
|
324
|
+
|
|
325
|
+
# Run backtest
|
|
326
|
+
# backtester = VectorizedBacktester()
|
|
327
|
+
# results = backtester.run(price_data, lambda p: momentum_signal(p, 50))
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Pattern 3: Walk-Forward Optimization
|
|
331
|
+
|
|
332
|
+
```python
|
|
333
|
+
from typing import Callable, Dict, List, Tuple, Any
|
|
334
|
+
import pandas as pd
|
|
335
|
+
import numpy as np
|
|
336
|
+
from itertools import product
|
|
337
|
+
|
|
338
|
+
class WalkForwardOptimizer:
|
|
339
|
+
"""Walk-forward analysis with anchored or rolling windows."""
|
|
340
|
+
|
|
341
|
+
def __init__(
|
|
342
|
+
self,
|
|
343
|
+
train_period: int,
|
|
344
|
+
test_period: int,
|
|
345
|
+
anchored: bool = False,
|
|
346
|
+
n_splits: int = None
|
|
347
|
+
):
|
|
348
|
+
"""
|
|
349
|
+
Args:
|
|
350
|
+
train_period: Number of bars in training window
|
|
351
|
+
test_period: Number of bars in test window
|
|
352
|
+
anchored: If True, training always starts from beginning
|
|
353
|
+
n_splits: Number of train/test splits (auto-calculated if None)
|
|
354
|
+
"""
|
|
355
|
+
self.train_period = train_period
|
|
356
|
+
self.test_period = test_period
|
|
357
|
+
self.anchored = anchored
|
|
358
|
+
self.n_splits = n_splits
|
|
359
|
+
|
|
360
|
+
def generate_splits(
|
|
361
|
+
self,
|
|
362
|
+
data: pd.DataFrame
|
|
363
|
+
) -> List[Tuple[pd.DataFrame, pd.DataFrame]]:
|
|
364
|
+
"""Generate train/test splits."""
|
|
365
|
+
splits = []
|
|
366
|
+
n = len(data)
|
|
367
|
+
|
|
368
|
+
if self.n_splits:
|
|
369
|
+
step = (n - self.train_period) // self.n_splits
|
|
370
|
+
else:
|
|
371
|
+
step = self.test_period
|
|
372
|
+
|
|
373
|
+
start = 0
|
|
374
|
+
while start + self.train_period + self.test_period <= n:
|
|
375
|
+
if self.anchored:
|
|
376
|
+
train_start = 0
|
|
377
|
+
else:
|
|
378
|
+
train_start = start
|
|
379
|
+
|
|
380
|
+
train_end = start + self.train_period
|
|
381
|
+
test_end = min(train_end + self.test_period, n)
|
|
382
|
+
|
|
383
|
+
train_data = data.iloc[train_start:train_end]
|
|
384
|
+
test_data = data.iloc[train_end:test_end]
|
|
385
|
+
|
|
386
|
+
splits.append((train_data, test_data))
|
|
387
|
+
start += step
|
|
388
|
+
|
|
389
|
+
return splits
|
|
390
|
+
|
|
391
|
+
def optimize(
|
|
392
|
+
self,
|
|
393
|
+
data: pd.DataFrame,
|
|
394
|
+
strategy_func: Callable,
|
|
395
|
+
param_grid: Dict[str, List],
|
|
396
|
+
metric: str = "sharpe_ratio"
|
|
397
|
+
) -> Dict[str, Any]:
|
|
398
|
+
"""
|
|
399
|
+
Run walk-forward optimization.
|
|
400
|
+
|
|
401
|
+
Args:
|
|
402
|
+
data: Full dataset
|
|
403
|
+
strategy_func: Function(data, **params) -> results dict
|
|
404
|
+
param_grid: Parameter combinations to test
|
|
405
|
+
metric: Metric to optimize
|
|
406
|
+
|
|
407
|
+
Returns:
|
|
408
|
+
Combined results from all test periods
|
|
409
|
+
"""
|
|
410
|
+
splits = self.generate_splits(data)
|
|
411
|
+
all_results = []
|
|
412
|
+
optimal_params_history = []
|
|
413
|
+
|
|
414
|
+
for i, (train_data, test_data) in enumerate(splits):
|
|
415
|
+
# Optimize on training data
|
|
416
|
+
best_params, best_metric = self._grid_search(
|
|
417
|
+
train_data, strategy_func, param_grid, metric
|
|
418
|
+
)
|
|
419
|
+
optimal_params_history.append(best_params)
|
|
420
|
+
|
|
421
|
+
# Test with optimal params
|
|
422
|
+
test_results = strategy_func(test_data, **best_params)
|
|
423
|
+
test_results["split"] = i
|
|
424
|
+
test_results["params"] = best_params
|
|
425
|
+
all_results.append(test_results)
|
|
426
|
+
|
|
427
|
+
print(f"Split {i+1}/{len(splits)}: "
|
|
428
|
+
f"Best {metric}={best_metric:.4f}, params={best_params}")
|
|
429
|
+
|
|
430
|
+
return {
|
|
431
|
+
"split_results": all_results,
|
|
432
|
+
"param_history": optimal_params_history,
|
|
433
|
+
"combined_equity": self._combine_equity_curves(all_results)
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
def _grid_search(
|
|
437
|
+
self,
|
|
438
|
+
data: pd.DataFrame,
|
|
439
|
+
strategy_func: Callable,
|
|
440
|
+
param_grid: Dict[str, List],
|
|
441
|
+
metric: str
|
|
442
|
+
) -> Tuple[Dict, float]:
|
|
443
|
+
"""Grid search for best parameters."""
|
|
444
|
+
best_params = None
|
|
445
|
+
best_metric = -np.inf
|
|
446
|
+
|
|
447
|
+
# Generate all parameter combinations
|
|
448
|
+
param_names = list(param_grid.keys())
|
|
449
|
+
param_values = list(param_grid.values())
|
|
450
|
+
|
|
451
|
+
for values in product(*param_values):
|
|
452
|
+
params = dict(zip(param_names, values))
|
|
453
|
+
results = strategy_func(data, **params)
|
|
454
|
+
|
|
455
|
+
if results["metrics"][metric] > best_metric:
|
|
456
|
+
best_metric = results["metrics"][metric]
|
|
457
|
+
best_params = params
|
|
458
|
+
|
|
459
|
+
return best_params, best_metric
|
|
460
|
+
|
|
461
|
+
def _combine_equity_curves(
|
|
462
|
+
self,
|
|
463
|
+
results: List[Dict]
|
|
464
|
+
) -> pd.Series:
|
|
465
|
+
"""Combine equity curves from all test periods."""
|
|
466
|
+
combined = pd.concat([r["equity"] for r in results])
|
|
467
|
+
return combined
|
|
468
|
+
```
|
|
469
|
+
|
|
470
|
+
### Pattern 4: Monte Carlo Analysis
|
|
471
|
+
|
|
472
|
+
```python
|
|
473
|
+
import numpy as np
|
|
474
|
+
import pandas as pd
|
|
475
|
+
from typing import Dict, List
|
|
476
|
+
|
|
477
|
+
class MonteCarloAnalyzer:
|
|
478
|
+
"""Monte Carlo simulation for strategy robustness."""
|
|
479
|
+
|
|
480
|
+
def __init__(self, n_simulations: int = 1000, confidence: float = 0.95):
|
|
481
|
+
self.n_simulations = n_simulations
|
|
482
|
+
self.confidence = confidence
|
|
483
|
+
|
|
484
|
+
def bootstrap_returns(
|
|
485
|
+
self,
|
|
486
|
+
returns: pd.Series,
|
|
487
|
+
n_periods: int = None
|
|
488
|
+
) -> np.ndarray:
|
|
489
|
+
"""
|
|
490
|
+
Bootstrap simulation by resampling returns.
|
|
491
|
+
|
|
492
|
+
Args:
|
|
493
|
+
returns: Historical returns series
|
|
494
|
+
n_periods: Length of each simulation (default: same as input)
|
|
495
|
+
|
|
496
|
+
Returns:
|
|
497
|
+
Array of shape (n_simulations, n_periods)
|
|
498
|
+
"""
|
|
499
|
+
if n_periods is None:
|
|
500
|
+
n_periods = len(returns)
|
|
501
|
+
|
|
502
|
+
simulations = np.zeros((self.n_simulations, n_periods))
|
|
503
|
+
|
|
504
|
+
for i in range(self.n_simulations):
|
|
505
|
+
# Resample with replacement
|
|
506
|
+
simulated_returns = np.random.choice(
|
|
507
|
+
returns.values,
|
|
508
|
+
size=n_periods,
|
|
509
|
+
replace=True
|
|
510
|
+
)
|
|
511
|
+
simulations[i] = simulated_returns
|
|
512
|
+
|
|
513
|
+
return simulations
|
|
514
|
+
|
|
515
|
+
def analyze_drawdowns(
|
|
516
|
+
self,
|
|
517
|
+
returns: pd.Series
|
|
518
|
+
) -> Dict[str, float]:
|
|
519
|
+
"""Analyze drawdown distribution via simulation."""
|
|
520
|
+
simulations = self.bootstrap_returns(returns)
|
|
521
|
+
|
|
522
|
+
max_drawdowns = []
|
|
523
|
+
for sim_returns in simulations:
|
|
524
|
+
equity = (1 + sim_returns).cumprod()
|
|
525
|
+
rolling_max = np.maximum.accumulate(equity)
|
|
526
|
+
drawdowns = (equity - rolling_max) / rolling_max
|
|
527
|
+
max_drawdowns.append(drawdowns.min())
|
|
528
|
+
|
|
529
|
+
max_drawdowns = np.array(max_drawdowns)
|
|
530
|
+
|
|
531
|
+
return {
|
|
532
|
+
"expected_max_dd": np.mean(max_drawdowns),
|
|
533
|
+
"median_max_dd": np.median(max_drawdowns),
|
|
534
|
+
f"worst_{int(self.confidence*100)}pct": np.percentile(
|
|
535
|
+
max_drawdowns, (1 - self.confidence) * 100
|
|
536
|
+
),
|
|
537
|
+
"worst_case": max_drawdowns.min()
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
def probability_of_loss(
|
|
541
|
+
self,
|
|
542
|
+
returns: pd.Series,
|
|
543
|
+
holding_periods: List[int] = [21, 63, 126, 252]
|
|
544
|
+
) -> Dict[int, float]:
|
|
545
|
+
"""Calculate probability of loss over various holding periods."""
|
|
546
|
+
results = {}
|
|
547
|
+
|
|
548
|
+
for period in holding_periods:
|
|
549
|
+
if period > len(returns):
|
|
550
|
+
continue
|
|
551
|
+
|
|
552
|
+
simulations = self.bootstrap_returns(returns, period)
|
|
553
|
+
total_returns = (1 + simulations).prod(axis=1) - 1
|
|
554
|
+
prob_loss = (total_returns < 0).mean()
|
|
555
|
+
results[period] = prob_loss
|
|
556
|
+
|
|
557
|
+
return results
|
|
558
|
+
|
|
559
|
+
def confidence_interval(
|
|
560
|
+
self,
|
|
561
|
+
returns: pd.Series,
|
|
562
|
+
periods: int = 252
|
|
563
|
+
) -> Dict[str, float]:
|
|
564
|
+
"""Calculate confidence interval for future returns."""
|
|
565
|
+
simulations = self.bootstrap_returns(returns, periods)
|
|
566
|
+
total_returns = (1 + simulations).prod(axis=1) - 1
|
|
567
|
+
|
|
568
|
+
lower = (1 - self.confidence) / 2
|
|
569
|
+
upper = 1 - lower
|
|
570
|
+
|
|
571
|
+
return {
|
|
572
|
+
"expected": total_returns.mean(),
|
|
573
|
+
"lower_bound": np.percentile(total_returns, lower * 100),
|
|
574
|
+
"upper_bound": np.percentile(total_returns, upper * 100),
|
|
575
|
+
"std": total_returns.std()
|
|
576
|
+
}
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
## Performance Metrics
|
|
580
|
+
|
|
581
|
+
```python
|
|
582
|
+
def calculate_metrics(returns: pd.Series, rf_rate: float = 0.02) -> Dict[str, float]:
|
|
583
|
+
"""Calculate comprehensive performance metrics."""
|
|
584
|
+
# Annualization factor (assuming daily returns)
|
|
585
|
+
ann_factor = 252
|
|
586
|
+
|
|
587
|
+
# Basic metrics
|
|
588
|
+
total_return = (1 + returns).prod() - 1
|
|
589
|
+
annual_return = (1 + total_return) ** (ann_factor / len(returns)) - 1
|
|
590
|
+
annual_vol = returns.std() * np.sqrt(ann_factor)
|
|
591
|
+
|
|
592
|
+
# Risk-adjusted returns
|
|
593
|
+
sharpe = (annual_return - rf_rate) / annual_vol if annual_vol > 0 else 0
|
|
594
|
+
|
|
595
|
+
# Sortino (downside deviation)
|
|
596
|
+
downside_returns = returns[returns < 0]
|
|
597
|
+
downside_vol = downside_returns.std() * np.sqrt(ann_factor)
|
|
598
|
+
sortino = (annual_return - rf_rate) / downside_vol if downside_vol > 0 else 0
|
|
599
|
+
|
|
600
|
+
# Calmar ratio
|
|
601
|
+
equity = (1 + returns).cumprod()
|
|
602
|
+
rolling_max = equity.cummax()
|
|
603
|
+
drawdowns = (equity - rolling_max) / rolling_max
|
|
604
|
+
max_drawdown = drawdowns.min()
|
|
605
|
+
calmar = annual_return / abs(max_drawdown) if max_drawdown != 0 else 0
|
|
606
|
+
|
|
607
|
+
# Win rate and profit factor
|
|
608
|
+
wins = returns[returns > 0]
|
|
609
|
+
losses = returns[returns < 0]
|
|
610
|
+
win_rate = len(wins) / len(returns[returns != 0]) if len(returns[returns != 0]) > 0 else 0
|
|
611
|
+
profit_factor = wins.sum() / abs(losses.sum()) if losses.sum() != 0 else np.inf
|
|
612
|
+
|
|
613
|
+
return {
|
|
614
|
+
"total_return": total_return,
|
|
615
|
+
"annual_return": annual_return,
|
|
616
|
+
"annual_volatility": annual_vol,
|
|
617
|
+
"sharpe_ratio": sharpe,
|
|
618
|
+
"sortino_ratio": sortino,
|
|
619
|
+
"calmar_ratio": calmar,
|
|
620
|
+
"max_drawdown": max_drawdown,
|
|
621
|
+
"win_rate": win_rate,
|
|
622
|
+
"profit_factor": profit_factor,
|
|
623
|
+
"num_trades": int((returns != 0).sum())
|
|
624
|
+
}
|
|
625
|
+
```
|
|
626
|
+
|
|
627
|
+
## Best Practices
|
|
628
|
+
|
|
629
|
+
### Do's
|
|
630
|
+
- **Use point-in-time data** - Avoid look-ahead bias
|
|
631
|
+
- **Include transaction costs** - Realistic estimates
|
|
632
|
+
- **Test out-of-sample** - Always reserve data
|
|
633
|
+
- **Use walk-forward** - Not just train/test
|
|
634
|
+
- **Monte Carlo analysis** - Understand uncertainty
|
|
635
|
+
|
|
636
|
+
### Don'ts
|
|
637
|
+
- **Don't overfit** - Limit parameters
|
|
638
|
+
- **Don't ignore survivorship** - Include delisted
|
|
639
|
+
- **Don't use adjusted data carelessly** - Understand adjustments
|
|
640
|
+
- **Don't optimize on full history** - Reserve test set
|
|
641
|
+
- **Don't ignore capacity** - Market impact matters
|
|
642
|
+
|
|
643
|
+
## Resources
|
|
644
|
+
|
|
645
|
+
- [Advances in Financial Machine Learning (Marcos López de Prado)](https://www.amazon.com/Advances-Financial-Machine-Learning-Marcos/dp/1119482089)
|
|
646
|
+
- [Quantitative Trading (Ernest Chan)](https://www.amazon.com/Quantitative-Trading-Build-Algorithmic-Business/dp/1119800064)
|
|
647
|
+
- [Backtrader Documentation](https://www.backtrader.com/docu/)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bash-defensive-patterns
|
|
3
|
+
description: Master defensive Bash programming techniques for production-grade scripts. Use when writing robust shell scripts, CI/CD pipelines, or system utilities requiring fault tolerance and safety.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Bash Defensive Patterns
|
|
7
|
+
|
|
8
|
+
Comprehensive guidance for writing production-ready Bash scripts using defensive programming techniques, error handling, and safety best practices to prevent common pitfalls and ensure reliability.
|
|
9
|
+
|
|
10
|
+
## Use this skill when
|
|
11
|
+
|
|
12
|
+
- Writing production automation scripts
|
|
13
|
+
- Building CI/CD pipeline scripts
|
|
14
|
+
- Creating system administration utilities
|
|
15
|
+
- Developing error-resilient deployment automation
|
|
16
|
+
- Writing scripts that must handle edge cases safely
|
|
17
|
+
- Building maintainable shell script libraries
|
|
18
|
+
- Implementing comprehensive logging and monitoring
|
|
19
|
+
- Creating scripts that must work across different platforms
|
|
20
|
+
|
|
21
|
+
## Do not use this skill when
|
|
22
|
+
|
|
23
|
+
- You need a single ad-hoc shell command, not a script
|
|
24
|
+
- The target environment requires strict POSIX sh only
|
|
25
|
+
- The task is unrelated to shell scripting or automation
|
|
26
|
+
|
|
27
|
+
## Instructions
|
|
28
|
+
|
|
29
|
+
1. Confirm the target shell, OS, and execution environment.
|
|
30
|
+
2. Enable strict mode and safe defaults from the start.
|
|
31
|
+
3. Validate inputs, quote variables, and handle files safely.
|
|
32
|
+
4. Add logging, error traps, and basic tests.
|
|
33
|
+
|
|
34
|
+
## Safety
|
|
35
|
+
|
|
36
|
+
- Avoid destructive commands without confirmation or dry-run flags.
|
|
37
|
+
- Do not run scripts as root unless strictly required.
|
|
38
|
+
|
|
39
|
+
Refer to `resources/implementation-playbook.md` for detailed patterns, checklists, and templates.
|
|
40
|
+
|
|
41
|
+
## Resources
|
|
42
|
+
|
|
43
|
+
- `resources/implementation-playbook.md` for detailed patterns, checklists, and templates.
|