This commit is contained in:
27942
2025-12-29 18:29:21 +08:00
parent 2b8698ddbc
commit 3bea1cf69e
4 changed files with 1176 additions and 699 deletions

View File

@@ -5,19 +5,14 @@ BitMart 被动做市/高频刷单策略
"""
import time
import datetime
from typing import Optional, Dict, List, Tuple
from dataclasses import dataclass
from loguru import logger
from threading import Lock
import requests
from DrissionPage import ChromiumPage, ChromiumOptions
from dataclasses import dataclass
from bitmart.api_contract import APIContract
from bitmart.lib.cloud_exceptions import APIException
from typing import Optional, Dict, List, Tuple
from DrissionPage import ChromiumPage, ChromiumOptions
# from 交易.tools import send_dingtalk_message
from bit_tools import openBrowser
# ================================================================
@@ -26,6 +21,7 @@ from bitmart.lib.cloud_exceptions import APIException
@dataclass
class MarketMakingConfig:
bit_id: str = "f2320f57e24c45529a009e1541e25961"
"""做市策略配置"""
# API配置仅用于查询不下单
api_key: str = "a0fb7b98464fd9bcce67e7c519d58ec10d0c38a8"
@@ -119,7 +115,8 @@ class PendingOrder:
class BrowserManager:
"""浏览器管理器:负责浏览器的启动、接管和标签页管理"""
def __init__(self, config: MarketMakingConfig):
def __init__(self, config: MarketMakingConfig, bit_id="f2320f57e24c45529a009e1541e25961"):
self.bit_id = "f2320f57e24c45529a009e1541e25961"
self.config = config
self.tge_port: Optional[int] = None
self.page: Optional[ChromiumPage] = None
@@ -127,14 +124,10 @@ class BrowserManager:
def open_browser(self) -> bool:
"""打开浏览器并获取端口"""
try:
response = requests.post(
f"{self.config.tge_url}/api/browser/start",
json={"envId": self.config.tge_id},
headers=self.config.tge_headers,
timeout=10
)
self.tge_port = response.json()["data"]["port"]
logger.success(f"成功打开浏览器,端口:{self.tge_port}")
bit_port = openBrowser(id=self.bit_id)
co = ChromiumOptions()
co.set_local_port(port=bit_port)
self.page = ChromiumPage(addr_or_opts=co)
return True
except Exception as e:
logger.error(f"打开浏览器失败: {e}")
@@ -580,7 +573,8 @@ class BitMartMarketMakerAPI:
class MarketMakingStrategy:
"""被动做市策略(使用浏览器自动化下单,获取高返佣)"""
def __init__(self, config: MarketMakingConfig):
def __init__(self, config: MarketMakingConfig, bit_id=None):
self.bit_id = bit_id
self.config = config
self.api = BitMartMarketMakerAPI(config) # 仅用于查询
@@ -615,10 +609,10 @@ class MarketMakingStrategy:
logger.error("打开浏览器失败")
return False
# 接管浏览器
if not self.browser_manager.take_over_browser():
logger.error("接管浏览器失败")
return False
# # 接管浏览器
# if not self.browser_manager.take_over_browser():
# logger.error("接管浏览器失败")
# return False
# 关闭多余标签页
self.browser_manager.close_extra_tabs()
@@ -967,7 +961,7 @@ class MarketMakingStrategy:
if __name__ == '__main__':
config = MarketMakingConfig(
contract_symbol="ETHUSDT",
tge_id=196495, # TGE浏览器ID
bit_id="f2320f57e24c45529a009e1541e25961", # TGE浏览器ID
trading_url="https://derivatives.bitmart.com/zh-CN/futures/ETHUSDT",
spread_percent=0.01, # 0.01%价差
order_size_usdt=0.1, # 每单10 USDT
@@ -976,7 +970,7 @@ if __name__ == '__main__':
order_timeout=60.0, # 60秒超时
max_daily_loss=50.0, # 每日最大亏损50 USDT
max_daily_trades=1000, # 每日最大1000笔
leverage="30",
leverage="35",
open_type="cross"
)
@@ -988,6 +982,5 @@ if __name__ == '__main__':
logger.error(f"程序异常: {e}")
# send_dingtalk_message(f"做市策略异常: {e}", error=True)
# 9359,53
# 14.35
# 14.35

File diff suppressed because it is too large Load Diff

979
test1.py

File diff suppressed because it is too large Load Diff

View File

@@ -571,12 +571,15 @@ Winwin benefits — dont miss out! 🚀
# 点击关注
# tab = self.page.new_tab(url="https://x.com/CryptoStart_App")
tab = self.page.new_tab(url="https://x.com/webseabusiness")
tab = self.page.new_tab(url="https://x.com/Websea_MY")
time.sleep(10)
ele = tab.ele('x://span[text()="Follow"]', timeout=0.5)
if ele:
tab.actions.click(on_ele=ele)
time.sleep(10)
# ele = tab.ele('x://span[text()="Follow"]', timeout=0.5)
# if ele:
# tab.actions.click(on_ele=ele)
# time.sleep(10)
tab.actions.click(
on_ele='x://*[@id="react-root"]/div/div/div[2]/main/div/div/div/div[1]/div/div[3]/div/div/div[1]/div[1]/div[1]/div[2]/div/div[1]/button/div/span/span')
for i in range(random.randint(1, 10)):
tab.actions.scroll(delta_y=random.randint(400, 800))
@@ -585,16 +588,17 @@ Winwin benefits — dont miss out! 🚀
def 回复(self):
urls = [
"https://x.com/Websea_MY/status/2003700808186278388",
"https://x.com/Websea_MY/status/2003669526492405904",
# "https://x.com/Websea_MY/status/2001119115575222779",
# "https://x.com/Websea_MY/status/2001180999443734677"
"https://x.com/Websea_MY/status/2004081342364123146",
# "https://x.com/Websea_MY/status/2003669526492405904",
# # "https://x.com/Websea_MY/status/2001119115575222779",
# # "https://x.com/Websea_MY/status/2001180999443734677"
]
tests = [
"Canal premium de Websea: Regístrese para disfrutar de descuentos del 85 % en las comisiones de los futuros de Websea. Para grandes volúmenes de registros, el porcentaje es negociable. Agentes bienvenidos a consultar. Contacto Telegram: @webseatom",
"O canal premium da Websea oferece 85% de desconto nas taxas de comissão de contratos após o cadastro, com condições negociáveis para grandes volumes. Corretores interessados podem entrar em contato pelo Telegram: @webseatom",
"Канал Websea Premium: зарегистрируйтесь, чтобы получить 85% комиссионных от контрактов Websea. По запросу предоставляются скидки за объем. Приглашаем агентов обращаться с запросами. Контактный Telegram: @webseatom",
"Websea - Kênh hàng đầu, đăng ký ngay để nhận 85% hoa hồng từ hợp đồng Websea. Số lượng lớn có thể thương lượng, chào đón các đại lý liên hệ. Liên hệ TG: @webseatom"
"O seguro de futuros da Websea ultrapassou oficialmente a marca de 400 rodadas de airdrops! 🚀 Contacte TGwebseatom 85% de reembolso",
"Websea #FuturesInsurance официально преодолела отметку в 400 раундов аирдропов! 🚀Свяжитесь с TGwebseatom 85% кэшбэк",
"¡Websea #FuturesInsurance ha superado oficialmente las 400 rondas de airdrops! 🚀Póngase en contacto con TGwebseatom 85 % de reembolso",
"Websea #FuturesInsurance has officially surpassed 400 rounds of airdrops! 🚀 Contact TGwebseatom 85% cashback",
"Websea #FuturesInsurance đã chính thức vượt qua 400 đợt airdrop! 🚀Liên hệ TGwebseatom 85% hoàn tiền",
]
tab = self.page.new_tab(random.choice(urls))
@@ -739,9 +743,9 @@ def run_work(x_token_info, xstart_info):
pass
# hub.to_do_tui() # 发推
hub.回复() # 发推
# hub.回复() # 发推
# hub.FollowTwitterAccount() # 关注
hub.FollowTwitterAccount() # 关注
if __name__ == '__main__':
@@ -763,8 +767,8 @@ if __name__ == '__main__':
# time.sleep(random.randint(15, 60))
# 同时运行
max_threads = 10
delay_between_start = 15 # 每次启动线程之间的延迟时间(秒)
max_threads = 5
delay_between_start = 30 # 每次启动线程之间的延迟时间(秒)
with ThreadPoolExecutor(max_workers=max_threads) as executor:
@@ -785,5 +789,5 @@ if __name__ == '__main__':
# continue
executor.submit(run_work, x_token_info, xstart_info)
# time.sleep(random.randint(150, 850))
# time.sleep(random.randint(60, 150))
time.sleep(delay_between_start)