trading-order-admin/src/main/resources/application-prod.yml
@@ -2,9 +2,9 @@ port: 8111 spring: datasource: url: jdbc:mysql://127.0.0.1:3306/trading_order?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true url: jdbc:mysql://127.0.0.1:6306/trading_order?allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true username: root password: 123456 password: Err;2[eoGFUriwdgr driver-class-name: com.mysql.cj.jdbc.Driver type: com.zaxxer.hikari.HikariDataSource hikari: @@ -13,8 +13,32 @@ idle-timeout: 25000 auto-commit: true connection-test-query: SELECT 1 cache: type: redis redis: cache-null-values: true redis: redisson: config: classpath:redisson/redisson-dev.yml logging: config: classpath:logback/logback-prod.xml jetcache: statIntervalMinutes: 1 default: # 默认default,可以配置更多的area type: linkedhashmap # 已支持可选:linkedhashmap、caffeine keyConvertor: fastjson # key转换器 remote: default: # 缓存类型。tair、redis为当前支持的远程缓存 type: redis keyConvertor: fastjson # 采用Java序列化存储 valueEncoder: java valueDecoder: java poolConfig: minIdle: 5 maxIdle: 20 maxTotal: 50 host: 127.0.0.1 port: 6380 trading-order-admin/src/main/resources/application.yml
@@ -1,7 +1,7 @@ spring: # 环境 dev|test|prod profiles: active: local active: prod #文件上传设置 servlet: multipart: trading-order-admin/src/main/resources/logback/logback-prod.xml
@@ -1,5 +1,5 @@ <configuration scan="true" scanPeriod="60 seconds" debug="false"> <property name="PROJECT_PATH" value="/opt/projects/yami-b2b2c"/> <property name="PROJECT_PATH" value="/springbootlog"/> <property name="LOG_FILE_MAX_HISTORY" value="30"/> <property name="LOG_FILE_MAX_SIZE" value="50MB"/> trading-order-admin/src/main/resources/redisson/redisson-dev.yml
@@ -1,8 +1,8 @@ # 单节点设置 singleServerConfig: address: redis://127.0.0.1:7379 database: 0 password: BHvK&mg6cckt address: redis://127.0.0.1:6380 database: 10 password: idleConnectionTimeout: 10000 connectTimeout: 10000 timeout: 3000 trading-order-security-common/src/main/java/com/yami/trading/security/common/manager/TokenStore.java
@@ -257,15 +257,18 @@ int expiresIn = getExpiresIn(sysType); long second = 1000L; if (System.currentTimeMillis() - createTokenTime > expiresIn * second) { logger.error("登录token已过期"); throw new YamiShopBindException(403,"token error"); } } catch (Exception e) { }catch (Exception e) { logger.error("登录token异常"+e.getMessage()); e.printStackTrace(); throw new YamiShopBindException(403,"token error"); } // 防止解密后的token是脚本,从而对redis进行攻击,uuid只能是数字和小写字母 if (!PrincipalUtil.isSimpleChar(decryptToken)) { logger.error("token解密异常:"+decryptStr); throw new YamiShopBindException(403,"token error"); } return decryptToken; trading-order-service/src/main/java/com/yami/trading/service/impl/StrongLevelCalculationServiceImpl.java
@@ -14,31 +14,6 @@ @Service public class StrongLevelCalculationServiceImpl implements StrongLevelCalculationService { public static void main(String[] args) { // 给定参数 double marginBalance = 10; // 保证金余额 double faceValue = 0.01; // 合约面值(固定面值不能调整) double contractQuantity = 0.5; // 合约张数 张数=可用保证金*杠杆倍数/(面值*最新成交价) double openingPrice = 97016.4; // 开仓均价 double maintenanceMarginRate = 0.004; // 维持保证金率(固定不变) double feeRate = 0.0005; // 手续费率 根据实际设置 // 计算强平价 double liquidationPrice = a(marginBalance, faceValue, contractQuantity, openingPrice, maintenanceMarginRate, feeRate); // 输出结果 System.out.println("多仓预估强平价: " + liquidationPrice); // 计算空仓预估强平价 double liquidationPrice2 = b(marginBalance, faceValue, contractQuantity, openingPrice, maintenanceMarginRate, feeRate); // 输出结果 System.out.println("空仓预估强平价: " + liquidationPrice2); } /** * 多仓强平价格计算 多仓预估强平价 =(保证金余额-面值 *|张数|*开仓均价)/(面值*张数|*(维持保证金率+手续费率 -1)); * @param marginBalance 保证金余额 @@ -113,7 +88,34 @@ return bd.doubleValue(); } public static double a (double marginBalance, double faceValue, double contractQuantity, public static void main(String[] args) { // 给定参数 double marginBalance = 10; // 保证金余额 double faceValue = 0.01; // 合约面值(固定面值不能调整) double contractQuantity = 0.5; // 合约张数 张数=可用保证金*杠杆倍数/(面值*最新成交价) double openingPrice = 97016.4; // 开仓均价 double maintenanceMarginRate = 0.004; // 维持保证金率(固定不变) double feeRate = 0.0005; // 手续费率 根据实际设置 // 计算强平价 double liquidationPrice = demoA(marginBalance, faceValue, contractQuantity, openingPrice, maintenanceMarginRate, feeRate); // 输出结果 System.out.println("多仓预估强平价: " + liquidationPrice); // 计算空仓预估强平价 double liquidationPrice2 = demoB(marginBalance, faceValue, contractQuantity, openingPrice, maintenanceMarginRate, feeRate); // 输出结果 System.out.println("空仓预估强平价: " + liquidationPrice2); } public static double demoA (double marginBalance, double faceValue, double contractQuantity, double openingPrice, double maintenanceMarginRate, double feeRate){ // 计算分子部分 double numerator = marginBalance - (faceValue * contractQuantity * openingPrice); @@ -140,7 +142,7 @@ * @param feeRate 手续费率 * @return */ public static double b (double marginBalance, double faceValue, double contractQuantity, public static double demoB (double marginBalance, double faceValue, double contractQuantity, double openingPrice, double maintenanceMarginRate, double feeRate){ // 计算分子部分 double numerator = marginBalance + (faceValue * contractQuantity * openingPrice);