auto_trade_sys/持仓记录_2026-02-16T09-45-37.json
薇薇安 0fb42a5f24 feat(market_cache): 引入市场数据缓存机制以优化API调用
在 `backend/database/models.py` 中新增 `MarketCache` 类,支持从数据库缓存交易对信息和资金费率,减少对币安API的调用频率。更新 `binance_client` 和 `market_scanner` 以优先从缓存读取数据,添加超时处理和重试机制,提升系统稳定性。同时,增强了资金费率和主动买卖量的过滤逻辑,确保在开仓前进行有效的风险控制。
2026-02-16 18:05:11 +08:00

870 lines
22 KiB
JSON

[
{
"id": 5110,
"symbol": "1000BONKUSDT",
"side": "BUY",
"quantity": 3531,
"entry_price": 0.006565,
"entry_value_usdt": 23.181015,
"notional_usdt": 23.459964,
"margin_usdt": 5.864991,
"original_notional_usdt": 23.181015,
"original_margin_usdt": 5.79525375,
"mark_price": 0.006644,
"pnl": 0.278949,
"pnl_percent": 4.7561709813365445,
"leverage": 4,
"entry_time": 1771214454,
"stop_loss_price": 0.00636805,
"take_profit_price": 0.00697531,
"take_profit_1": null,
"take_profit_2": null,
"atr": null,
"entry_order_id": null,
"entry_order_type": null,
"open_orders": [
{
"orderId": 2000000460584754,
"type": "TAKE_PROFIT_MARKET",
"side": "SELL",
"stopPrice": 0.006975,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460584735,
"type": "STOP_MARKET",
"side": "SELL",
"stopPrice": 0.006369,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
],
"active_sl_orders": "STOP_MARKET @ 0.006369 (NEW)",
"active_tp_orders": "TAKE_PROFIT_MARKET @ 0.006975 (NEW)",
"binance_open_orders_raw": [
{
"orderId": 2000000460584754,
"type": "TAKE_PROFIT_MARKET",
"side": "SELL",
"stopPrice": 0.006975,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460584735,
"type": "STOP_MARKET",
"side": "SELL",
"stopPrice": 0.006369,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
]
},
{
"id": 5157,
"symbol": "ZECUSDT",
"side": "SELL",
"quantity": 0.077,
"entry_price": 284.54,
"entry_value_usdt": 21.909580000000002,
"notional_usdt": 22.23683,
"margin_usdt": 5.5592075,
"original_notional_usdt": 21.92881912,
"original_margin_usdt": 5.48220478,
"mark_price": 288.79,
"pnl": -0.32725,
"pnl_percent": -5.886630423491117,
"leverage": 4,
"entry_time": 1771226616,
"stop_loss_price": null,
"take_profit_price": null,
"take_profit_1": null,
"take_profit_2": null,
"atr": 14.62428571,
"entry_order_id": 797717260491,
"entry_order_type": "LIMIT",
"open_orders": [
{
"orderId": 2000000460584806,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 266.76,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460584795,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 293.07,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
],
"active_sl_orders": "STOP_MARKET @ 293.07 (NEW)",
"active_tp_orders": "TAKE_PROFIT_MARKET @ 266.76 (NEW)",
"binance_open_orders_raw": [
{
"orderId": 2000000460584806,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 266.76,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460584795,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 293.07,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
]
},
{
"id": 5109,
"symbol": "HYPEUSDT",
"side": "SELL",
"quantity": 0.7,
"entry_price": 30.158,
"entry_value_usdt": 21.110599999999998,
"notional_usdt": 20.984715002999998,
"margin_usdt": 5.2461787507499995,
"original_notional_usdt": 21.1106,
"original_margin_usdt": 5.27765,
"mark_price": 29.97816429,
"pnl": 0.12588499,
"pnl_percent": 2.3995558668679244,
"leverage": 4,
"entry_time": 1771214453,
"stop_loss_price": null,
"take_profit_price": null,
"take_profit_1": null,
"take_profit_2": null,
"atr": null,
"entry_order_id": 5837357832,
"entry_order_type": "LIMIT",
"open_orders": [
{
"orderId": 2000000460584837,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 28.274,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460584833,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 31.062,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
],
"active_sl_orders": "STOP_MARKET @ 31.062 (NEW)",
"active_tp_orders": "TAKE_PROFIT_MARKET @ 28.274 (NEW)",
"binance_open_orders_raw": [
{
"orderId": 2000000460584837,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 28.274,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460584833,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 31.062,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
]
},
{
"id": 5112,
"symbol": "FILUSDT",
"side": "SELL",
"quantity": 22,
"entry_price": 0.963,
"entry_value_usdt": 21.186,
"notional_usdt": 21.37234946,
"margin_usdt": 5.343087365,
"original_notional_usdt": 21.186,
"original_margin_usdt": 5.2965,
"mark_price": 0.97147043,
"pnl": -0.18634946,
"pnl_percent": -3.4876738348073033,
"leverage": 4,
"entry_time": 1771214455,
"stop_loss_price": 0.99189,
"take_profit_price": 0.9028125,
"take_profit_1": null,
"take_profit_2": null,
"atr": null,
"entry_order_id": null,
"entry_order_type": null,
"open_orders": [
{
"orderId": 2000000460584866,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 0.903,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460584857,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 0.991,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
],
"active_sl_orders": "STOP_MARKET @ 0.991 (NEW)",
"active_tp_orders": "TAKE_PROFIT_MARKET @ 0.903 (NEW)",
"binance_open_orders_raw": [
{
"orderId": 2000000460584866,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 0.903,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460584857,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 0.991,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
]
},
{
"id": 5113,
"symbol": "TAKEUSDT",
"side": "SELL",
"quantity": 172,
"entry_price": 0.03629,
"entry_value_usdt": 6.24188,
"notional_usdt": 5.387599,
"margin_usdt": 5.387599,
"original_notional_usdt": 6.24188,
"original_margin_usdt": 6.24188,
"mark_price": 0.03132325,
"pnl": 0.854281,
"pnl_percent": 15.856432522168037,
"leverage": 1,
"entry_time": 1771214456,
"stop_loss_price": 0.0373787,
"take_profit_price": 0.0272175,
"take_profit_1": null,
"take_profit_2": null,
"atr": null,
"entry_order_id": null,
"entry_order_type": null,
"open_orders": [
{
"orderId": 2000000460584904,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 0.02722,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460584895,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 0.03737,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
],
"active_sl_orders": "STOP_MARKET @ 0.03737 (NEW)",
"active_tp_orders": "TAKE_PROFIT_MARKET @ 0.02722 (NEW)",
"binance_open_orders_raw": [
{
"orderId": 2000000460584904,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 0.02722,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460584895,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 0.03737,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
]
},
{
"id": 5135,
"symbol": "ZROUSDT",
"side": "SELL",
"quantity": 13.5,
"entry_price": 1.6807,
"entry_value_usdt": 22.68945,
"notional_usdt": 22.76581086,
"margin_usdt": 5.691452715,
"original_notional_usdt": 22.68945,
"original_margin_usdt": 5.6723625,
"mark_price": 1.68635636,
"pnl": -0.07636086,
"pnl_percent": -1.3416760855932017,
"leverage": 4,
"entry_time": 1771223082,
"stop_loss_price": 1.731121,
"take_profit_price": 1.57565625,
"take_profit_1": 1.57565625,
"take_profit_2": 1.49288286,
"atr": 0.07825714,
"entry_order_id": 6021914660,
"entry_order_type": "LIMIT",
"open_orders": [
{
"orderId": 2000000460584948,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 1.4929,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460584947,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 1.7311,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
],
"active_sl_orders": "STOP_MARKET @ 1.7311 (NEW)",
"active_tp_orders": "TAKE_PROFIT_MARKET @ 1.4929 (NEW)",
"binance_open_orders_raw": [
{
"orderId": 2000000460584948,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 1.4929,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460584947,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 1.7311,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
]
},
{
"id": 5115,
"symbol": "AXSUSDT",
"side": "SELL",
"quantity": 18,
"entry_price": 1.388,
"entry_value_usdt": 24.983999999999998,
"notional_usdt": 24.42318858,
"margin_usdt": 6.105797145,
"original_notional_usdt": 24.984,
"original_margin_usdt": 6.246,
"mark_price": 1.35684381,
"pnl": 0.56081142,
"pnl_percent": 9.184900950390155,
"leverage": 4,
"entry_time": 1771214457,
"stop_loss_price": 1.42964,
"take_profit_price": 1.30125,
"take_profit_1": null,
"take_profit_2": null,
"atr": null,
"entry_order_id": null,
"entry_order_type": null,
"open_orders": [
{
"orderId": 2000000460584986,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 1.302,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460584975,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 1.429,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
],
"active_sl_orders": "STOP_MARKET @ 1.429 (NEW)",
"active_tp_orders": "TAKE_PROFIT_MARKET @ 1.302 (NEW)",
"binance_open_orders_raw": [
{
"orderId": 2000000460584986,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 1.302,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460584975,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 1.429,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
]
},
{
"id": 5137,
"symbol": "XLMUSDT",
"side": "SELL",
"quantity": 127,
"entry_price": 0.16858,
"entry_value_usdt": 21.409660000000002,
"notional_usdt": 21.68884283,
"margin_usdt": 5.4222107075,
"original_notional_usdt": 21.40966,
"original_margin_usdt": 5.352415,
"mark_price": 0.17077829,
"pnl": -0.27918283,
"pnl_percent": -5.1488746022694105,
"leverage": 4,
"entry_time": 1771223321,
"stop_loss_price": 0.1736374,
"take_profit_price": 0.15804375,
"take_profit_1": 0.15804375,
"take_profit_2": 0.15550343,
"atr": 0.00544857,
"entry_order_id": 20994894391,
"entry_order_type": "LIMIT",
"open_orders": [
{
"orderId": 2000000460585021,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 0.15551,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460585020,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 0.17363,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
],
"active_sl_orders": "STOP_MARKET @ 0.17363 (NEW)",
"active_tp_orders": "TAKE_PROFIT_MARKET @ 0.15551 (NEW)",
"binance_open_orders_raw": [
{
"orderId": 2000000460585021,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 0.15551,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460585020,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 0.17363,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
]
},
{
"id": 5116,
"symbol": "DASHUSDT",
"side": "SELL",
"quantity": 0.571,
"entry_price": 37.25,
"entry_value_usdt": 21.26975,
"notional_usdt": 21.304009999999998,
"margin_usdt": 5.3260024999999995,
"original_notional_usdt": 21.26975,
"original_margin_usdt": 5.3174375,
"mark_price": 37.31,
"pnl": -0.03426,
"pnl_percent": -0.6432591798445457,
"leverage": 4,
"entry_time": 1771214458,
"stop_loss_price": 38.3675,
"take_profit_price": 34.921875,
"take_profit_1": null,
"take_profit_2": null,
"atr": null,
"entry_order_id": null,
"entry_order_type": null,
"open_orders": [
{
"orderId": 2000000460585100,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 34.93,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460585093,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 38.36,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
],
"active_sl_orders": "STOP_MARKET @ 38.36 (NEW)",
"active_tp_orders": "TAKE_PROFIT_MARKET @ 34.93 (NEW)",
"binance_open_orders_raw": [
{
"orderId": 2000000460585100,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 34.93,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460585093,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 38.36,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
]
},
{
"id": 5117,
"symbol": "USELESSUSDT",
"side": "BUY",
"quantity": 150,
"entry_price": 0.04083,
"entry_value_usdt": 6.124499999999999,
"notional_usdt": 7.085999999999999,
"margin_usdt": 7.085999999999999,
"original_notional_usdt": 6.1245,
"original_margin_usdt": 6.1245,
"mark_price": 0.04724,
"pnl": 0.9615,
"pnl_percent": 13.56900931414056,
"leverage": 1,
"entry_time": 1771214459,
"stop_loss_price": 0.0396051,
"take_profit_price": 0.0510375,
"take_profit_1": null,
"take_profit_2": null,
"atr": null,
"entry_order_id": null,
"entry_order_type": null,
"open_orders": [
{
"orderId": 2000000460585145,
"type": "TAKE_PROFIT_MARKET",
"side": "SELL",
"stopPrice": 0.05103,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460585138,
"type": "STOP_MARKET",
"side": "SELL",
"stopPrice": 0.03961,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
],
"active_sl_orders": "STOP_MARKET @ 0.03961 (NEW)",
"active_tp_orders": "TAKE_PROFIT_MARKET @ 0.05103 (NEW)",
"binance_open_orders_raw": [
{
"orderId": 2000000460585145,
"type": "TAKE_PROFIT_MARKET",
"side": "SELL",
"stopPrice": 0.05103,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460585138,
"type": "STOP_MARKET",
"side": "SELL",
"stopPrice": 0.03961,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
]
},
{
"id": 5118,
"symbol": "ENAUSDT",
"side": "SELL",
"quantity": 194,
"entry_price": 0.1196,
"entry_value_usdt": 23.2024,
"notional_usdt": 23.53230864,
"margin_usdt": 5.88307716,
"original_notional_usdt": 23.2024,
"original_margin_usdt": 5.8006,
"mark_price": 0.12130056,
"pnl": -0.32990864,
"pnl_percent": -5.607756468725288,
"leverage": 4,
"entry_time": 1771214460,
"stop_loss_price": 0.123188,
"take_profit_price": 0.112125,
"take_profit_1": null,
"take_profit_2": null,
"atr": null,
"entry_order_id": null,
"entry_order_type": null,
"open_orders": [
{
"orderId": 2000000460585199,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 0.1122,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460585168,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 0.1231,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
],
"active_sl_orders": "STOP_MARKET @ 0.1231 (NEW)",
"active_tp_orders": "TAKE_PROFIT_MARKET @ 0.1122 (NEW)",
"binance_open_orders_raw": [
{
"orderId": 2000000460585199,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 0.1122,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460585168,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 0.1231,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
]
},
{
"id": 5151,
"symbol": "WLFIUSDT",
"side": "SELL",
"quantity": 219,
"entry_price": 0.1011,
"entry_value_usdt": 22.1409,
"notional_usdt": 22.23684171,
"margin_usdt": 5.5592104275,
"original_notional_usdt": 22.1409,
"original_margin_usdt": 22.1409,
"mark_price": 0.10153809,
"pnl": -0.09594171,
"pnl_percent": -1.7258154058245532,
"leverage": 4,
"entry_time": 1771226264,
"stop_loss_price": null,
"take_profit_price": null,
"take_profit_1": null,
"take_profit_2": null,
"atr": null,
"entry_order_id": 2846730648,
"entry_order_type": "LIMIT",
"open_orders": [],
"active_sl_orders": "",
"active_tp_orders": "",
"binance_open_orders_raw": []
},
{
"id": 5123,
"symbol": "WLDUSDT",
"side": "SELL",
"quantity": 56,
"entry_price": 0.4028,
"entry_value_usdt": 22.5568,
"notional_usdt": 22.65973696,
"margin_usdt": 5.66493424,
"original_notional_usdt": 22.5568,
"original_margin_usdt": 5.6392,
"mark_price": 0.40463816,
"pnl": -0.10293696,
"pnl_percent": -1.8170901133002384,
"leverage": 4,
"entry_time": 1771214479,
"stop_loss_price": 0.414884,
"take_profit_price": 0.377625,
"take_profit_1": null,
"take_profit_2": null,
"atr": null,
"entry_order_id": null,
"entry_order_type": null,
"open_orders": [
{
"orderId": 2000000460523250,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 0.3777,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460523242,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 0.4148,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
],
"active_sl_orders": "STOP_MARKET @ 0.4148 (NEW)",
"active_tp_orders": "TAKE_PROFIT_MARKET @ 0.3777 (NEW)",
"binance_open_orders_raw": [
{
"orderId": 2000000460523250,
"type": "TAKE_PROFIT_MARKET",
"side": "BUY",
"stopPrice": 0.3777,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
},
{
"orderId": 2000000460523242,
"type": "STOP_MARKET",
"side": "BUY",
"stopPrice": 0.4148,
"price": 0,
"origType": "CONDITIONAL",
"reduceOnly": true,
"status": "NEW"
}
]
}
]