固定六个交易品种并修正 1/5/9 月合约轮换规则

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
fish
2026-05-03 16:09:50 +08:00
parent a1355d91aa
commit dc22799985
2 changed files with 49 additions and 6 deletions

View File

@@ -6,6 +6,9 @@ from typing import Optional
# exchange: tushare 合约后缀(交易所) # exchange: tushare 合约后缀(交易所)
# active: 当月 -> (主力合约月, 年份偏移) # active: 当月 -> (主力合约月, 年份偏移)
# 例 FG 12 月用次年 5 月,故 12 -> (5, 1) # 例 FG 12 月用次年 5 月,故 12 -> (5, 1)
# 允许前端选择的品种列表
SYMBOLS = ["FG", "SA", "RB", "MA", "CF", "M"]
ROLLOVER_RULES: dict[str, dict] = { ROLLOVER_RULES: dict[str, dict] = {
"FG": { "FG": {
"exchange": "ZCE", "exchange": "ZCE",
@@ -16,6 +19,46 @@ ROLLOVER_RULES: dict[str, dict] = {
12: (5, 1), 12: (5, 1),
}, },
}, },
"SA": {
"exchange": "ZCE",
"active": {
1: (5, 0), 2: (5, 0), 3: (5, 0), 4: (5, 0),
5: (9, 0), 6: (9, 0), 7: (9, 0), 8: (9, 0),
9: (1, 1), 10: (1, 1), 11: (1, 1), 12: (1, 1),
},
},
"MA": {
"exchange": "ZCE",
"active": {
1: (5, 0), 2: (5, 0), 3: (5, 0), 4: (5, 0),
5: (9, 0), 6: (9, 0), 7: (9, 0), 8: (9, 0),
9: (1, 1), 10: (1, 1), 11: (1, 1), 12: (1, 1),
},
},
"CF": {
"exchange": "ZCE",
"active": {
1: (5, 0), 2: (5, 0), 3: (5, 0), 4: (5, 0),
5: (9, 0), 6: (9, 0), 7: (9, 0), 8: (9, 0),
9: (1, 1), 10: (1, 1), 11: (1, 1), 12: (1, 1),
},
},
"RB": {
"exchange": "SHF",
"active": {
1: (10, 0), 2: (10, 0), 3: (10, 0), 4: (10, 0), 5: (10, 0),
6: (1, 1), 7: (1, 1), 8: (1, 1), 9: (1, 1),
10: (5, 1), 11: (5, 1), 12: (5, 1),
},
},
"M": {
"exchange": "DCE",
"active": {
1: (5, 0), 2: (5, 0), 3: (5, 0), 4: (5, 0), 5: (5, 0),
6: (9, 0), 7: (9, 0), 8: (9, 0),
9: (1, 1), 10: (1, 1), 11: (1, 1), 12: (1, 1),
},
},
} }

View File

@@ -4,6 +4,8 @@ import { ElMessage } from 'element-plus'
import { listContracts } from '@/api/scores' import { listContracts } from '@/api/scores'
import { runPipeline, type RunResponse } from '@/api/run' import { runPipeline, type RunResponse } from '@/api/run'
const SYMBOLS = ['FG', 'SA', 'RB', 'MA', 'CF', 'M']
const form = reactive<{ const form = reactive<{
ts_code: string ts_code: string
symbol: string symbol: string
@@ -83,12 +85,10 @@ onMounted(async () => {
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="品种代号"> <el-form-item label="品种">
<el-input <el-select v-model="form.symbol" style="width: 100%">
v-model="form.symbol" <el-option v-for="s in SYMBOLS" :key="s" :label="s" :value="s" />
placeholder="未选合约时按此品种选主力,如 FG" </el-select>
clearable
/>
</el-form-item> </el-form-item>
<el-form-item label="打分日期"> <el-form-item label="打分日期">
<el-date-picker <el-date-picker