Commit 17c356ce authored by ml's avatar ml

合约交易对配置修改

parent 94108a6a
// @madex/ex-ts-dao 是 ts 的 dao, 代码在 bitbucket/ex-js-dao 的 ts 分支上
import { contractPairs, madContractOrmDB, coinType } from "@madex/ex-ts-dao";
import { contractPairs, madContractOrmDB, coinType, spotPairs } from "@madex/ex-ts-dao";
import { NUMBER } from "sequelize";
import { addPairToCore } from "../../../utils/coreSystemUtils";
import { ErrorCode } from "../../../constant/errorCode";
......@@ -48,19 +48,37 @@ export interface AddParam {
quantity_increment?: number;
default_initial_margin?: number; //"0.01",
base_initial_margin?: number;//"0.01",
base_maintenance_margin?: number;//"0.01",
settlement_asset?: number;// "USDT", 结算币种
index?: string;
base_interest: number; //"0.0003",
quote_interest?: number ; //"0.0006",
quote_interest?: number; //"0.0006",
impact_notional?: number; // "600000",
base_risk_limit?: number; // "1000000",
risk_limit_step?: number; //"1000000",
funding_times_perday: number; // 3
status?: number
min_order_size?: number
max_order_size?: number
min_order_value?: number
max_order_value?: number
view_precision?: number
createdAt?: Date | any,
......@@ -93,10 +111,25 @@ export async function list(param: ListParam) {
export const save = async (param: AddParam, currentUserId: any, ip: any) => {
param.updatedAt = new Date();
param.createdAt = new Date();
let dbInfo = await contractPairs.prototype.findOne({
where: {
symbol: param.symbol
},
raw: true
});
if (dbInfo) {
throw ErrorCode.DATA_EXIST;
}
if (!param.price_increment) {
param.price_increment = 1;
}
if (!param.quantity_increment) {
param.quantity_increment = 1;
}
await contractPairs.prototype.create(param);
//管理后台操作日志
addOptLog(currentUserId, 0, '交易对配置新增', ip, JSON.stringify(param), '交易对配置');
addOptLog(currentUserId, 0, '合约代码配置新增', ip, JSON.stringify(param), '合约代码配置');
return 'ok';
};
......@@ -115,12 +148,12 @@ export const update = async (param: AddParam, currentUserId: any, ip: any) => {
if (param.view_precision || param.view_precision === 0) {
updateInfo['view_precision'] = param.view_precision
}
// if (param.price_increment || param.price_increment === 0) {
// updateInfo['price_increment'] = param.price_increment
// }
// if (param.quantity_increment || param.quantity_increment === 0) {
// updateInfo['quantity_increment'] = param.quantity_increment
// }
if (param.price_increment) {
updateInfo['price_increment'] = param.price_increment
}
if (param.quantity_increment) {
updateInfo['quantity_increment'] = param.quantity_increment
}
await contractPairs.prototype.update(updateInfo, {
where: {
......@@ -128,7 +161,7 @@ export const update = async (param: AddParam, currentUserId: any, ip: any) => {
}
});
//管理后台操作日志
addOptLog(currentUserId, 0, '交易对配置更新', ip, JSON.stringify(param), '交易对配置');
addOptLog(currentUserId, 0, '合约代码配置更新', ip, JSON.stringify(param), '合约代码配置');
return 'ok';
};
......@@ -146,7 +179,7 @@ export const pushToCoreSystem = async (id: any, currentUserId: any, ip: any) =>
let base = sps[0];
let quote = sps[1]
let param = {
"market_type":2,
"market_type": 2,
"base": base, "quote": quote, "symbol": symbol, "name": symbol,
"price_scale": cfg.price_scale, "quantity_scale": cfg.quantity_scale,
"maker_fee": cfg.maker_fee, "taker_fee": cfg.taker_fee,
......@@ -177,7 +210,7 @@ export const pushToCoreSystem = async (id: any, currentUserId: any, ip: any) =>
let optResult = await addPairToCore(param);
if (!optResult.is_success) {
//管理后台操作日志
addOptLog(currentUserId, 0, '提交交易对到撮合-失败', ip, `pair:${symbol},error_msg:${optResult.err_msg}`, '交易对配置');
addOptLog(currentUserId, 0, '提交合约交易对到撮合-失败', ip, `pair:${symbol},error_msg:${optResult.err_msg}`, '合约代码配置');
throw ErrorCode.ADD_PAIR_TO_CORE_ERR;
}
......@@ -185,7 +218,7 @@ export const pushToCoreSystem = async (id: any, currentUserId: any, ip: any) =>
where: where
});
//管理后台操作日志
addOptLog(currentUserId, 0, '提交交易对到撮合-成功', ip, JSON.stringify(param), '交易对配置');
addOptLog(currentUserId, 0, '提交合约交易对到撮合-成功', ip, JSON.stringify(param), '合约代码配置');
return 'ok';
};
......
......@@ -50,6 +50,14 @@ export interface AddParam {
view_precision?: number
min_order_size?: number
max_order_size?: number
min_order_value?: number
max_order_value?: number
createdAt?: Date | any,
updatedAt?: Date | any,
......@@ -80,7 +88,22 @@ export async function list(param: ListParam) {
export const save = async (param: AddParam, currentUserId: any, ip: any) => {
param.updatedAt = new Date();
param.createdAt = new Date();
let dbInfo = await spotPairs.prototype.findOne({
where: {
symbol: param.symbol
},
raw: true
});
if (dbInfo) {
throw ErrorCode.DATA_EXIST;
}
if (!param.price_increment) {
param.price_increment = 1;
}
if (!param.quantity_increment) {
param.quantity_increment = 1;
}
await spotPairs.prototype.create(param);
//管理后台操作日志
addOptLog(currentUserId, 0, '交易对配置新增', ip, JSON.stringify(param), '交易对配置');
......@@ -102,12 +125,12 @@ export const update = async (param: AddParam, currentUserId: any, ip: any) => {
if (param.view_precision || param.view_precision === 0) {
updateInfo['view_precision'] = param.view_precision
}
// if (param.price_increment || param.price_increment === 0) {
// updateInfo['price_increment'] = param.price_increment
// }
// if (param.quantity_increment || param.quantity_increment === 0) {
// updateInfo['quantity_increment'] = param.quantity_increment
// }
if (param.price_increment) {
updateInfo['price_increment'] = param.price_increment
}
if (param.quantity_increment) {
updateInfo['quantity_increment'] = param.quantity_increment
}
await spotPairs.prototype.update(updateInfo, {
where: {
......
......@@ -22,6 +22,12 @@ let cmdWhiteList = {
'spotPair/list': 1,
'spotPair/pushToCoreSystem': 1,
'spotPair/getAllSubmitSuccess': 1,
//金融部-交易管理-合约代码配置
'contractPair/save': 1,
'contractPair/update': 1,
'contractPair/list': 1,
'contractPair/pushToCoreSystem': 1,
'contractPair/getAllSubmitSuccess': 1,
//运营部-其他管理-币种管理
'coinType/save': 1,
'coinType/update': 1,
......@@ -146,10 +152,6 @@ let cmdWhiteList = {
'tech/other/apikey/strict/add': 1,
'tech/other/apikey/strict/update': 1,
'tech/other/apikey/strict/del': 1,
//金融部-交易管理-合约代码配置
'finance/trade/contract/pair/set': 1,
'finance/trade/contract/pair/update': 1,
'finance/trade/contract/pair/query': 1,
//金融部-其他管理-现货做市参数配置
'fiance/other/spot/market/maker/set': 1,
'fiance/other/spot/market/maker/list': 1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment