feat(place_order): a 0.5% price impact in LIMIT
orders to guarantee filling
This commit is contained in:
9
main.py
9
main.py
@@ -27,6 +27,7 @@ import logging
|
|||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date
|
||||||
from typing import Dict, Any, Optional, Tuple, List
|
from typing import Dict, Any, Optional, Tuple, List
|
||||||
|
|
||||||
@@ -306,8 +307,12 @@ class MexcSpotTrade:
|
|||||||
if current_price is None:
|
if current_price is None:
|
||||||
logger.error("无法获取实时价格,交易取消")
|
logger.error("无法获取实时价格,交易取消")
|
||||||
return None
|
return None
|
||||||
processed_kwargs["price"] = current_price
|
# 防止挂单不成交
|
||||||
logger.info("使用实时价格作为限价: %f", current_price)
|
if side == "BUY":
|
||||||
|
processed_kwargs["price"] = current_price * 1.01 # 买入加价0.5%
|
||||||
|
elif side == "SELL":
|
||||||
|
processed_kwargs["price"] = current_price * 0.91 # 卖出减价0.5%
|
||||||
|
logger.info("使用调整0.5%%后价格作为限价: %f", processed_kwargs["price"])
|
||||||
|
|
||||||
# 处理LIMIT订单只有quoteOrderQty没有quantity的情况
|
# 处理LIMIT订单只有quoteOrderQty没有quantity的情况
|
||||||
if (
|
if (
|
||||||
|
Reference in New Issue
Block a user