This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,525 @@
|
||||
# 下单接口用例数据(数据驱动)
|
||||
# 结构:[参数 dict, 期望 dict],与 @pytest.mark.parametrize("test_input,expected", ...) 按位解包
|
||||
# 正例:限价开仓冻结保证金;负例:各类非法入参 + 余额不足
|
||||
|
||||
creatOrderTrueTestdata:
|
||||
# 全仓-限价-买入开仓
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 0
|
||||
msg: OK
|
||||
# 全仓-限价-卖出开仓
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: ask
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 0
|
||||
msg: OK
|
||||
# 逐仓-限价开仓(冻结走逐仓冻结字段)
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 2
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 0
|
||||
msg: OK
|
||||
# 更低起始保证金率(5 倍杠杆)
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.005'
|
||||
orderSourceType: 1
|
||||
- code: 0
|
||||
msg: OK
|
||||
# ---- 矩阵扩充:全仓/逐仓 × 多空 × 起始保证金率三档(0.005/0.02/0.05) ----
|
||||
# 全仓-卖出-0.005(20 倍杠杆)
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: ask
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.005'
|
||||
orderSourceType: 1
|
||||
- code: 0
|
||||
msg: OK
|
||||
# 全仓-买入-0.02(50 倍杠杆)
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.02'
|
||||
orderSourceType: 1
|
||||
- code: 0
|
||||
msg: OK
|
||||
# 全仓-卖出-0.02
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: ask
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.02'
|
||||
orderSourceType: 1
|
||||
- code: 0
|
||||
msg: OK
|
||||
# 全仓-买入-0.05(20 倍杠杆)
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.05'
|
||||
orderSourceType: 1
|
||||
- code: 0
|
||||
msg: OK
|
||||
# 全仓-卖出-0.05
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: ask
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.05'
|
||||
orderSourceType: 1
|
||||
- code: 0
|
||||
msg: OK
|
||||
# 逐仓-买入-0.005(20 倍杠杆)
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 2
|
||||
marginRate: '0.005'
|
||||
orderSourceType: 1
|
||||
- code: 0
|
||||
msg: OK
|
||||
# 逐仓-卖出-0.005
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: ask
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 2
|
||||
marginRate: '0.005'
|
||||
orderSourceType: 1
|
||||
- code: 0
|
||||
msg: OK
|
||||
# 逐仓-买入-0.02(50 倍杠杆)
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 2
|
||||
marginRate: '0.02'
|
||||
orderSourceType: 1
|
||||
- code: 0
|
||||
msg: OK
|
||||
# 逐仓-卖出-0.02
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: ask
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 2
|
||||
marginRate: '0.02'
|
||||
orderSourceType: 1
|
||||
- code: 0
|
||||
msg: OK
|
||||
# 逐仓-买入-0.05(20 倍杠杆)
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 2
|
||||
marginRate: '0.05'
|
||||
orderSourceType: 1
|
||||
- code: 0
|
||||
msg: OK
|
||||
# 逐仓-卖出-0.05
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: ask
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 2
|
||||
marginRate: '0.05'
|
||||
orderSourceType: 1
|
||||
- code: 0
|
||||
msg: OK
|
||||
|
||||
creatOrderFalseTestdata:
|
||||
# userId 非数值
|
||||
- - userId: ''
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:userId"
|
||||
# userId 特殊字符
|
||||
- - userId: '!@#$'
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:userId"
|
||||
# 用户不存在
|
||||
- - userId: 9999
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 1001
|
||||
msg: 用户不存在
|
||||
# 合约不存在
|
||||
- - userId: 1001
|
||||
contractId: 20
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 1002
|
||||
msg: 合约不存在
|
||||
# side 非法枚举(数值)
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: 111
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:side"
|
||||
# side 非法字符串
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: asdd
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:side"
|
||||
# 价格为空
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: ''
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:price"
|
||||
# 价格非正数
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: -1
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:price"
|
||||
# 价格非数值
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: abc
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:price"
|
||||
# 数量为 0
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 0
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:quantity"
|
||||
# 委托类型非法
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 5
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:orderType"
|
||||
# 保证金模式非法
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 3
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:marginType"
|
||||
# 保证金率超上限(>1)
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '2'
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:marginRate"
|
||||
# 有效期非法
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: SDFSDF
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:timeInForce"
|
||||
# 余额不足(冻结金额超过账户资金)
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 99999999
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 2001
|
||||
msg: 余额不足
|
||||
# 余额不足(市价单路径:起始保证金 + taker 手续费超过账户资金)
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
quantity: 2000000
|
||||
orderType: 2
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 2001
|
||||
msg: 余额不足
|
||||
# ---- 负例扩充 ----
|
||||
# 数量为负数
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: -10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:quantity"
|
||||
# 保证金率为 0
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0'
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:marginRate"
|
||||
# 保证金率非法字符串
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: abc
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:marginRate"
|
||||
# 平仓方向(positionEffect != 1)
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 2
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:positionEffect"
|
||||
# 缺 price 参数(限价单必传)
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
- code: 1003
|
||||
msg: "参数错误:price"
|
||||
# 余额不足边界:冻结额(本金+孰高手续费)恰好略超账户总资金
|
||||
- - userId: 1001
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100001
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '1'
|
||||
orderSourceType: 1
|
||||
- code: 2001
|
||||
msg: 余额不足
|
||||
@@ -0,0 +1,31 @@
|
||||
# 撤单解冻场景用例数据(数据驱动)
|
||||
# 每行一个场景:限价开仓挂单 → 撤单 → 三重校验(响应 / 落库 / 缓存)。
|
||||
# 期望冻结金额由公式层独立计算(formula.frozen_margin),不抄被测系统返回值。
|
||||
|
||||
cancelScenarios:
|
||||
# 全仓-限价-买入开仓后撤单(冻结走全仓冻结字段)
|
||||
- name: 全仓限价买入撤单解冻
|
||||
order:
|
||||
contractId: 1
|
||||
side: bid
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 1
|
||||
marginRate: '0.01'
|
||||
orderSourceType: 1
|
||||
# 逐仓-限价-卖出开仓后撤单(冻结走逐仓冻结字段)
|
||||
- name: 逐仓限价卖出撤单解冻
|
||||
order:
|
||||
contractId: 1
|
||||
side: ask
|
||||
positionEffect: 1
|
||||
price: 100
|
||||
quantity: 10
|
||||
orderType: 1
|
||||
timeInForce: GTC
|
||||
marginType: 2
|
||||
marginRate: '0.02'
|
||||
orderSourceType: 1
|
||||
@@ -0,0 +1,56 @@
|
||||
# 合约公式层纯函数用例数据(数据驱动)
|
||||
# 期望值均为 Decimal 精确结果;费率用合约参数(maker=0.0002, taker=0.0005)
|
||||
|
||||
frozenMargin:
|
||||
- {price: 100, quantity: 10, margin_rate: '0.01', expected: '10.5'}
|
||||
- {price: 100, quantity: 10, margin_rate: '0.005', expected: '5.5'}
|
||||
- {price: '95.5', quantity: '2', margin_rate: '0.1', expected: '19.1955'}
|
||||
# 精度演示:float 下 0.1*3=0.30000000000000004,Decimal 精确
|
||||
- {price: '0.1', quantity: '3', margin_rate: '1', expected: '0.30015'}
|
||||
# 高杠杆:1000*50*0.02=1000,手续费孰高 1000*50*0.0005=25
|
||||
- {price: 1000, quantity: 50, margin_rate: '0.02', expected: '1025'}
|
||||
# 整仓(margin_rate=1):125*8*1 + 125*8*0.0005 = 1000 + 0.5
|
||||
- {price: 125, quantity: 8, margin_rate: '1', expected: '1000.5'}
|
||||
|
||||
unrealizedPnl:
|
||||
- {side: bid, open_price: 100, mark_price: 110, quantity: 10, expected: '100'}
|
||||
- {side: bid, open_price: 100, mark_price: 90, quantity: 10, expected: '-100'}
|
||||
- {side: ask, open_price: 100, mark_price: 90, quantity: 10, expected: '100'}
|
||||
- {side: ask, open_price: 100, mark_price: 110, quantity: 10, expected: '-100'}
|
||||
# 标记价不变:盈亏为 0
|
||||
- {side: bid, open_price: 100, mark_price: 100, quantity: 10, expected: '0'}
|
||||
# 小数价格:3.5*(100.25-95.5)=16.625
|
||||
- {side: bid, open_price: '95.5', mark_price: '100.25', quantity: '3.5', expected: '16.625'}
|
||||
|
||||
bankruptcyPrice:
|
||||
- {side: bid, open_price: 100, quantity: 10, margin_rate: '0.1', extra_margin: '0', expected: '90'}
|
||||
- {side: ask, open_price: 100, quantity: 10, margin_rate: '0.1', extra_margin: '0', expected: '110'}
|
||||
- {side: bid, open_price: 100, quantity: 10, margin_rate: '0.1', extra_margin: '20', expected: '88'}
|
||||
# 做空追加保证金:100*1.1 + 20/10 = 112
|
||||
- {side: ask, open_price: 100, quantity: 10, margin_rate: '0.1', extra_margin: '20', expected: '112'}
|
||||
# 高杠杆做多 20 倍:100*(1-0.05) = 95
|
||||
- {side: bid, open_price: 100, quantity: 10, margin_rate: '0.05', extra_margin: '0', expected: '95'}
|
||||
# 高杠杆做空 50 倍:100*(1+0.02) = 102
|
||||
- {side: ask, open_price: 100, quantity: 10, margin_rate: '0.02', extra_margin: '0', expected: '102'}
|
||||
|
||||
liquidationPrice:
|
||||
- {side: bid, open_price: 100, quantity: 10, margin_rate: '0.1', maintain_rate: '0.005', extra_margin: '0', expected: '90.5'}
|
||||
- {side: ask, open_price: 100, quantity: 10, margin_rate: '0.1', maintain_rate: '0.005', extra_margin: '0', expected: '109.5'}
|
||||
- {side: bid, open_price: 100, quantity: 10, margin_rate: '0.1', maintain_rate: '0.005', extra_margin: '20', expected: '88.5'}
|
||||
# 做空追加保证金:需亏 115,价格上涨 11.5 → 100 + 11.5 = 111.5
|
||||
- {side: ask, open_price: 100, quantity: 10, margin_rate: '0.1', maintain_rate: '0.005', extra_margin: '20', expected: '111.5'}
|
||||
# 高杠杆做多 20 倍:100 + (5-0-50)/10 = 95.5
|
||||
- {side: bid, open_price: 100, quantity: 10, margin_rate: '0.05', maintain_rate: '0.005', extra_margin: '0', expected: '95.5'}
|
||||
# 高杠杆做空 50 倍:需亏 15,价格上涨 1.5 → 100 + 1.5 = 101.5
|
||||
- {side: ask, open_price: 100, quantity: 10, margin_rate: '0.02', maintain_rate: '0.005', extra_margin: '0', expected: '101.5'}
|
||||
|
||||
isBurst:
|
||||
# 恰好等于强平价:保证金余额 == 维持保证金,<= 即触发
|
||||
- {side: bid, open_price: 100, mark_price: '90.5', quantity: 10, margin_rate: '0.1', maintain_rate: '0.005', extra_margin: '0', expected: true}
|
||||
- {side: bid, open_price: 100, mark_price: '91', quantity: 10, margin_rate: '0.1', maintain_rate: '0.005', extra_margin: '0', expected: false}
|
||||
- {side: ask, open_price: 100, mark_price: '109.5', quantity: 10, margin_rate: '0.1', maintain_rate: '0.005', extra_margin: '0', expected: true}
|
||||
- {side: ask, open_price: 100, mark_price: '109', quantity: 10, margin_rate: '0.1', maintain_rate: '0.005', extra_margin: '0', expected: false}
|
||||
# 穿仓:标记价跌破破产价,余额为负仍判定触发
|
||||
- {side: bid, open_price: 100, mark_price: '85', quantity: 10, margin_rate: '0.1', maintain_rate: '0.005', extra_margin: '0', expected: true}
|
||||
# 高杠杆做空 50 倍:余额 20+(100-103.5)*10=-15 <= 维持保证金 5,触发(103.5 已越过强平价 101.5)
|
||||
- {side: ask, open_price: 100, mark_price: '103.5', quantity: 10, margin_rate: '0.02', maintain_rate: '0.005', extra_margin: '0', expected: true}
|
||||
@@ -0,0 +1,47 @@
|
||||
# 强平场景用例数据(数据驱动)
|
||||
# 每行一个场景:市价开仓(开仓时标记价 100)→ 设安全标记价(不触发)
|
||||
# → 设触发标记价(触发强平)。期望的强平价/破产价由公式层独立计算。
|
||||
|
||||
liquidationScenarios:
|
||||
# 做多 10 倍杠杆:强平价 90.5,破产价 90
|
||||
- name: 做多-触及强平价触发
|
||||
side: bid
|
||||
quantity: 10
|
||||
marginRate: '0.1'
|
||||
safeMark: '91'
|
||||
triggerMark: '90.5'
|
||||
# 做空 10 倍杠杆:强平价 109.5,破产价 110
|
||||
- name: 做空-触及强平价触发
|
||||
side: ask
|
||||
quantity: 10
|
||||
marginRate: '0.1'
|
||||
safeMark: '109'
|
||||
triggerMark: '109.5'
|
||||
# 做多且标记价跌破破产价:穿仓,缺口由风险基金兜底
|
||||
- name: 做多-穿仓由风险基金兜底
|
||||
side: bid
|
||||
quantity: 10
|
||||
marginRate: '0.1'
|
||||
safeMark: '91'
|
||||
triggerMark: '85'
|
||||
# 逐仓 20 倍杠杆做多:强平价 95.5,破产价 95
|
||||
- name: 高杠杆20x做多-触及强平价触发
|
||||
side: bid
|
||||
quantity: 10
|
||||
marginRate: '0.05'
|
||||
safeMark: '96'
|
||||
triggerMark: '95.5'
|
||||
# 逐仓 50 倍杠杆做空:强平价 101.5,破产价 102
|
||||
- name: 高杠杆50x做空-触及强平价触发
|
||||
side: ask
|
||||
quantity: 10
|
||||
marginRate: '0.02'
|
||||
safeMark: '101'
|
||||
triggerMark: '101.5'
|
||||
# 做空且标记价涨破破产价 110:穿仓,缺口由风险基金兜底
|
||||
- name: 做空-穿仓由风险基金兜底
|
||||
side: ask
|
||||
quantity: 10
|
||||
marginRate: '0.1'
|
||||
safeMark: '109'
|
||||
triggerMark: '115'
|
||||
Reference in New Issue
Block a user