| name | add-exchange |
| description | Scaffolds a new exchange connector with connector, provider, and trait implementations. Use when integrating a new exchange. |
| disable-model-invocation | true |
| user-invocable | true |
| argument-hint | <๊ฑฐ๋์๋ช
_snake_case> [์์ฅ์ ํ: kr|us|crypto|global] |
| allowed-tools | Read, Grep, Edit, Write, Bash(cargo *) |
| context | fork |
| agent | rust-impl |
๊ฑฐ๋์ ์ปค๋ฅํฐ ์ถ๊ฐ ์ํฌํ๋ก์ฐ
์ ๊ฑฐ๋์ $ARGUMENTS[0]์ ์ถ๊ฐํฉ๋๋ค.
0๋จ๊ณ: ๊ธฐ์กด ๊ฑฐ๋์ ์ฐธ์กฐ
ls crates/trader-exchange/src/connector/
ls crates/trader-exchange/src/provider/
์ถ์ฒ ์ฐธ์กฐ: upbit/ (๊ฐ์ฅ ๊ฐ๊ฒฐํ ๊ตฌ์กฐ)
1๋จ๊ณ: Connector ๊ตฌํ
์์น: crates/trader-exchange/src/connector/$ARGUMENTS[0]/
ํ์ ํ์ผ ๊ตฌ์กฐ
connector/$ARGUMENTS[0]/
โโโ mod.rs # pub ๋ชจ๋ ์ ์ธ
โโโ client.rs # HTTP ํด๋ผ์ด์ธํธ (REST API ํธ์ถ)
โโโ models.rs # API ์์ฒญ/์๋ต ํ์
โโโ websocket.rs # WebSocket ์คํธ๋ฆผ (์ ํ)
client.rs ํ์ ๋ฉ์๋
pub struct ExchangeClient {
base_url: String,
client: reqwest::Client,
}
impl ExchangeClient {
pub async fn get_ticker(&self, symbol: &str) -> Result<TickerResponse>;
pub async fn get_orderbook(&self, symbol: &str) -> Result<OrderbookResponse>;
pub async fn get_candles(&self, symbol: &str, interval: &str) -> Result<Vec<CandleResponse>>;
pub async fn place_order(&self, order: &OrderRequest) -> Result<OrderResponse>;
pub async fn cancel_order(&self, order_id: &str) -> Result<()>;
pub async fn get_balance(&self) -> Result<BalanceResponse>;
}
์ฒดํฌํฌ์ธํธ
2๋จ๊ณ: Provider ๊ตฌํ
์์น: crates/trader-exchange/src/provider/$ARGUMENTS[0].rs
use crate::traits::{ExchangeProvider, OrderExecutionProvider};
pub struct ExchangeProviderImpl { }
impl ExchangeProvider for ExchangeProviderImpl {
async fn get_ticker(&self, symbol: &str) -> Result<Ticker>;
async fn get_orderbook(&self, symbol: &str) -> Result<Orderbook>;
}
impl OrderExecutionProvider for ExchangeProviderImpl {
async fn place_order(&self, order: OrderRequest) -> Result<OrderResult>;
async fn cancel_order(&self, order_id: &str) -> Result<()>;
async fn get_balance(&self) -> Result<Balance>;
}
3๋จ๊ณ: ๋ชจ๋ ๋ฑ๋ก
crates/trader-exchange/src/connector/mod.rs โ pub mod $ARGUMENTS[0];
crates/trader-exchange/src/provider/mod.rs โ pub mod $ARGUMENTS[0];
crates/trader-exchange/src/lib.rs โ ํฉํ ๋ฆฌ ํจ์์ match ๋ถ๊ธฐ ์ถ๊ฐ
4๋จ๊ณ: WebSocket ์คํธ๋ฆผ (์ ํ)
MarketStream trait ๊ตฌํ:
impl MarketStream for ExchangeStream {
async fn subscribe_ticker(&mut self, symbols: &[String]) -> Result<()>;
async fn subscribe_orderbook(&mut self, symbols: &[String]) -> Result<()>;
}
5๋จ๊ณ: API ๋ช
์ธ ๋ฌธ์
์์น: docs/exchange/$ARGUMENTS[0]_openapi_spec.md
/crawl-api-spec ์คํฌ๋ก ์๋ ์์ฑ ๊ฐ๋ฅ
6๋จ๊ณ: ๊ฒ์ฆ
cargo check -p trader-exchange
cargo clippy -p trader-exchange -- -D warnings
cargo test -p trader-exchange -- $ARGUMENTS[0]
๊ฒ์ฆ ์คํจ ์
- ์๋ฌ ๋ฉ์์ง์์ ํ์ผ/๋ผ์ธ ํ์ธ
- ํด๋น ํ์ผ ์์
- ๊ฒ์ฆ ๋ช
๋ น ์ฌ์คํ โ ํต๊ณผํ ๋๊น์ง ๋ฐ๋ณต