Skip to content

Commit 2484f61

Browse files
author
min
committed
feat: add some storege fuc and pypi publish
1 parent 0b9d046 commit 2484f61

37 files changed

+1137
-676
lines changed

.github/workflows/python-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
python-version: ["3.8", "3.12"]
19+
python-version: ["3.10", "3.12"]
2020

2121
steps:
2222
- uses: actions/checkout@v3

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ dist/
2525
# Ignore .env file
2626
.env
2727

28-
# Ignore .env.template file
29-
!.env.template
30-
3128
# Ignore mypy cache
3229
.mypy_cache/
30+
31+
# Ignore data directory
32+
/data/

README.md

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
## 安装
1515

1616
```bash
17-
pip install crypto-data
17+
pip install cryptoservice
1818
```
1919

2020
## 快速开始
@@ -25,32 +25,80 @@ pip install crypto-data
2525
# 根目录.env 文件 建议的token保存方式
2626
BINANCE_API_KEY=your_api_key
2727
BINANCE_API_SECRET=your_api_secret
28+
# 使用时
2829
```
29-
30-
2. 基本使用:
31-
3230
```python
33-
from crypto_data import BinanceClientFactory
34-
from crypto_data import MarketDataService
31+
# 使用时这样引入
32+
import os
3533
from dotenv import load_dotenv
3634

3735
load_dotenv()
3836
api_key = os.getenv("BINANCE_API_KEY")
3937
api_secret = os.getenv("BINANCE_API_SECRET")
38+
```
39+
40+
2. 基本使用:
41+
42+
```python
43+
from cryptoservice import MarketDataService
44+
45+
# 创建市场数据服务实例
46+
service = MarketDataService(api_key, api_secret)
47+
```
48+
49+
3. 获取数据:
50+
51+
```python
52+
# 获取单个交易对的行情数据
53+
ticker = service.get_ticker("BTCUSDT")
54+
```
55+
56+
```python
57+
# 获取排名靠前的币种数据
58+
top_coins = service.get_top_coins(
59+
limit=10,
60+
sort_by=SortBy.QUOTE_VOLUME,
61+
quote_asset="USDT"
62+
)
63+
```
4064

41-
# 除了现有的功能,使用者也可以提feature commit,merge进主线发包就可以用了
65+
```python
66+
# 获取市场概况
67+
summary = service.get_market_summary(
68+
symbols=["BTCUSDT", "ETHUSDT"],
69+
interval="1d"
70+
)
71+
```
4272

43-
# 创建客户端
44-
client = BinanceClientFactory.create_client(api_key, api_secret)
73+
```python
74+
# 获取历史行情数据
75+
historical_data = service.get_historical_data(
76+
symbol="BTCUSDT",
77+
start_time="20240101",
78+
end_time="20240102",
79+
interval="1h"
80+
)
81+
```
4582

46-
# 通过客户端获取市场数据
47-
# 例如获取BTCUSDT的行情数据
48-
data = client.somet_other_way(...).A(...).B(...).C("BTCUSDT")
83+
```python
84+
# 获取订单簿数据
85+
orderbook = service.get_orderbook(
86+
symbol="BTCUSDT",
87+
limit=100
88+
)
89+
```
4990

50-
# MarketDataService 是服务层,封装了一些常用的功能
51-
# 通过MarketDataService 获取市场数据 例如获取BTCUSDT的行情数据
52-
data = MarketDataService(client).get_ticker("BTCUSDT")
91+
```python
92+
# 获取永续合约历史数据
93+
perpetual_data = service.get_perpetual_data(
94+
symbols=["BTCUSDT", "ETHUSDT"],
95+
start_time="20240101",
96+
end_time="20240102",
97+
freq="1h",
98+
store=True # 是否存储数据
99+
)
53100
```
101+
除了现有的功能,使用者也可以提feature commit,merge进主线发包就可以用了
54102

55103
## 开发环境设置
56104

@@ -81,7 +129,7 @@ pre-commit install
81129
```
82130
Xdata/
83131
├── src/
84-
│ ├── crypto_data/ # 源代码
132+
│ ├── cryptoservice/ # 源代码
85133
│ ├── examples/ # 示例代码
86134
│ └── tests/ # 测试文件
87135
├── scripts/ # 工具脚本
@@ -167,7 +215,7 @@ BREAKING CHANGE: new API is not compatible with previous version"
167215

168216
```bash
169217
# 查看当前版本
170-
python setup.py --version
218+
python setup.py --versiona
171219

172220
# 查看提交历史和对应的版本变更
173221
git log --pretty=format:"%h %s"

pyproject.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ requires = ["hatchling"]
33
build-backend = "hatchling.build"
44

55
[project]
6-
name = "crypto-data"
6+
name = "cryptoservice"
77
version = "0.1.0"
88
description = "A cryptocurrency trading info package"
99
readme = "README.md"
10-
requires-python = ">=3.8"
10+
requires-python = ">=3.10"
1111
dependencies = [
1212
"python-binance>=1.0.0",
1313
"pyyaml>=5.4",
@@ -19,7 +19,7 @@ classifiers = [
1919
"License :: OSI Approved :: MIT License",
2020
"Operating System :: OS Independent",
2121
]
22-
authors = [{ name = "Your Name", email = "your.email@example.com" }]
22+
authors = [{ name = "Minnn", email = "minzzzai.s@gmail.com" }]
2323

2424
[project.optional-dependencies]
2525
dev = [
@@ -40,7 +40,7 @@ build_command = "python setup.py sdist bdist_wheel"
4040

4141
[tool.black]
4242
line-length = 100
43-
target-version = ["py38"]
43+
target-version = ["py310"]
4444
include = "\\.pyi?$"
4545

4646
[tool.isort]
@@ -49,7 +49,7 @@ multi_line_output = 3
4949
line_length = 100
5050

5151
[tool.mypy]
52-
python_version = "3.8"
52+
python_version = "3.10"
5353
warn_return_any = true
5454
warn_unused_configs = true
5555
disallow_untyped_defs = true
@@ -59,7 +59,7 @@ ignore_missing_imports = true
5959
[tool.pytest.ini_options]
6060
testpaths = ["tests"]
6161
python_files = ["test_*.py"]
62-
addopts = "-v --cov=src/crypto_data --cov-report=term-missing"
62+
addopts = "-v --cov=src/cryptoservice --cov-report=term-missing"
6363

6464
[tool.hatch.build.targets.wheel]
65-
packages = ["src/crypto_data"]
65+
packages = ["src/cryptoservice"]

src/crypto_data/config/settings.py

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/crypto_data/data/__init__.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)