openfund-core 0.0.3__py3-none-any.whl → 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. core/Exchange.py +276 -0
  2. core/main.py +23 -0
  3. core/smc/SMCBase.py +130 -0
  4. core/smc/SMCFVG.py +86 -0
  5. core/smc/SMCLiquidity.py +7 -0
  6. core/smc/SMCOrderBlock.py +288 -0
  7. core/smc/SMCPDArray.py +77 -0
  8. core/smc/SMCStruct.py +290 -0
  9. core/smc/__init__.py +0 -0
  10. core/utils/OPTools.py +30 -0
  11. openfund_core-1.0.1.dist-info/METADATA +48 -0
  12. openfund_core-1.0.1.dist-info/RECORD +15 -0
  13. {openfund_core-0.0.3.dist-info → openfund_core-1.0.1.dist-info}/WHEEL +1 -1
  14. openfund_core-1.0.1.dist-info/entry_points.txt +3 -0
  15. openfund/core/__init__.py +0 -14
  16. openfund/core/api_tools/__init__.py +0 -16
  17. openfund/core/api_tools/binance_futures_tools.py +0 -23
  18. openfund/core/api_tools/binance_tools.py +0 -26
  19. openfund/core/api_tools/enums.py +0 -539
  20. openfund/core/base_collector.py +0 -72
  21. openfund/core/base_tool.py +0 -58
  22. openfund/core/factory.py +0 -97
  23. openfund/core/openfund_old/continuous_klines.py +0 -153
  24. openfund/core/openfund_old/depth.py +0 -92
  25. openfund/core/openfund_old/historical_trades.py +0 -123
  26. openfund/core/openfund_old/index_info.py +0 -67
  27. openfund/core/openfund_old/index_price_kline.py +0 -118
  28. openfund/core/openfund_old/klines.py +0 -95
  29. openfund/core/openfund_old/klines_qrr.py +0 -103
  30. openfund/core/openfund_old/mark_price.py +0 -121
  31. openfund/core/openfund_old/mark_price_klines.py +0 -122
  32. openfund/core/openfund_old/ticker_24hr_price_change.py +0 -99
  33. openfund/core/pyopenfund.py +0 -85
  34. openfund/core/services/um_futures_collector.py +0 -142
  35. openfund/core/sycu_exam/__init__.py +0 -1
  36. openfund/core/sycu_exam/exam.py +0 -19
  37. openfund/core/sycu_exam/random_grade_cplus.py +0 -440
  38. openfund/core/sycu_exam/random_grade_web.py +0 -404
  39. openfund/core/utils/time_tools.py +0 -25
  40. openfund_core-0.0.3.dist-info/LICENSE +0 -201
  41. openfund_core-0.0.3.dist-info/METADATA +0 -67
  42. openfund_core-0.0.3.dist-info/RECORD +0 -30
  43. {openfund/core/openfund_old → core}/__init__.py +0 -0
@@ -1,72 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import logging
4
- import csv
5
-
6
- from abc import abstractmethod
7
- from pathlib import Path
8
- from typing import TYPE_CHECKING
9
-
10
- from apscheduler.job import Job
11
-
12
- from openfund.core.pyopenfund import Openfund
13
- from openfund.core.factory import Factory
14
-
15
-
16
- logger = logging.getLogger(__name__)
17
-
18
-
19
- class Collector:
20
- def __init__(self, openfund: Openfund | None = None) -> None:
21
- self._openfund: Openfund = openfund
22
- if self._openfund is None:
23
- self._openfund = Factory.create_openfund()
24
- self._job: Job = None
25
-
26
- @property
27
- def openfund(self) -> Openfund:
28
- return self._openfund
29
-
30
- @abstractmethod
31
- def collect(self) -> None:
32
- raise NotImplementedError()
33
-
34
- @abstractmethod
35
- def start(self) -> int:
36
- raise NotImplementedError()
37
- # from apscheduler.schedulers.background import BlockingScheduler
38
-
39
- # apSchedule = BlockingScheduler()
40
- # self.openfund.scheduler.add_job(
41
- # func=self.collect, trigger="interval", minutes=5,seconds=5 id="um_futures_collector"
42
- # )
43
-
44
- def stop(self) -> int:
45
- if self._job is not None:
46
- self._job.remove()
47
- logger.debug(f"{self._job.name} is stop .")
48
- return 0
49
-
50
- def pause(self) -> int:
51
- if self._job is not None:
52
- self._job.pause()
53
- logger.debug(f"{self._job.name} is pause .")
54
- return 0
55
-
56
- def resume(self) -> int:
57
- if self._job is not None:
58
- self._job.resume()
59
- logger.debug(f"{self._job.name} is resume .")
60
- return 0
61
-
62
- def _write_to_csv(self, file: Path, listData: list) -> None:
63
-
64
- # 如果路径不存在,创建路径
65
- file.parent.mkdir(parents=True, exist_ok=True)
66
-
67
- with open(file, "a", newline="") as file:
68
- writer = csv.writer(file)
69
- # 时间戳倒序,插入文件尾部
70
- writer.writerows(sorted(listData, key=lambda x: x[0], reverse=True))
71
-
72
- logger.debug("2、{}条写入{}文件...".format(len(listData), file))
@@ -1,58 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import logging
4
-
5
- from pathlib import Path
6
-
7
- from typing import TYPE_CHECKING
8
-
9
- from poetry.utils.authenticator import Authenticator
10
- from binance.spot import Spot as Client
11
- from binance.um_futures import UMFutures as UMClient
12
-
13
- from openfund.core.pyopenfund import Openfund
14
- from openfund.core.factory import Factory
15
-
16
-
17
- logger = logging.getLogger(__name__)
18
-
19
-
20
- class Tool:
21
- def __init__(
22
- self, openfund: Openfund | None = None, toolname: str = "binance"
23
- ) -> None:
24
- self._openfund: Openfund = openfund
25
- if self._openfund is None:
26
- self._openfund = Factory.create_openfund()
27
-
28
- self._toolname = toolname
29
- self._password_manager = Authenticator(
30
- self._openfund._poetry.config
31
- )._password_manager
32
-
33
- self._client = None
34
- self._umclient = None
35
-
36
- @property
37
- def api_key(self) -> str:
38
- return self._password_manager.get_http_auth(self._toolname).get("username")
39
-
40
- @property
41
- def apk_secret(self) -> str:
42
- return self._password_manager.get_http_auth(self._toolname).get("password")
43
-
44
- @property
45
- def openfund(self) -> Openfund:
46
- return self._openfund
47
-
48
- @property
49
- def client(self) -> Client:
50
- if self._client is None:
51
- self._client = Client(self.api_key, self.apk_secret)
52
- return self._client
53
-
54
- @property
55
- def umclient(self) -> UMClient:
56
- if self._umclient is None:
57
- self._umclient = UMClient(self.api_key, self.apk_secret)
58
- return self._umclient
openfund/core/factory.py DELETED
@@ -1,97 +0,0 @@
1
- from __future__ import annotations
2
-
3
- import logging
4
-
5
- from pathlib import Path
6
- from typing import TYPE_CHECKING
7
-
8
- from poetry.factory import Factory as BaseFactory
9
- from openfund.core.pyopenfund import Openfund
10
-
11
-
12
- if TYPE_CHECKING:
13
- from poetry.poetry import Poetry
14
-
15
-
16
- logger = logging.getLogger(__name__)
17
- _APP_NAME = "pyopenfund"
18
-
19
-
20
- class Factory(BaseFactory):
21
- _openfund: Openfund = None
22
-
23
- def __init__(self) -> None:
24
- super().__init__()
25
- self._init_log()
26
-
27
- def create_poetry(
28
- self,
29
- cwd: Path | None = None,
30
- with_groups: bool = True,
31
- ) -> Poetry:
32
- poetry = super().create_poetry(cwd=cwd, with_groups=with_groups)
33
- return poetry
34
-
35
- @classmethod
36
- def create_openfund(
37
- cls,
38
- cwd: Path | None = None,
39
- with_groups: bool = True,
40
- ) -> Openfund:
41
- if cls._openfund is not None:
42
- return cls._openfund
43
-
44
- if cwd is None:
45
- cwd = Path.cwd()
46
-
47
- poetry = Factory().create_poetry(cwd=cwd, with_groups=with_groups)
48
- cls._openfund = Openfund(poetry)
49
- cls._openfund.scheduler.start()
50
- return cls._openfund
51
-
52
- def _init_log(self):
53
- from openfund.core.pyopenfund import user_log_path
54
-
55
- log_file = user_log_path(
56
- _APP_NAME, appauthor=False, ensure_exists=True
57
- ).resolve()
58
- log_file = (
59
- user_log_path(_APP_NAME, appauthor=False, ensure_exists=True)
60
- .joinpath("openfund-core.log")
61
- .resolve()
62
- )
63
- fileHandler = FileHandler(log_file)
64
- fileHandler.setFormatter(FileFormatter())
65
- console_handler = logging.StreamHandler()
66
- console_handler.setFormatter(FileFormatter())
67
- logging.basicConfig(
68
- level=logging.DEBUG,
69
- handlers=[console_handler, fileHandler],
70
- )
71
-
72
-
73
- from logging.handlers import TimedRotatingFileHandler
74
-
75
-
76
- class FileHandler(TimedRotatingFileHandler):
77
- def __init__(
78
- self,
79
- filename,
80
- when="midnight",
81
- interval=1,
82
- backupCount=7,
83
- encoding=None,
84
- delay=False,
85
- utc=False,
86
- ) -> None:
87
- super().__init__(filename, when, interval, backupCount, encoding, delay, utc)
88
-
89
-
90
- class FileFormatter(logging.Formatter):
91
-
92
- _format = "%(asctime)s - %(process)d | %(threadName)s | %(module)s.%(funcName)s:%(lineno)d - %(levelname)s -%(message)s"
93
-
94
- _datefmt = "%Y-%m-%d-%H:%M:%S" # 时间
95
-
96
- def __init__(self, fmt=_format, datefmt=_datefmt, style="%") -> None:
97
- super().__init__(fmt, datefmt, style)
@@ -1,153 +0,0 @@
1
- #!/usr/bin/env python
2
- import csv
3
- import logging
4
- import time
5
- import os
6
- import sys
7
-
8
-
9
- curPath = os.path.abspath(os.path.dirname(__file__))
10
- rootPath = os.path.split(curPath)[0]
11
- sys.path.append(rootPath)
12
- from datetime import datetime
13
-
14
- from binance.um_futures import UMFutures
15
- from binance.um_futures import UMFutures
16
- from binance.error import ClientError
17
-
18
- from libs.time_tools import format_timestamp
19
- from libs.file_tools import create_path
20
- from libs.prepare_env import get_api_key, get_path
21
- from libs import enums
22
-
23
- # 数据路径、日志路径
24
- data_path, log_path = get_path()
25
- # client
26
- um_futures_client = UMFutures()
27
- # 合同类型
28
- contractTypes = [type.value for type in enums.ContractType]
29
- # 币种类型
30
- # POOL = enums.CUR_SYMBOL_POOL
31
- POOL = [
32
- "BTCUSDT_240329",
33
- "BLURUSDT",
34
- "DYDXUSDT",
35
- "ETHBTC",
36
- "ETHBUSD",
37
- "ETHUSDT",
38
- "ETHUSDT_231229",
39
- "ETHUSDT_240329",
40
- "GMTBUSD",
41
- "GMTUSDT",
42
- "LTCBUSD",
43
- "LTCUSDT",
44
- "MATICBUSD",
45
- "MATICUSDT",
46
- "SOLBUSD",
47
- "SOLUSDT",
48
- ]
49
- interval = enums.KLINE_INTERVAL_5MINUTE
50
- limit = 1500
51
- errorLimit = 100
52
- sleepSec = 10
53
-
54
- # 历史截止数据开关
55
- hisSwitch = 0
56
- # hisSwitch 打开的情况下,抓取数据截止时间
57
- hisDateTime = 1653974399999
58
-
59
- for symbol in POOL:
60
- fileName = "{}/continuous_klines_{}_{}.log".format(
61
- log_path, symbol, format_timestamp(datetime.now().timestamp() * 1000)
62
- )
63
- # print(fileName)
64
- logging.basicConfig(
65
- format="%(asctime)s %(name)s:%(levelname)s:%(message)s",
66
- datefmt="%Y-%m-%d %H:%M:%S",
67
- level=logging.INFO,
68
- filename=fileName,
69
- )
70
- logging.info("{} symbol 开始 ++++++++++++++++++++++++++++ ".format(symbol))
71
- total = 0
72
- for contractType in contractTypes:
73
- latestRecords = 1
74
- records = 0 # 累计记录数
75
- queryTimes = 0 # 执行次数
76
- nextEndTime = 0
77
- errorCount = 0
78
- params = {"limit": limit}
79
- while latestRecords != 0: # 循环读取,直到记录为空
80
- queryTimes = queryTimes + 1
81
- if nextEndTime != 0:
82
- params = {"limit": limit, "endTime": nextEndTime}
83
-
84
- logging.info(
85
- "1、{}-{} 第{}次开始执行...".format(symbol, contractType, queryTimes)
86
- )
87
- listData = []
88
- try:
89
- listData = um_futures_client.continuous_klines(
90
- symbol, contractType, interval, **params
91
- )
92
- except KeyError as err:
93
- print("KeyError:", err)
94
- logging.error(err)
95
- break
96
- except ClientError as error:
97
- logging.error(
98
- "Found error. status: {}, error code: {}, error message: {}".format(
99
- error.status_code, error.error_code, error.error_message
100
- )
101
- )
102
- if error.error_code == -4144 and error.status_code == 400:
103
- break
104
- except Exception as e:
105
- print("Error:", e)
106
- logging.error(e)
107
- errorCount = errorCount + 1
108
- if errorCount > errorLimit:
109
- break
110
- else:
111
- time.sleep(sleepSec)
112
- continue
113
-
114
- latestRecords = len(listData)
115
- records = latestRecords + records
116
- logging.info("2、{}条写入文件...".format(latestRecords))
117
-
118
- path = "{}/continuous_klines/{}/{}/".format(data_path, symbol, contractType)
119
- create_path(path) # 不存在路径进行呢创建
120
-
121
- with open(
122
- "{}continuous_klines_{}_{}_{}.csv".format(
123
- path, symbol, contractType, interval
124
- ),
125
- "a",
126
- newline="",
127
- ) as file:
128
- writer = csv.writer(file)
129
- # 时间戳倒序,插入文件尾部
130
- writer.writerows(sorted(listData, key=lambda x: x[0], reverse=True))
131
-
132
- # 拿到最后一条记录后,获取close时间戳,变为下一次截止时间戳
133
- if latestRecords > 0:
134
- nextEndTime = (
135
- listData[0][0] - 1
136
- ) # -1 不和close时间戳相同,避免重新拉取重复数据
137
- errorCount = 0
138
- logging.info(
139
- "3、下次结束时间 {} {}".format(
140
- format_timestamp(nextEndTime), nextEndTime
141
- )
142
- )
143
-
144
- if nextEndTime <= hisDateTime and hisSwitch == 1:
145
- break
146
- else:
147
- logging.info("4、结束...")
148
-
149
- total = total + records
150
- logging.info("5、{} 抓取数据 {} 条记录...".format(symbol, records))
151
-
152
- logging.info("6、{} 抓取数据 {} 条记录...".format(symbol, total))
153
- logging.info("{} symbol --------------------------------- ".format(symbol))
@@ -1,92 +0,0 @@
1
- #!/usr/bin/env python
2
- import csv
3
- import time
4
- import os
5
- import sys
6
- import json
7
- import schedule
8
-
9
- curPath = os.path.abspath(os.path.dirname(__file__))
10
- rootPath = os.path.split(curPath)[0]
11
- sys.path.append(rootPath)
12
-
13
-
14
- from datetime import datetime
15
- from binance.um_futures import UMFutures
16
- from binance.error import ClientError
17
- from libs.time_tools import format_timestamp, format_date
18
- from libs.file_tools import create_path
19
- from libs.prepare_env import get_api_key, get_path
20
- from libs import enums
21
- from libs.log_tools import Logger
22
-
23
- data_path, log_path = get_path()
24
-
25
- um_futures_client = UMFutures()
26
-
27
- POOL = enums.NEW_SYMBOL_POLL
28
- interval = enums.KLINE_INTERVAL_5MINUTE
29
- # 历史截止数据开关
30
- hisSwitch = 0
31
- # hisSwitch 打开的情况下,抓取数据截止时间
32
- hisDateTime = 1653974399999
33
- # 发现异常后累计失败次数上限,超过后退出。
34
- errorLimit = 100
35
- # 异常后暂停秒数
36
- sleepSec = 10
37
- # 下次执行周期 5min
38
- nextTimeMin = 5
39
-
40
- app = "depth"
41
- logger = Logger(app).get_log()
42
-
43
-
44
- # logging.basicConfig(
45
- # format="%(asctime)s %(name)s:%(levelname)s:%(message)s",
46
- # datefmt="%Y-%m-%d %H:%M:%S",
47
- # level=logging.INFO,
48
- # filename="{}/{}_{}.log".format(
49
- # log_path, app, format_timestamp(datetime.now().timestamp() * 1000)
50
- # ),
51
- # )
52
- def job():
53
- logger.info("{} app 开始 ++++++++++++++++++++++++++++ ".format(app))
54
- latestRecords = 1
55
- params = {"limit": 1000}
56
- for symbol in POOL:
57
- queryTimes = queryTimes + 1
58
- logger.info("1、{}第{}次开始执行...".format(symbol, queryTimes))
59
- listData = []
60
- try:
61
- listData = um_futures_client.depth(symbol, **params)
62
- except Exception as e:
63
- logger.error(e)
64
- time.sleep(sleepSec)
65
- continue
66
-
67
- latestRecords = len(listData)
68
- records = latestRecords + records
69
- logger.info("2、{}条写入文件...".format(latestRecords))
70
-
71
- path = "{}/{}/".format(data_path, app)
72
- create_path(path) # 不存在路径进行呢创建
73
-
74
- with open(
75
- "{}{}_{}.txt".format(
76
- path,
77
- app,
78
- format_date(datetime.now().timestamp() * 1000),
79
- ),
80
- "a",
81
- ) as file:
82
- file.writelines(json.dumps(listData) + "\r\n")
83
-
84
- logger.info("3、本次 {} 抓取数据 {} 条记录...".format(app, records))
85
- logger.info("{} app --------------------------------- ".format(app))
86
-
87
-
88
- if __name__ == "__main__":
89
- schedule.every(nextTimeMin).minutes.do(job)
90
- logger.info("Schedule Starting {0}min ...... ".format(nextTimeMin))
91
- while True:
92
- schedule.run_pending() # 运行所有可运行的任务
@@ -1,123 +0,0 @@
1
- #!/usr/bin/env python
2
- import csv
3
- import logging
4
- import time
5
- import os
6
- import sys
7
-
8
- from datetime import datetime
9
-
10
- from binance.lib.utils import config_logging
11
- from binance.um_futures import UMFutures
12
- from binance.error import ClientError, Error
13
-
14
- import enums as enums
15
- from time_tools import format_timestamp
16
- from file_tools import create_path
17
- from prepare_env import get_api_key, get_path
18
-
19
- # config_logging(logging, logging.INFO)
20
- api_key, api_secret = get_api_key()
21
- um_futures_client = UMFutures(key=api_key)
22
-
23
- data_path, log_path = get_path()
24
- # POOL = ['AAVEUSDT','BTCBUSD', 'BTCDOMUSDT', 'BTCSTUSDT', 'BTCUSDT', 'BTCUSDT_231229', 'BTCUSDT_240329',
25
- # 'BLURUSDT', 'DYDXUSDT', 'ETHBTC', 'ETHBUSD', 'ETHUSDT', 'ETHUSDT_231229', 'ETHUSDT_240329',
26
- # 'GMTBUSD', 'GMTUSDT', 'LTCBUSD', 'LTCUSDT', 'MATICBUSD', 'MATICUSDT', 'SOLBUSD', 'SOLUSDT',
27
- # ]
28
- POOL = ["GMTBUSD"]
29
-
30
- # 历史截止数据开关
31
- hisSwitch = 1
32
- # hisSwitch 打开的情况下,抓取数据截止时间
33
- hisDateTime = 1653974399999
34
-
35
- for symbol in POOL:
36
- logging.basicConfig(
37
- format="%(asctime)s %(name)s:%(levelname)s:%(message)s",
38
- datefmt="%Y-%m-%d %H:%M:%S",
39
- level=logging.INFO,
40
- filename="{}/{}_historical_trades_{}.log".format(
41
- log_path, symbol, format_timestamp(datetime.now().timestamp() * 1000)
42
- ),
43
- )
44
- logging.info("{} symbol 开始 ++++++++++++++++++++++++++++ ".format(symbol))
45
-
46
- latestRecords = 1
47
- records = 0 # 累计记录数
48
- queryTimes = 0 # 执行次数
49
- nextKey = 0
50
- params = {"limit": 1000}
51
-
52
- while latestRecords != 0: # 循环读取,直到记录为空
53
- queryTimes = queryTimes + 1
54
- if nextKey != 0:
55
- params = {"limit": 1000, "fromId": nextKey}
56
-
57
- logging.info("1、{}第{}次开始执行...".format(symbol, queryTimes))
58
- listData = []
59
- try:
60
- listData = um_futures_client.historical_trades(symbol, **params)
61
- # except ClientError as error:
62
- # logging.error(
63
- # "Found error. status: {}, error code: {}, error message: {}".format(
64
- # error.status_code, error.error_code, error.error_message
65
- # )
66
- # )
67
- # time.sleep(30)
68
- # continue
69
- # except ProxyError as error:
70
- # logging.error(
71
- # "Found error. error code: {}, error message: {}".format(
72
- # error, error.error_message
73
- # )
74
- # )
75
- # time.sleep(10)
76
- # continue
77
- except Exception as e:
78
- print("Error:", e)
79
- logging.error(e)
80
- time.sleep(10)
81
- continue
82
- # listData 结构
83
- # [
84
- # {
85
- # "id": 28457,
86
- # "price": "4.00000100",
87
- # "qty": "12.00000000",
88
- # "quoteQty": "8000.00",
89
- # "time": 1499865549590,
90
- # "isBuyerMaker": true,
91
- # }
92
- # ]
93
- latestRecords = len(listData)
94
- records = latestRecords + records
95
- logging.info("2、{}条写入文件...".format(latestRecords))
96
-
97
- path = "{}/historical_trades/{}/".format(data_path, symbol)
98
-
99
- create_path(path) # 不存在路径进行呢创建
100
-
101
- with open(
102
- "{}/{}_historical_trades.csv".format(path, symbol), "a", newline=""
103
- ) as file:
104
- writer = csv.writer(file)
105
- # 时间戳倒序,插入文件尾部
106
- writer.writerows(sorted(listData, key=lambda x: x["id"], reverse=True))
107
-
108
- # 拿到最后一条记录后,获取close时间戳,变为下一次截止时间戳
109
- if latestRecords > 0:
110
- first = listData[0]
111
- nextKey = first["id"] - 1000
112
- curTime = first["time"]
113
- logging.info("3、下个Key {} {}".format(format_timestamp(curTime), nextKey))
114
- errorCount = 0
115
- if curTime <= hisDateTime and hisSwitch == 1:
116
- break
117
- else:
118
- logging.info("4、结束...")
119
-
120
- time.sleep(0.01)
121
-
122
- logging.info("5、{} 抓取数据 {} 条记录...".format(symbol, records))
123
- logging.info("{} symbol --------------------------------- ".format(symbol))
@@ -1,67 +0,0 @@
1
- #!/usr/bin/env python
2
- import csv
3
- import time
4
- import os
5
- import sys
6
- import json
7
- import schedule
8
-
9
- curPath = os.path.abspath(os.path.dirname(__file__))
10
- rootPath = os.path.split(curPath)[0]
11
- sys.path.append(rootPath)
12
-
13
-
14
- from datetime import datetime
15
- from binance.um_futures import UMFutures
16
- from binance.error import ClientError
17
- from utils.time_tools import format_timestamp, format_date, format_date_to
18
- from utils.file_tools import create_path
19
- from utils.prepare_env import get_api_key, get_path
20
- from utils import enums
21
- from utils.log_tools import Logger
22
-
23
- data_path, log_path = get_path()
24
- um_futures_client = UMFutures()
25
-
26
- # 下次执行周期 5min
27
- nextTimeMin = 5
28
-
29
- app = "index_info"
30
- logger = Logger(app).get_log()
31
-
32
-
33
- def job():
34
- logger.info("{} app 开始 ++++++++++++++++++++++++++++ ".format(app))
35
- listData = []
36
- try:
37
- listData = um_futures_client.index_info()
38
- except Exception as e:
39
- print("Error:", e)
40
- logger.error(e)
41
-
42
- latestRecords = len(listData)
43
-
44
- path = "{}/{}/".format(data_path, app)
45
- create_path(path) # 不存在路径进行呢创建
46
-
47
- with open(
48
- "{}{}_{}.txt".format(
49
- path,
50
- app,
51
- format_date(datetime.now().timestamp() * 1000),
52
- ),
53
- "a",
54
- ) as file:
55
- file.writelines(
56
- json.dumps(sorted(listData, key=lambda x: x["symbol"])) + "\r\n"
57
- )
58
-
59
- logger.info("1、本次 {} 抓取数据 {} 条记录...".format(app, records))
60
- logger.info("{} app --------------------------------- ".format(app))
61
-
62
-
63
- if __name__ == "__main__":
64
- schedule.every(nextTimeMin).minutes.do(job)
65
- logger.info("Schedule Starting {0}min ...... ".format(nextTimeMin))
66
- while True:
67
- schedule.run_pending() # 运行所有可运行的任务