| name | add-strategy |
| description | Adds a new trading strategy across 5 locations (mod.rs, routes, backtest, SDUI schema, frontend). Use when implementing a new strategy. |
| disable-model-invocation | true |
| user-invocable | true |
| argument-hint | <์ ๋ต๋ช
_snake_case> [์ ๋ต ์ค๋ช
] |
| allowed-tools | Read, Grep, Edit, Write, Bash(cargo *) |
| context | fork |
| agent | rust-impl |
์ ๋ต ์ถ๊ฐ ์ํฌํ๋ก์ฐ
์ ์ ๋ต $ARGUMENTS[0]์ ์ถ๊ฐํฉ๋๋ค.
โ ๏ธ ๋ฐ๋์ 5๊ณณ์ ๋ชจ๋ ์์ ํด์ผ ํฉ๋๋ค. ํ๋๋ผ๋ ๋น ์ง๋ฉด ๋ฐํ์ ์๋ฌ๊ฐ ๋ฐ์ํฉ๋๋ค.
0๋จ๊ณ: ๊ธฐ์กด ์ ๋ต ์ฐธ์กฐ
๋จผ์ ๊ฐ์ฅ ์ ์ฌํ ๊ธฐ์กด ์ ๋ต์ ์ฐธ๊ณ ์๋ฃ๋ก ์ฝ์ต๋๋ค:
ls crates/trader-strategy/src/strategies/
์ถ์ฒ ์ฐธ์กฐ ์ ๋ต: rsi.rs (๊ฐ์ฅ ๊ธฐ๋ณธ์ ์ธ ๊ตฌ์กฐ)
1๋จ๊ณ: ์ ๋ต ๊ตฌํ ํ์ผ ์์ฑ
์์น: crates/trader-strategy/src/strategies/$ARGUMENTS[0].rs
ํ์ ๊ตฌํ ์ฌํญ
use crate::traits::Strategy;
use trader_core::domain::{
context::StrategyContext,
signal::Signal,
};
use rust_decimal::Decimal;
pub struct YourStrategy {
}
impl Strategy for YourStrategy {
fn name(&self) -> &str { "your_strategy" }
fn on_market_data(
&mut self,
ctx: &StrategyContext,
) -> Vec<Signal> {
vec![]
}
}
์ฒดํฌํฌ์ธํธ
2๋จ๊ณ: ๋ชจ๋ ๋ฑ๋ก
์์น: crates/trader-strategy/src/strategies/mod.rs
pub mod $ARGUMENTS[0];
pub use $ARGUMENTS[0]::*;
3๋จ๊ณ: API ๋ผ์ฐํธ ์ฐ๋
์์น: crates/trader-api/src/routes/strategies.rs
3๊ณณ์ ์์ ํฉ๋๋ค:
create_strategy_instance() โ match ๋ถ๊ธฐ์ ์ ๋ต ์ถ๊ฐ
get_strategy_default_name() โ ํ๊ธ ์ด๋ฆ ๋ฐํ
get_strategy_default_timeframe() โ ๊ธฐ๋ณธ ํ์ํ๋ ์
get_strategy_default_symbols() โ ๊ถ์ฅ ์ฌ๋ณผ ๋ชฉ๋ก
4๋จ๊ณ: ๋ฐฑํ
์คํธ ์์ง ์ฐ๋
์์น: crates/trader-api/src/routes/backtest/engine.rs
- import ์ถ๊ฐ
run_strategy_backtest() ๋๋ run_multi_strategy_backtest() match ๋ถ๊ธฐ์ ์ถ๊ฐ
5๋จ๊ณ: UI ์คํค๋ง ๋ฐ ํ๋ก ํธ์๋
5-1. SDUI ์คํค๋ง
์์น: config/sdui/strategy_schemas.json
strategies ๊ฐ์ฒด์ ์ ๋ต ์คํค๋ง ์ถ๊ฐ (~50์ค):
- ์ ๋ต ํ๋ผ๋ฏธํฐ๋ณ UI ์ปดํฌ๋ํธ ์ ์
type, min, max, default, step ๋ฑ
5-2. ํ๋ก ํธ์๋ ํ์ํ๋ ์
์์น: frontend/src/pages/Strategies.tsx
getDefaultTimeframe() switch ๋ฌธ์ case ์ถ๊ฐ
6๋จ๊ณ: ๊ฒ์ฆ
# 1. ์ปดํ์ผ ํ์ธ
cargo check -p trader-strategy
cargo check -p trader-api
# 2. ํ
์คํธ ์คํ
cargo test -p trader-strategy -- $ARGUMENTS[0]
# 3. Clippy
cargo clippy -p trader-strategy -p trader-api -- -D warnings
๊ฒ์ฆ ์คํจ ์
- ์๋ฌ ๋ฉ์์ง์์ ํ์ผ/๋ผ์ธ ํ์ธ
- ํด๋น ํ์ผ ์์
- ๊ฒ์ฆ ๋ช
๋ น ์ฌ์คํ โ ํต๊ณผํ ๋๊น์ง ๋ฐ๋ณต
๋ชจ๋ ๊ฒ์ฆ ํต๊ณผ ํ ์ฌ์ฉ์์๊ฒ ๊ฒฐ๊ณผ๋ฅผ ๋ณด๊ณ ํฉ๋๋ค.