xtraderClient/docs/api/constants.md
2026-02-14 18:59:36 +08:00

45 lines
968 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# constants.ts
**路径**`src/api/constants.ts`
## 功能用途
交易相关常量订单类型OrderType、交易方向Side用于 market 接口入参。
## 常量说明
### OrderType
| 值 | 常量 | 说明 |
|----|------|------|
| 0 | GTC | Good Till Cancelled一直有效直到取消 |
| 1 | GTD | Good Till Date指定时间内有效 |
| 2 | FOK | Fill Or Kill全部成交或立即取消 |
| 3 | FAK | Fill And Kill (IOC),立即成交,剩余取消 |
| 4 | Market | 市价单 |
### Side
| 值 | 常量 | 说明 |
|----|------|------|
| 1 | Buy | 买入 |
| 2 | Sell | 卖出 |
## 使用方式
```typescript
import { OrderType, Side } from '@/api/constants'
// 下单时
await pmOrderPlace({
orderType: OrderType.GTC,
side: Side.Buy,
// ...
})
```
## 扩展方式
1. **新增订单类型**:在 `OrderType` 中增加,并同步后端定义
2. **业务枚举**:可在此文件或新建 `enums.ts` 中集中管理