- 使用 swapPricePrecision 工具替代原有的 otcformat 精度设置 - 在多个页面文件中引入 swapPricePrecision 相关脚本 - 将原有的固定精度配置替换为动态精度获取方法 - 统一金额、数量、利率等字段的格式化处理逻辑 - 优化数据格式化函数,提高数值显示的一致性和准确性 - 移除冗余的硬编码精度参数,简化代码维护复杂度
54 lines
2.3 KiB
JavaScript
54 lines
2.3 KiB
JavaScript
// 通过 /front/swappriceprecision 加载。可按 UnderlyingInstrumentType 修改;缺项或非法值由页面精度组件回退内置默认规则。
|
|
window.main = window.main || {};
|
|
window.main.swapPricePrecision = {
|
|
common: {
|
|
amount: { precision: 2 },
|
|
quantity: { precision: 2 },
|
|
rate: { precision: 4 }
|
|
},
|
|
Stock: { integerDigits: 7, precision: 2 },
|
|
StockIndex: { integerDigits: 7, precision: 2 },
|
|
StockIF: { integerDigits: 7, precision: 4 },
|
|
CommodityFutures: { integerDigits: 7, precision: 4 },
|
|
CommoditySpot: { integerDigits: 7, precision: 4 },
|
|
NewOtcStock: { integerDigits: 7, precision: 4 },
|
|
HKStock: { integerDigits: 7, precision: 4 },
|
|
HKStockIndex: { integerDigits: 7, precision: 4 },
|
|
Fund: { integerDigits: 7, precision: 4 },
|
|
Bond: {
|
|
grossPrice: { integerDigits: 6, precision: 9 },
|
|
netPrice: { integerDigits: 6, precision: 9 },
|
|
yield: { integerDigits: 2, precision: 4 }
|
|
},
|
|
TBonds: {
|
|
grossPrice: { integerDigits: 6, precision: 9 },
|
|
netPrice: { integerDigits: 6, precision: 9 },
|
|
yield: { integerDigits: 2, precision: 4 }
|
|
},
|
|
CreditBonds: {
|
|
grossPrice: { integerDigits: 6, precision: 9 },
|
|
netPrice: { integerDigits: 6, precision: 9 },
|
|
yield: { integerDigits: 2, precision: 4 }
|
|
},
|
|
OtherBonds: {
|
|
grossPrice: { integerDigits: 6, precision: 9 },
|
|
netPrice: { integerDigits: 6, precision: 9 },
|
|
yield: { integerDigits: 2, precision: 4 }
|
|
},
|
|
TBFutures: { integerDigits: 8, precision: 4 },
|
|
OtherFutures: { integerDigits: 8, precision: 4 },
|
|
GoldSpot: { integerDigits: 8, precision: 4 },
|
|
OtherSpot: { integerDigits: 8, precision: 4 },
|
|
AbroadFutures: { integerDigits: 8, precision: 4 },
|
|
AbroadSpot: { integerDigits: 8, precision: 4 },
|
|
AbroadStock: { integerDigits: 8, precision: 2 },
|
|
AbroadStockIndex: { integerDigits: 8, precision: 4 },
|
|
ExRate: { integerDigits: 2, precision: 8 },
|
|
Shibor: { integerDigits: 2, precision: 4 },
|
|
FixingRepoRate: { integerDigits: 2, precision: 4 },
|
|
RateYield: {integerDigits: 6, precision: 8},
|
|
BondIndex: {integerDigits: 6, precision: 4},
|
|
|
|
// TODO: 利率收益率(6+8)、债券指数(6+4)、黄金期货(6+4)待对应的 UnderlyingInstrumentType 枚举确认后启用。
|
|
};
|