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