bitmart优化完成
This commit is contained in:
@@ -15,6 +15,8 @@ import requests
|
||||
from DrissionPage import ChromiumPage, ChromiumOptions
|
||||
from bitmart.api_contract import APIContract
|
||||
from bitmart.lib.cloud_exceptions import APIException
|
||||
|
||||
|
||||
# from 交易.tools import send_dingtalk_message
|
||||
|
||||
|
||||
@@ -220,7 +222,7 @@ class BrowserTradingExecutor:
|
||||
# 市价做空
|
||||
if not self.click_safe('x://button[normalize-space(text()) ="市价"]'):
|
||||
return False
|
||||
self.page.ele('x://*[@id="size_0"]').input(size)
|
||||
self.page.ele('x://*[@id="size_0"]').input(vals=size, clear=True)
|
||||
if not self.click_safe('x://span[normalize-space(text()) ="卖出/做空"]'):
|
||||
return False
|
||||
logger.success(f"市价做空成功: {size}")
|
||||
@@ -230,7 +232,7 @@ class BrowserTradingExecutor:
|
||||
# 市价做多
|
||||
if not self.click_safe('x://button[normalize-space(text()) ="市价"]'):
|
||||
return False
|
||||
self.page.ele('x://*[@id="size_0"]').input(size)
|
||||
self.page.ele('x://*[@id="size_0"]').input(vals=size, clear=True)
|
||||
if not self.click_safe('x://span[normalize-space(text()) ="买入/做多"]'):
|
||||
return False
|
||||
logger.success(f"市价做多成功: {size}")
|
||||
@@ -243,7 +245,7 @@ class BrowserTradingExecutor:
|
||||
return False
|
||||
self.page.ele('x://*[@id="price_0"]').input(vals=price, clear=True)
|
||||
time.sleep(1)
|
||||
self.page.ele('x://*[@id="size_0"]').input(size)
|
||||
self.page.ele('x://*[@id="size_0"]').input(vals=size, clear=True)
|
||||
if not self.click_safe('x://span[normalize-space(text()) ="卖出/做空"]'):
|
||||
return False
|
||||
logger.success(f"限价做空成功: {size} @ {price}")
|
||||
@@ -255,7 +257,7 @@ class BrowserTradingExecutor:
|
||||
return False
|
||||
self.page.ele('x://*[@id="price_0"]').input(vals=price, clear=True)
|
||||
time.sleep(1)
|
||||
self.page.ele('x://*[@id="size_0"]').input(size)
|
||||
self.page.ele('x://*[@id="size_0"]').input(vals=size, clear=True)
|
||||
if not self.click_safe('x://span[normalize-space(text()) ="买入/做多"]'):
|
||||
return False
|
||||
logger.success(f"限价做多成功: {size} @ {price}")
|
||||
@@ -483,7 +485,7 @@ class BitMartMarketMakerAPI:
|
||||
def get_open_orders(self) -> List[Dict]:
|
||||
"""获取当前所有挂单"""
|
||||
try:
|
||||
resp = self.contractAPI.get_open_orders(
|
||||
resp = self.contractAPI.get_open_order(
|
||||
contract_symbol=self.config.contract_symbol
|
||||
)[0]
|
||||
if resp.get("code") == 1000:
|
||||
@@ -833,9 +835,9 @@ class MarketMakingStrategy:
|
||||
# 检查当前挂单数量
|
||||
with self.order_lock:
|
||||
pending_buy_count = sum(1 for o in self.pending_orders.values()
|
||||
if o.side == "buy" and o.status == "pending")
|
||||
if o.side == "buy" and o.status == "pending")
|
||||
pending_sell_count = sum(1 for o in self.pending_orders.values()
|
||||
if o.side == "sell" and o.status == "pending")
|
||||
if o.side == "sell" and o.status == "pending")
|
||||
|
||||
# 如果两侧都有挂单,不重复挂
|
||||
if pending_buy_count > 0 and pending_sell_count > 0:
|
||||
@@ -966,8 +968,8 @@ if __name__ == '__main__':
|
||||
tge_id=196495, # TGE浏览器ID
|
||||
trading_url="https://derivatives.bitmart.com/zh-CN/futures/ETHUSDT",
|
||||
spread_percent=0.01, # 0.01%价差
|
||||
order_size_usdt=2.0, # 每单10 USDT
|
||||
max_position_usdt=30.0, # 最大持仓100 USDT
|
||||
order_size_usdt=1.0, # 每单10 USDT
|
||||
max_position_usdt=3.0, # 最大持仓100 USDT
|
||||
order_refresh_interval=2.0, # 2秒刷新一次
|
||||
order_timeout=60.0, # 60秒超时
|
||||
max_daily_loss=50.0, # 每日最大亏损50 USDT
|
||||
@@ -984,3 +986,6 @@ if __name__ == '__main__':
|
||||
logger.error(f"程序异常: {e}")
|
||||
# send_dingtalk_message(f"做市策略异常: {e}", error=True)
|
||||
|
||||
|
||||
# 9359,53
|
||||
# 14.35
|
||||
Binary file not shown.
BIN
telegram/sign.db
BIN
telegram/sign.db
Binary file not shown.
Reference in New Issue
Block a user