dededdew
This commit is contained in:
30
test.py
30
test.py
@@ -1,9 +1,23 @@
|
||||
from logly import *
|
||||
import time
|
||||
import tkinter as tk
|
||||
from tkinter import messagebox
|
||||
|
||||
logger.add(
|
||||
"logs/app.log",
|
||||
rotation="daily", # 或 "hourly", "10MB"
|
||||
retention=7,
|
||||
async_write=True # 启用异步写入,不阻塞主线程
|
||||
)
|
||||
logger.success("jegferwgrewgerwg")
|
||||
def show_reminder():
|
||||
root = tk.Tk()
|
||||
root.withdraw() # 隐藏主窗口
|
||||
messagebox.showinfo("提醒", "现在是整点或 30 分啦,注意休息!")
|
||||
root.destroy()
|
||||
|
||||
while True:
|
||||
# 获取当前时间
|
||||
current_time = time.localtime()
|
||||
current_minute = current_time.tm_min
|
||||
print(current_minute)
|
||||
|
||||
if current_minute in [6, 30]:
|
||||
show_reminder()
|
||||
# 避免在同一分钟内重复提醒,等待一分钟
|
||||
time.sleep(60)
|
||||
else:
|
||||
# 如果不是 0 分或 30 分,每隔 10 秒检查一次
|
||||
time.sleep(10)
|
||||
@@ -1,4 +1,5 @@
|
||||
import json
|
||||
import time
|
||||
|
||||
import requests
|
||||
|
||||
@@ -27,7 +28,9 @@ class WeexTransaction:
|
||||
|
||||
self.page = None # 浏览器对象
|
||||
|
||||
self.start = None # 持仓状态
|
||||
self.start = 0 # 持仓状态 -1:做空,0:维持仓,1:做多
|
||||
self.kline_1 = None # 0:跌,1:涨
|
||||
self.kline_2 = None # 0:跌,1:涨
|
||||
|
||||
def openBrowser(self, ): # 直接指定ID打开窗口,也可以使用 createBrowser 方法返回的ID
|
||||
|
||||
@@ -70,6 +73,25 @@ class WeexTransaction:
|
||||
def is_bearish(self, c): # 阴线
|
||||
return float(c['close']) < float(c['open'])
|
||||
|
||||
def check_signal(self, prev, curr):
|
||||
"""
|
||||
包住形态信号判定(仅15分钟K线):
|
||||
- 前跌后涨包住 -> 做多
|
||||
- 前涨后跌包住 -> 做空
|
||||
"""
|
||||
p_open, p_close = float(prev['open']), float(prev['close'])
|
||||
c_open, c_close = float(curr['open']), float(curr['close'])
|
||||
|
||||
# 前跌后涨包住 -> 做多
|
||||
if is_bullish(curr) and is_bearish(prev) and c_open <= p_close and c_close >= p_open:
|
||||
return "long", "bear_bull_engulf"
|
||||
|
||||
# 前涨后跌包住 -> 做空
|
||||
if is_bearish(curr) and is_bullish(prev) and c_open >= p_close and c_close <= p_open:
|
||||
return "short", "bull_bear_engulf"
|
||||
|
||||
return None, None
|
||||
|
||||
def get_price(self):
|
||||
|
||||
for i in range(3):
|
||||
@@ -123,9 +145,19 @@ class WeexTransaction:
|
||||
logger.info("获取最新价格有问题!!!")
|
||||
|
||||
new_price_datas1 = sorted(new_price_datas, key=lambda x: x["id"])
|
||||
prev, curr, next_bar = new_price_datas1[-3:]
|
||||
kline_1, kline_2, kline_3 = new_price_datas1[-3:]
|
||||
|
||||
pass
|
||||
# 获取当前时间
|
||||
current_time = time.localtime()
|
||||
current_minute = current_time.tm_min
|
||||
print(current_minute)
|
||||
|
||||
if current_minute in [0, 30]: # 判断是否是 新的30分钟了
|
||||
|
||||
self.kline_1 = self.is_bullish(kline_1)
|
||||
self.kline_2 = self.is_bullish(kline_2)
|
||||
|
||||
self.check_signal(prev=kline_1, curr=kline_2)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user