dededdew
This commit is contained in:
28
test1.py
28
test1.py
@@ -1,2 +1,26 @@
|
||||
if 0:
|
||||
print(1)
|
||||
import time
|
||||
from tqdm import tqdm
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
# 获取当前时间的分钟数
|
||||
def get_current_minute():
|
||||
now = datetime.now()
|
||||
return now.minute
|
||||
|
||||
|
||||
# 计算进度
|
||||
def calculate_progress(minute):
|
||||
return minute % 30
|
||||
|
||||
|
||||
# 创建进度条
|
||||
with tqdm(total=30, desc="时间进度", unit="分钟") as pbar:
|
||||
while True:
|
||||
current_minute = get_current_minute()
|
||||
progress = calculate_progress(current_minute)
|
||||
# 重置进度条并更新到计算出的进度
|
||||
pbar.reset()
|
||||
pbar.update(progress)
|
||||
# 每秒更新一次进度条
|
||||
time.sleep(1)
|
||||
|
||||
@@ -3,9 +3,12 @@ import time
|
||||
|
||||
import requests
|
||||
|
||||
from tqdm import *
|
||||
from loguru import *
|
||||
from DrissionPage import *
|
||||
|
||||
from test1 import pbar
|
||||
|
||||
|
||||
def is_bullish(c): # 阳线
|
||||
return float(c['close']) > float(c['open'])
|
||||
@@ -32,6 +35,8 @@ class WeexTransaction:
|
||||
|
||||
self.direction = None # 信号类型
|
||||
|
||||
self.pbar = None # 进度条对象
|
||||
|
||||
def openBrowser(self, ): # 直接指定ID打开窗口,也可以使用 createBrowser 方法返回的ID
|
||||
|
||||
json_data = {
|
||||
@@ -155,12 +160,21 @@ class WeexTransaction:
|
||||
self.page.listen.start("public/quote/v1/getKlineV2")
|
||||
logger.success("浏览器开启抓包模式。。。")
|
||||
|
||||
self.pbar = tqdm(total=30) # 重置进度条
|
||||
|
||||
while True:
|
||||
|
||||
# 获取当前时间
|
||||
current_time = time.localtime()
|
||||
current_minute = current_time.tm_min
|
||||
|
||||
if current_minute < 30:
|
||||
self.pbar.reset()
|
||||
self.pbar.update(current_minute)
|
||||
else:
|
||||
self.pbar.reset()
|
||||
self.pbar.update(current_minute - 30)
|
||||
|
||||
if current_minute in [0, 30]: # 判断是否是 新的30分钟了
|
||||
|
||||
time.sleep(10)
|
||||
@@ -197,8 +211,7 @@ class WeexTransaction:
|
||||
if self.direction:
|
||||
self.to_do_page()
|
||||
|
||||
else:
|
||||
logger.warning(f"当前分钟:{current_minute},不符合》》》")
|
||||
self.pbar = tqdm(total=30) # 重置进度条
|
||||
|
||||
time.sleep(10)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user