diff --git a/1.json b/1.json index 248f3b9..18afde3 100644 --- a/1.json +++ b/1.json @@ -1,62 +1,31 @@ { - 'id': '681146715025178980', - 'accountId': '667375883530535268', - 'coinId': '64', - 'contractId': '20000002', - 'marginMode': 'SHARED', - 'separatedMode': 'COMBINED', - 'separatedOpenOrderId': '0', - 'positionSide': 'LONG', - 'orderSide': 'BUY', - 'price': '0.00', - 'size': '2.680', - 'clientOrderId': 'f57f5877-5af4-42d6-adad-5d88457b65ca', - 'type': 'MARKET', - 'timeInForce': 'IMMEDIATE_OR_CANCEL', - 'reduceOnly': False, - 'triggerPrice': '0', - 'triggerPriceType': 'UNKNOWN_PRICE_TYPE', - 'orderSource': 'WEB', - 'openTpslParentOrderId': '0', - 'openTpParam': None, - 'openSlParam': None, - 'extraType': '', - 'extraDataJson': '{"appVersion":"2.0.1","terminalType":"1"}', - 'leverage': '100', - 'takerFeeRate': '0.0008', - 'makerFeeRate': '0.0002', - 'feeDiscount': '1', - 'liquidateFeeRate': '0.01', - 'liquidateType': 'UNKNOWN_LIQUIDATE_TYPE', - 'legacyOrderDirection': 'OPEN_LONG', - 'legacyOrderDirectionDesc': '开多仓', - 'withoutMatchFillSize': '0', - 'withoutMatchFillValue': '0', - 'withoutMatchPeerAccountId': '0', - 'withoutMatchPeerOrderId': '0', - 'status': 'FILLED', - 'matchSequenceId': '2944106434', - 'triggerTime': '0', - 'triggerPriceTime': '0', - 'triggerPriceValue': '0', - 'cancelReason': 'UNKNOWN_ORDER_CANCEL_REASON', - 'latestFillPrice': '3420.63', - 'maxFillPrice': '3420.63', - 'minFillPrice': '3420.63', - 'cumFillSize': '2.680', - 'cumFillValue': '9167.28840', - 'cumFillFee': '7.33383072', - 'cumLiquidateFee': '0', - 'cumRealizePnl': '0', - 'createdTime': '1762398031956', - 'updatedTime': '1762398031962', - 'fallback': False, - 'positionTpsl': False, - 'setOpenTp': False, - 'setOpenSl': False, - 'liquidate': False, - 'deleverage': False, - 'withoutMatch': False, - 'closeAllPosition': False, - 'closeFullPositionTpSl': False + 'vs': 'K5K7WsN820mZ9m9C8DH97HODDqzNj6vx', + 'sec-ch-ua-platform': '"Windows"', + 'language': 'zh_CN', + 'sec-ch-ua': '"Not;A=Brand";v="99", "Google Chrome";v="139", "Chromium";v="139"', + 'sec-ch-ua-mobile': '?0', + 'appVersion': '2.0.1', + 'Accept': 'application/json, text/plain, */*', + 'locale': 'zh_CN', + 'terminalCode': 'ea778f2af8f3a418595f4993fe0ed949', + 'Referer': 'https://www.weeaxs.site/', + 'X-SIG': 'fd2c7a52262066131ef4a118122d23e0', + 'sidecar': '013199792959396ff5b6c81006f3a12ad867af9972d26e231d2dc0e113c21d5d95', + 'X-TIMESTAMP': '1762421152641', + 'bundleid': '', + 'U-TOKEN': 'eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiI4MjE2MDlhOS1kMDI3LTRiOTAtOTU0OC1iZGU3YTlmNmRiOWMxMzczNjgzNjU1IiwidWlkIjoidEQzQ1FIaFJUblVYcm5MNFNwckw3UT09Iiwic3ViIjoieXgyMDI1KioqKkBnbWFpbC5jb20iLCJpcCI6IllXb3dNNkVVWnYzamdjOTkwUHVHUFE9PSIsImRpZCI6InVxSnQ1N1N2SVBZcE5oM1MzU3VxcktCVERiaHBoeTN6S2VyMmZVNnF3MktnMk12cVptaUhFNmJ0YSt0OUgrcUEiLCJzdHMiOjAsImlhdCI6MTc2MjQwOTc3NywiZXhwIjoxNzcwMTg1Nzc3LCJwdXNoaWQiOiJvTmpMNm1ab2h4T203V3ZyZlIvcWdBPT0iLCJhdGwiOiIwIiwiaXNzIjoidXBleCJ9.idUb4bjGwoDy2MRZWmaIuNZAwCRAos6t6nt4sAZBw_Urg2Jtuz5sEZQYnZxx0fczg7RG8zm0bzeAqoIRHXWLSEQs366HA55bAIcz_GM12Wik7-zWZ_CVz5VqTVCO1xUUfRX7a-qRB6HfgdUu_f-rlqG8U8l__65sWhEtDZ2mJNk', + 'terminaltype': '1', + 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36', + 'traceId': '869c997d-29cd-490b-b63c-4a95fdff5f83', + ':authority': 'http-gateway2.ngsvsfx.cn', + ':method': 'GET', + ':path': '/api/v1/public/quote/v1/getKlineV2?contractId=10000002&productCode=cmt_ethusdt&priceType=LAST_PRICE&klineType=MINUTE_30&limit=300&timeZone=string&languageType=1&sign=SIGN', + ':scheme': 'https', + 'accept-encoding': 'gzip, deflate, br, zstd', + 'accept-language': 'fi', + 'origin': 'https://www.weeaxs.site', + 'priority': 'u=1, i', + 'sec-fetch-dest': 'empty', + 'sec-fetch-mode': 'cors', + 'sec-fetch-site': 'cross-site' } diff --git a/test.py b/test.py index 27f4154..1dbf522 100644 --- a/test.py +++ b/test.py @@ -1,5 +1,65 @@ -import datetime +import requests -# 获取当前日期和时间 -now = datetime.datetime.now() -print("当前日期和时间:", now) \ No newline at end of file +headers = { + 'accept': 'application/json, text/plain, */*', + 'accept-language': 'fi', + 'appversion': '2.0.1', + 'bundleid': '', + 'cache-control': 'no-cache', + 'content-type': 'application/json', + 'language': 'zh_CN', + 'locale': 'zh_CN', + 'origin': 'https://www.weeaxs.site', + 'pragma': 'no-cache', + 'priority': 'u=1, i', + 'referer': 'https://www.weeaxs.site/', + 'sec-ch-ua': '"Not;A=Brand";v="99", "Google Chrome";v="139", "Chromium";v="139"', + 'sec-ch-ua-mobile': '?0', + 'sec-ch-ua-platform': '"Windows"', + 'sec-fetch-dest': 'empty', + 'sec-fetch-mode': 'cors', + 'sec-fetch-site': 'cross-site', + 'sidecar': '0178049a0185f33762dafde8f7cb8867abe35beee750cbfef6f36c10796b5e4696', + 'terminalcode': 'ea778f2af8f3a418595f4993fe0ed949', + 'terminaltype': '1', + 'traceid': '6422ff55-de8a-4964-9828-59a1b7b76734', + 'u-token': 'eyJhbGciOiJSUzI1NiJ9.eyJqdGkiOiI4MjE2MDlhOS1kMDI3LTRiOTAtOTU0OC1iZGU3YTlmNmRiOWMxMzczNjgzNjU1IiwidWlkIjoidEQzQ1FIaFJUblVYcm5MNFNwckw3UT09Iiwic3ViIjoieXgyMDI1KioqKkBnbWFpbC5jb20iLCJpcCI6IllXb3dNNkVVWnYzamdjOTkwUHVHUFE9PSIsImRpZCI6InVxSnQ1N1N2SVBZcE5oM1MzU3VxcktCVERiaHBoeTN6S2VyMmZVNnF3MktnMk12cVptaUhFNmJ0YSt0OUgrcUEiLCJzdHMiOjAsImlhdCI6MTc2MjQwOTc3NywiZXhwIjoxNzcwMTg1Nzc3LCJwdXNoaWQiOiJvTmpMNm1ab2h4T203V3ZyZlIvcWdBPT0iLCJhdGwiOiIwIiwiaXNzIjoidXBleCJ9.idUb4bjGwoDy2MRZWmaIuNZAwCRAos6t6nt4sAZBw_Urg2Jtuz5sEZQYnZxx0fczg7RG8zm0bzeAqoIRHXWLSEQs366HA55bAIcz_GM12Wik7-zWZ_CVz5VqTVCO1xUUfRX7a-qRB6HfgdUu_f-rlqG8U8l__65sWhEtDZ2mJNk', + 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36', + 'vs': 'M5l7PKl8QsOHCx9h9Zfl7mYWFhOVX6Rk', + 'x-sig': 'cedfb62ec95bc1f6aef8393db086af0b', + 'x-timestamp': '1762421067193', +} + +json_data = { + 'filterCoinIdList': [ + 2, + ], + 'filterContractIdList': [], + 'filterOrderStatusList': [ + 'CANCELED', + 'FILLED', + ], + 'filterOrderTypeList': [], + 'languageType': 1, + 'limit': 20, + 'sign': 'SIGN', + 'timeZone': 'string', +} + +response = requests.post( + 'https://http-gateway2.ngsvsfx.cn/api/v1/private/order/v2/getHistoryOrderPage', + headers=headers, + json=json_data, +) + +for i in response.json()["data"]["dataList"]: + print(i) + +# Note: json_data will not be serialized by requests +# exactly as it was in the original request. +# data = '{"filterCoinIdList":[2],"filterContractIdList":[],"filterOrderStatusList":["CANCELED","FILLED"],"filterOrderTypeList":[],"languageType":1,"limit":20,"sign":"SIGN","timeZone":"string"}' +# response = requests.post( +# 'https://http-gateway2.ngsvsfx.cn/api/v1/private/order/v2/getHistoryOrderPage', +# headers=headers, +# data=data, +# ) diff --git a/weex交易/30分钟盘交易.py b/weex交易/30分钟盘交易.py index e2f74e3..2941f44 100644 --- a/weex交易/30分钟盘交易.py +++ b/weex交易/30分钟盘交易.py @@ -3,14 +3,17 @@ import json import hmac import time import base64 +import random import hashlib import datetime -import requests from tqdm import * from loguru import * + from DrissionPage import * + from bs4 import BeautifulSoup +from curl_cffi import requests def is_bullish(c): # 阳线 @@ -45,6 +48,7 @@ class WeexTransaction: self.direction = None # 信号类型 self.pbar = None # 进度条对象 + self.session = requests.Session() # 接口请求对象 def get_signature(self, timestamp): # 将时间戳和密钥拼接 @@ -139,12 +143,24 @@ class WeexTransaction: return None, None def get_price(self): + params = { + 'contractId': '10000002', + 'productCode': 'cmt_ethusdt', + 'priceType': 'LAST_PRICE', + 'klineType': 'MINUTE_30', + 'limit': '300', + 'timeZone': 'string', + 'languageType': '1', + 'sign': 'SIGN', + } for i in range(3): try: logger.info(f"获取最新数据:{i + 1}次。。。") - self.mn_tab.get(url="https://http-gateway2.ngsvsfx.cn/api/v1/public/quote/v1/getKlineV2") - res = self.mn_tab.listen.wait(timeout=15) # 等待并获取一个数据包 + res = self.session.get( + url='https://http-gateway2.ngsvsfx.cn/api/v1/public/quote/v1/getKlineV2', + params=params, + ) datas = [] if res: @@ -253,6 +269,88 @@ class WeexTransaction: return False + def get_start(self, ): + + json_data = { + 'filterCoinIdList': [ + 2, + ], + 'filterContractIdList': [], + 'filterOrderStatusList': [ + 'CANCELED', + 'FILLED', + ], + 'filterOrderTypeList': [], + 'languageType': 1, + 'limit': 20, + 'sign': 'SIGN', + 'timeZone': 'string', + } + + response = requests.post( + 'https://http-gateway2.ngsvsfx.cn/api/v1/private/order/v2/getHistoryOrderPage', + headers=self.weex_headers, + json=json_data, + ) + + for i in response.json()["data"]["dataList"]: + print(i) + + def get_user_data(self): + self.mn_tab = self.page.new_tab() + self.mn_tab.listen.start("https://gateway2.ngsvsfx.cn/v1/user/overview/userinfo") + + self.mn_tab.get(url="https://www.weeaxs.site/zh-CN/futures/ETH-USDT") # 打开网页 + res = self.mn_tab.listen.wait(timeout=15) # 等待并获取一个数据包 + + if res: + self.weex_headers = res.request.headers + self.session.headers.update(self.weex_headers) + self.mn_tab.close() + + return True + + self.mn_tab.close() + return False + + def get_start(self): + json_data = { + 'filterCoinIdList': [ + 2, + ], + 'filterContractIdList': [], + 'filterOrderStatusList': [ + 'CANCELED', + 'FILLED', + ], + 'filterOrderTypeList': [], + 'languageType': 1, + 'limit': 20, + 'sign': 'SIGN', + 'timeZone': 'string', + } + + response = self.session.post( + 'https://http-gateway2.ngsvsfx.cn/api/v1/private/order/v2/getHistoryOrderPage', + json=json_data, + ) + + data = [] + for i in response.json()["data"]["dataList"]: + print(i) + + data.append({ + "id":int(i["createdTime"]), + "start": i["legacyOrderDirectionDesc"] + }) + + new_data = sorted(data, key=lambda x: x["id"]) + if new_data[-1]["data1"] == "开多仓": + self.start = 1 + elif new_data[-1]["data1"] == "开空仓": + self.start = -1 + + def action(self): # 获取比特端口 if self.openBrowser(): @@ -273,12 +371,6 @@ class WeexTransaction: else: logger.info('关闭多余标签页失败!!!') - self.mn_tab = self.page.new_tab() - self.mn_tab.listen.start("public/quote/v1/getKlineV2") - logger.success("浏览器开启抓包模式。。。") - - self.mn_tab.get(url="https://www.weeaxs.site/zh-CN/futures/ETH-USDT") # 打开网页 - self.pbar = tqdm(total=30, desc="等待时间中", ncols=80) # desc:进度条说明,ncols:长度 while True: @@ -297,12 +389,17 @@ class WeexTransaction: time.sleep(10) continue - new_price_datas = self.get_price() - if new_price_datas: - logger.success("获取最新交易价格成功!!!") - else: - logger.info("获取最新价格有问题!!!") - continue + new_price_datas = None + for i in range(3): + new_price_datas = self.get_price() + if new_price_datas: + logger.success("获取最新交易价格成功!!!") + else: + + self.send_dingtalk_message( + message_content=f"真实盘:{datetime.datetime.now()},获取最新价格有问题,重新获取用户信息!!!") + + self.get_user_data() new_price_datas1 = sorted(new_price_datas, key=lambda x: x["id"]) self.kline_1, self.kline_2, self.kline_3 = new_price_datas1[-3:] @@ -344,8 +441,11 @@ class WeexTransaction: try: self.to_do_page() except Exception as e: - self.send_dingtalk_message( - message_content=f"真实盘:{datetime.datetime.now()},{e}") + while True: + self.send_dingtalk_message( + message_content=f"真实盘:{datetime.datetime.now()},{e}") + + time.sleep(random.randint(5, 25)) self.pbar.reset() # 重置进度条 self.send_dingtalk_message(