diff --git a/models/database.db b/models/database.db index f1f8945..ccf1c6d 100644 Binary files a/models/database.db and b/models/database.db differ diff --git a/models/weex.py b/models/weex.py index 52d161e..5796f83 100644 --- a/models/weex.py +++ b/models/weex.py @@ -49,6 +49,17 @@ class Weex30(Model): database = db table_name = 'weex_30' +class Weex30Copy(Model): + id = IntegerField(primary_key=True) + open = FloatField(null=True) + high = FloatField(null=True) + low = FloatField(null=True) + close = FloatField(null=True) + + class Meta: + database = db + table_name = 'weex_30_copy1' + # 连接到数据库 db.connect() diff --git a/weex/自动化抓取数据.py b/weex/自动化抓取数据.py index 1b0103a..8fe8bf7 100644 --- a/weex/自动化抓取数据.py +++ b/weex/自动化抓取数据.py @@ -17,7 +17,7 @@ if __name__ == '__main__': page.set.window.max() - page.listen.start("https://http-gateway1.ngsvsfx.cn/api/v1/public/quote/v1/getKlineV2") + page.listen.start("public/quote/v1/getKlineV2") page.get(url="https://www.weeaxs.site/zh-CN/futures/ETH-USDT") diff --git a/weex交易/30分钟仿盘交易.py b/weex交易/30分钟仿盘交易.py new file mode 100644 index 0000000..27ab08d --- /dev/null +++ b/weex交易/30分钟仿盘交易.py @@ -0,0 +1,45 @@ +from DrissionPage import ChromiumPage, ChromiumOptions + +from bit_tools import openBrowser +from models.weex import Weex30Copy + +if __name__ == '__main__': + + bit_port = openBrowser(id="8dcb4f744cf64ab190e465e153088515") + + co = ChromiumOptions() + co.set_local_port(port=bit_port) + + co = ChromiumOptions() + co.set_local_port(bit_port) + + page = ChromiumPage(addr_or_opts=co) + + page.set.window.max() + + page.listen.start("public/quote/v1/getKlineV2") + + page.get(url="https://www.weeaxs.site/zh-CN/futures/demo-trading/ETH-SUSDT") + + for _ in range(10000): + res = page.listen.wait() # 等待并获取一个数据包 + + print(_) + print(res.response.url) + + for data in res.response.body['data']["dataList"]: + # 构建插入数据的字典 + insert_data = { + 'id': int(data[4]), + 'open': float(data[3]), + 'high': float(data[1]), + 'low': float(data[2]), + 'close': float(data[0]) + } + + # 使用 INSERT OR REPLACE 插入或更新数据 + query = Weex30Copy.insert(**insert_data).on_conflict( + conflict_target=[Weex30Copy.id], + update=insert_data + ) + query.execute() diff --git a/币安/test.py b/币安/test.py new file mode 100644 index 0000000..51b30e9 --- /dev/null +++ b/币安/test.py @@ -0,0 +1,13 @@ +from binance.client import Client + +if __name__ == '__main__': + + client = Client() + + # 获取ETHUSDT过去的K线数据,时间间隔为30分钟 + klines = client.get_historical_klines("ETHUSDT", Client.KLINE_INTERVAL_30MINUTE, "1 month ago UTC") + + # 打印K线数据 + for kline in klines: + print(kline) +# [1758542400000, '4181.63000000', '4190.00000000', '4169.17000000', '4184.14000000', '6409.29720000', 1758544199999, '26785429.32668800', 57484, '3256.65840000', '13611461.63871100', '0'] \ No newline at end of file