This commit is contained in:
27942
2025-10-27 10:18:59 +08:00
parent 18793fb382
commit 5aa5edac87
3 changed files with 43 additions and 55 deletions

View File

@@ -14,7 +14,7 @@ while True:
current_minute = current_time.tm_min
print(current_minute)
if current_minute in [6, 30]:
if current_minute in [0, 30]:
show_reminder()
# 避免在同一分钟内重复提醒,等待一分钟
time.sleep(60)

2
test1.py Normal file
View File

@@ -0,0 +1,2 @@
if 0:
print(1)

View File

@@ -32,6 +32,8 @@ class WeexTransaction:
self.kline_1 = None # 01
self.kline_2 = None # 01
self.direction = None # 信号类型
def openBrowser(self, ): # 直接指定ID打开窗口也可以使用 createBrowser 方法返回的ID
json_data = {
@@ -119,6 +121,20 @@ class WeexTransaction:
return False
def to_do_page(self):
self.page.get("https://www.weeaxs.site/zh-CN/futures/demo-trading/ETH-SUSDT")
self.page.ele('x://*[@id="guide-order-type"]/div[2]/div/div[2]', timeout=15).click()
time.sleep(1)
self.page.ele('x://*[@id="guide-order-type"]/div[5]/div/div[2]/div[1]/input[2]').input(100)
time.sleep(1)
if self.direction == "long":
self.page.ele('x://*[@id="guide-order-type"]/div[9]/div/div[1]').click()
if self.direction == "short":
self.page.ele('x://*[@id="guide-order-type"]/div[9]/div/div[2]').click()
def action(self):
# 获取比特端口
@@ -138,68 +154,38 @@ class WeexTransaction:
self.page.listen.start("public/quote/v1/getKlineV2")
logger.success("浏览器开启抓包模式。。。")
new_price_datas = self.get_price()
if new_price_datas:
logger.success("获取最新交易价格成功!!!")
else:
logger.info("获取最新价格有问题!!!")
while True:
new_price_datas1 = sorted(new_price_datas, key=lambda x: x["id"])
kline_1, kline_2, kline_3 = new_price_datas1[-3:]
# 获取当前时间
current_time = time.localtime()
current_minute = current_time.tm_min
# 获取当前时间
current_time = time.localtime()
current_minute = current_time.tm_min
print(current_minute)
if current_minute in [0, 30]: # 判断是否是 新的30分钟了
if current_minute in [0, 30]: # 判断是否是 新的30分钟了
new_price_datas = self.get_price()
if new_price_datas:
logger.success("获取最新交易价格成功!!!")
else:
logger.info("获取最新价格有问题!!!")
self.kline_1 = self.is_bullish(kline_1)
self.kline_2 = self.is_bullish(kline_2)
new_price_datas1 = sorted(new_price_datas, key=lambda x: x["id"])
kline_1, kline_2, kline_3 = new_price_datas1[-3:]
self.check_signal(prev=kline_1, curr=kline_2)
self.kline_1 = self.is_bullish(kline_1)
self.kline_2 = self.is_bullish(kline_2)
self.direction, signal_key = self.check_signal(prev=kline_1, curr=kline_2)
if self.direction:
self.to_do_page()
else:
logger.warning(f"当前分钟:{current_minute},不符合》》》")
time.sleep(10)
if __name__ == '__main__':
WeexTransaction(
bit_id="8dcb4f744cf64ab190e465e153088515"
).action()
# bit_port = openBrowser(id="8dcb4f744cf64ab190e465e153088515")
# co = ChromiumOptions()
# co.set_local_port(port=bit_port)
#
# co = ChromiumOptions()
# co.set_local_port(bit_port)
#
# page = ChromiumPage(addr_or_opts=co)
#
# page.set.window.max()
# page.listen.start("public/quote/v1/getKlineV2")
#
# page.get(url="https://www.weeaxs.site/zh-CN/futures/demo-trading/ETH-SUSDT")
#
# for _ in range(10000):
# res = page.listen.wait() # 等待并获取一个数据包
#
# print(_)
# print(res.response.url)
#
# for data in res.response.body['data']["dataList"]:
# # 构建插入数据的字典
# insert_data = {
# 'id': int(data[4]),
# 'open': float(data[3]),
# 'high': float(data[1]),
# 'low': float(data[2]),
# 'close': float(data[0])
# }
#
# # 使用 INSERT OR REPLACE 插入或更新数据
# query = Weex30Copy.insert(**insert_data).on_conflict(
# conflict_target=[Weex30Copy.id],
# update=insert_data
# )
# query.execute()