Skip to main content

A cryptocurrency trading info package

Project description

CryptoService

一个高性能的Python加密货币数据处理包,专注于币安市场数据的获取、存储和分析。

✨ 核心功能

  • 🚀 高性能异步:全面支持async/await,高效处理大量数据
  • 📊 全面数据覆盖:现货、永续合约、历史K线、实时WebSocket
  • 💾 智能存储:SQLite数据库 + 文件导出,支持增量更新
  • 🔧 开箱即用:完整的类型提示、错误处理和重试机制
  • 📈 数据处理:内置数据转换、验证和分析工具

📦 安装

pip install cryptoservice

🚀 快速开始

1. 环境配置

# .env 文件
BINANCE_API_KEY=your_api_key
BINANCE_API_SECRET=your_api_secret

2. 基本使用

import asyncio
from cryptoservice import MarketDataService

async def main():
    # 创建服务实例
    service = MarketDataService()

    # 获取实时行情
    ticker = await service.get_ticker("BTCUSDT")
    print(f"BTC价格: {ticker.price}")

    # 下载历史数据
    await service.download_klines("BTCUSDT", "1d", "2024-01-01", "2024-12-31")

asyncio.run(main())

🛠️ 开发环境

# 克隆项目
git clone https://github.com/ppmina/xdata.git
cd xdata

# 安装uv(推荐)
./scripts/setup_uv.sh  # macOS/Linux
# 或 .\scripts\setup_uv.ps1  # Windows

# 安装依赖
uv pip install -e ".[dev-all]"

# 激活环境
source .venv/bin/activate

常用命令

pytest                    # 运行测试
ruff format              # 格式化代码
ruff check --fix         # 检查并修复
mypy src/cryptoservice   # 类型检查
mkdocs serve            # 本地文档

🚢 发布流程(main release)

个人维护时推荐手动准备版本,并由 GitHub Actions 负责最终构建/发布:

  1. 确保工作区干净并切到 main 分支。
  2. 运行 python3 scripts/prepare_release.py 1.12.0(替换为目标版本),脚本会同步更新版本号,并依据自上一个标签以来的提交自动生成 CHANGELOG.md 段落。
  3. 检查 CHANGELOG.md 自动生成的条目,必要时手动调整;随后执行 pytest 等自检并提交:git commit -am "chore: release v1.12.0"
  4. 打标签并推送:git tag v1.12.0 && git push origin main --tags
  5. Release 工作流会在标签推送后自动运行测试、构建以及(若配置了 PYPI_API_TOKEN)上传到 PyPI。
  6. 如需仅验证构建或在未打标签时发布,可在 GitHub Actions 中手动触发 Release workflow,并在弹出的参数中选择是否上传到 PyPI。

若只想更新版本号,可使用 --skip-changelog 跳过自动生成的变更记录。 自动识别 (#123) 的提交引用并生成对应的 GitHub PR 链接。

📚 文档

完整文档:https://ppmina.github.io/Xdata/

🤝 贡献

  1. Fork项目并创建分支:git checkout -b feature/your-feature
  2. 遵循Conventional Commits规范
  3. 提交Pull Request

提交类型:feat | fix | docs | style | refactor | perf | test | chore

📄 许可证

MIT License

📞 联系

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cryptoservice-1.11.1.tar.gz (219.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cryptoservice-1.11.1-py3-none-any.whl (105.6 kB view details)

Uploaded Python 3

File details

Details for the file cryptoservice-1.11.1.tar.gz.

File metadata

  • Download URL: cryptoservice-1.11.1.tar.gz
  • Upload date:
  • Size: 219.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for cryptoservice-1.11.1.tar.gz
Algorithm Hash digest
SHA256 d7c1552ccc40235df02a589506b5b0cb6e1fc11255b4c6890558c3d1560b702b
MD5 f7132a2167d472b7ffbecf2cf7e64298
BLAKE2b-256 398634fbe4ba867ba2c72a2d0800f690efe6ef50bb7827d8b5bcd7a42dd3ab39

See more details on using hashes here.

File details

Details for the file cryptoservice-1.11.1-py3-none-any.whl.

File metadata

  • Download URL: cryptoservice-1.11.1-py3-none-any.whl
  • Upload date:
  • Size: 105.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for cryptoservice-1.11.1-py3-none-any.whl
Algorithm Hash digest
SHA256 89cdd5e34beed60ab859725e1725bd803e96a17fc71e0f0ed9f4ce655f34c5bf
MD5 7c2cb7f1fc57bc70357910d138283c23
BLAKE2b-256 89f6a5dd6806bf3523e6280ac274a98768a0efb3557a0f26b80da7fc18e64dd8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page