xingwudao/open-xquant/create-portfolio-optimizer
Claude Code and agent skill by xingwudao/open-xquant
- community
Checking that the SKILL.md file is still in the repository.
Create a new open-xquant PortfolioOptimizer with weight-invariant tests and registry wiring; use after create-component confirms no existing optimizer satisfies the allocation request.
Install
npx vskill@latest install xingwudao/open-xquant/create-portfolio-optimizerSKILL.md
Create PortfolioOptimizer
You create allocation logic that returns target weights.
Scope
Default built-in paths:
- source:
src/oxq/portfolio/{snake_name}.py - tests:
tests/portfolio/test_{snake_name}.py - package export:
src/oxq/portfolio/__init__.py - built-in registry:
src/oxq/core/registry.py
Existing built-ins live in src/oxq/portfolio/optimizers.py; read that file before choosing whether to add a new module or extend the existing built-in module. Prefer a new module for a new component unless project maintainers ask otherwise.
Phase 1: Read Existing Patterns
Read before editing:
src/oxq/core/types.pysrc/oxq/portfolio/optimizers.py- one existing test in
tests/portfolio/ src/oxq/portfolio/__init__.py- the portfolio registration block in
src/oxq/core/registry.py
Phase 2: Define Behavior
State before coding:
- allocation formula
- constructor parameters
- whether it reads
signals,indicators, or both - required indicator columns
- fallback when no valid inputs exist
- whether weights can include
CASH - max/min weight constraints
- whether the optimizer is stateful. If it consumes categorical signals such as
BUY, SELL, and HOLD, define how HOLD preserves or resets prior target weights. SignalToPosition is the built-in reference pattern.
Ask the user if allocation logic is ambiguous.
Phase 3: Test First
Write tests with deterministic DataFrames:
- protocol compliance with
PortfolioOptimizer - empty input returns
{"CASH": 1.0} - weights sum to
1.0 - multi-symbol behavior
- hand-calculated allocation
- invalid or NaN input behavior
namevalue
Run the new test and confirm the missing implementation fails before coding.
Phase 4: Implement
Skeleton:
Rules:
- every path returns a non-empty dict
- invalid input returns
{"CASH": 1.0} - weights must sum to
1.0 - include
CASHfor unused capital - do not mutate input DataFrames
- use only latest available row unless design says otherwise
Phase 5: Register
For a built-in component:
- import it in
src/oxq/portfolio/__init__.py - add it to
__all__ - add it to
_load_builtins()insrc/oxq/core/registry.py
Verify:
Run engine-level tests when optimizer behavior changes order generation.
Red Lines
- Do not return weights that sum above or below
1.0. - Do not return an empty dict.
- Do not ignore invalid data silently; fall back to
CASHor exclude the
symbol deliberately.
- Do not register before invariant tests pass.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingagent/skills/create-portfolio-optimizer/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/xingwudao/open-xquant/create-portfolio-optimizer)