haha
This commit is contained in:
@@ -37,7 +37,7 @@ class WeexOneThirdStrategy(WeexFuturesTransaction):
|
|||||||
self.pbar = tqdm(total=5, desc="等待5分钟K线", ncols=80)
|
self.pbar = tqdm(total=5, desc="等待5分钟K线", ncols=80)
|
||||||
self.min_body_size = 0.1
|
self.min_body_size = 0.1
|
||||||
self.min_shadow_pct = 0.01
|
self.min_shadow_pct = 0.01
|
||||||
self.check_interval = 3
|
self.check_interval = 5
|
||||||
self.position_ratio = 100 # 开仓金额 = 余额 / position_ratio
|
self.position_ratio = 100 # 开仓金额 = 余额 / position_ratio
|
||||||
self.last_trigger_kline_id: Optional[int] = None
|
self.last_trigger_kline_id: Optional[int] = None
|
||||||
self.last_trigger_direction: Optional[str] = None
|
self.last_trigger_direction: Optional[str] = None
|
||||||
@@ -156,7 +156,7 @@ class WeexOneThirdStrategy(WeexFuturesTransaction):
|
|||||||
|
|
||||||
# ------------------------- 主循环 -------------------------
|
# ------------------------- 主循环 -------------------------
|
||||||
def action(self) -> None:
|
def action(self) -> None:
|
||||||
|
n = 0
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
@@ -169,10 +169,14 @@ class WeexOneThirdStrategy(WeexFuturesTransaction):
|
|||||||
logger.info("TGE 浏览器已打开")
|
logger.info("TGE 浏览器已打开")
|
||||||
self.close_extra_tabs()
|
self.close_extra_tabs()
|
||||||
self.page.get(url=Config.TRADING_URL)
|
self.page.get(url=Config.TRADING_URL)
|
||||||
time.sleep(2)
|
time.sleep(self.check_interval)
|
||||||
if not self._get_token():
|
|
||||||
self.ding("获取 token 失败", error=True)
|
if n == 0 or random.randint(1,11)> 6:
|
||||||
return
|
n = 1
|
||||||
|
if not self._get_token():
|
||||||
|
self.ding("获取 token 失败", error=True)
|
||||||
|
return
|
||||||
|
|
||||||
self.click_safe('x:(//button[normalize-space(text()) = "市价"])')
|
self.click_safe('x:(//button[normalize-space(text()) = "市价"])')
|
||||||
logger.info("WEEX 三分之一策略(5分钟K线)开始监测")
|
logger.info("WEEX 三分之一策略(5分钟K线)开始监测")
|
||||||
|
|
||||||
|
|||||||
10
weex/框架.py
10
weex/框架.py
@@ -81,9 +81,9 @@ class WeexFuturesTransaction:
|
|||||||
limit: int = Config.KLINE_LIMIT,
|
limit: int = Config.KLINE_LIMIT,
|
||||||
) -> Optional[List[Dict]]:
|
) -> Optional[List[Dict]]:
|
||||||
"""获取 K 线,返回 [{'id', 'open', 'high', 'low', 'close'}, ...],按 id 升序。请求前需已取 token。"""
|
"""获取 K 线,返回 [{'id', 'open', 'high', 'low', 'close'}, ...],按 id 升序。请求前需已取 token。"""
|
||||||
if not self._get_token():
|
# if not self._get_token():
|
||||||
logger.error("获取 token 失败,无法拉取 K 线")
|
# logger.error("获取 token 失败,无法拉取 K 线")
|
||||||
return None
|
# return None
|
||||||
params = {
|
params = {
|
||||||
"contractId": contract_id,
|
"contractId": contract_id,
|
||||||
"productCode": product_code,
|
"productCode": product_code,
|
||||||
@@ -153,8 +153,8 @@ class WeexFuturesTransaction:
|
|||||||
|
|
||||||
def get_position_status(self) -> bool:
|
def get_position_status(self) -> bool:
|
||||||
"""从成交历史解析持仓方向,更新 self.start (-1/0/1),成功返回 True"""
|
"""从成交历史解析持仓方向,更新 self.start (-1/0/1),成功返回 True"""
|
||||||
if not self._get_token():
|
# if not self._get_token():
|
||||||
return False
|
# return False
|
||||||
payload = {
|
payload = {
|
||||||
"filterContractIdList": [10000002],
|
"filterContractIdList": [10000002],
|
||||||
"limit": 100,
|
"limit": 100,
|
||||||
|
|||||||
Reference in New Issue
Block a user