| | |
| | | import java.math.BigDecimal; |
| | | |
| | | /** |
| | | * 用户私有成交频道处理器(futures.usertrades)。 |
| | | * |
| | | * <h3>数据用途</h3> |
| | | * 订阅用户私有成交更新推送。当订单成交时,获得真实的成交价格、手续费等信息, |
| | | * 可用于计算实际盈亏。 |
| | | * |
| | | * <h3>关键推送字段</h3> |
| | | * <ul> |
| | | * <li>id:交易 ID</li> |
| | | * <li>contract:合约名称</li> |
| | | * <li>order_id:订单 ID</li> |
| | | * <li>size:成交数量</li> |
| | | * <li>price:成交价格</li> |
| | | * <li>role:用户角色(maker/taker)</li> |
| | | * <li>fee:手续费</li> |
| | | * <li>point_fee:点卡手续费</li> |
| | | * <li>text:订单自定义信息</li> |
| | | * </ul> |
| | | * |
| | | * <h3>回调数据(传给 GateGridTradeService)</h3> |
| | | * contract (String), orderId (String), price (BigDecimal), size (String), role (String), fee (BigDecimal) |
| | | * 用户私有成交频道处理器(futures.usertrades),接收成交推送并回调 {@link GateGridTradeService#onUserTrade}。 |
| | | * |
| | | * @author Administrator |
| | | */ |
| | |
| | | String role = trade.getString("role"); |
| | | BigDecimal fee = trade.getBigDecimal("fee"); |
| | | String text = trade.getString("text"); |
| | | log.info("[{}] 成交更新, id:{}, order_id:{}, price:{}, size:{}, role:{}, fee:{}, text:{}", |
| | | CHANNEL_NAME, id, orderId, price, size, role, fee, text); |
| | | if (getGridTradeService() != null) { |
| | | getGridTradeService().onUserTrade(contract, orderId, price, size, role, fee); |
| | | } |
| | | // log.info("[{}] 成交更新, id:{}, order_id:{}, price:{}, size:{}, role:{}, fee:{}, text:{}", |
| | | // CHANNEL_NAME, id, orderId, price, size, role, fee, text); |
| | | // if (getGridTradeService() != null) { |
| | | // getGridTradeService().onUserTrade(contract, orderId, price, size, role, fee); |
| | | // } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("[{}] 处理数据失败", CHANNEL_NAME, e); |