Skip to content

Repository files navigation

bt_api_bydfi

PyPI VersionPython VersionsLicenseCIDocs


bt_api_bydfi

BYDFi exchange plugin for bt_api — Unified REST API for Spot trading with real-time WebSocket support.

bt_api_bydfi is a runtime plugin for bt_api that connects to BYDFi exchange. It depends on bt_api_base for core infrastructure.

ResourceLink
English Docshttps://bt-api-bydfi.readthedocs.io/
Chinese Docshttps://bt-api-bydfi.readthedocs.io/zh/latest/
GitHubhttps://github.com/cloudQuant/bt_api_bydfi
PyPIhttps://pypi.org/project/bt_api_bydfi/
Issueshttps://github.com/cloudQuant/bt_api_bydfi/issues
bt_api_basehttps://bt-api-base.readthedocs.io/
Main Projecthttps://github.com/cloudQuant/bt_api_py

Features

Asset Types

Asset TypeCodeRESTWebSocketDescription
SpotBYDFI___SPOTSpot trading

Dual API Modes

  • REST API — Synchronous polling for order management, balance queries, historical data
  • WebSocket API — Real-time streaming for ticker, order book, k-lines, trades (planned)

Plugin Architecture

Auto-registers at import time via ExchangeRegistry. Works seamlessly with BtApi:

frombt_api_pyimportBtApiapi=BtApi(exchange_kwargs={
"BYDFI___SPOT": {
"api_key": "your_key",
"secret": "your_secret",
}
})
ticker=api.get_tick("BYDFI___SPOT", "BTCUSDT")
balance=api.get_balance("BYDFI___SPOT")
order=api.make_order(exchange_name="BYDFI___SPOT", symbol="BTCUSDT", volume=0.001, price=50000, order_type="limit")

Unified Data Containers

All exchange responses normalized to bt_api_base container types:

  • TickContainer — 24hr rolling ticker
  • OrderBookContainer — Order book depth
  • BarContainer — K-line/candlestick
  • TradeContainer — Individual trades
  • OrderContainer — Order status and fills
  • AccountBalanceContainer — Asset balances

Installation

From PyPI (Recommended)

pip install bt_api_bydfi

From Source

git clone https://github.com/cloudQuant/bt_api_bydfi
cd bt_api_bydfi
pip install -e .

Requirements

  • Python 3.93.14
  • bt_api_base >= 0.15
  • httpx for HTTP client

Quick Start

1. Install

pip install bt_api_bydfi

2. Get ticker (public — no API key needed)

frombt_api_pyimportBtApiapi=BtApi()
ticker=api.get_tick("BYDFI___SPOT", "BTCUSDT")
print(f"BTCUSDT price: {ticker.last_price}")

3. Place an order (requires API key)

frombt_api_pyimportBtApiapi=BtApi(exchange_kwargs={
"BYDFI___SPOT": {
"api_key": "your_api_key",
"secret": "your_secret",
}
})
order=api.make_order(
exchange_name="BYDFI___SPOT",
symbol="BTCUSDT",
volume=0.001,
price=50000,
order_type="limit",
)
print(f"Order placed: {order}")

4. Get balance

frombt_api_pyimportBtApiapi=BtApi(exchange_kwargs={
"BYDFI___SPOT": {
"api_key": "your_api_key",
"secret": "your_secret",
}
})
balance=api.get_balance("BYDFI___SPOT")
print(f"Balance: {balance}")

Architecture

bt_api_bydfi/
├── src/bt_api_bydfi/
│ ├── __init__.py # Package exports
│ ├── registry_registration.py # BYDFi feed/exchange_data registration
│ ├── containers/
│ │ ├── __init__.py
│ │ ├── exchanges/
│ │ │ ├── __init__.py
│ │ │ └── bydfi_exchange_data.py # BYDFiExchangeData, BYDFiExchangeDataSpot
│ │ └── tickers/
│ │ ├── __init__.py
│ │ └── bydfi_ticker.py # BYDFiRequestTickerData
│ └── feeds/
│ ├── __init__.py
│ ├── request_base.py # BYDFiRequestData base class
│ └── spot.py # BYDFiRequestDataSpot
├── tests/
├── docs/
├── pyproject.toml
└── README.md

Supported Operations

CategoryOperationNotes
Market Dataget_ticker24hr rolling ticker
get_orderbookDepth up to 100
get_barsIntervals: 1m/5m/15m/30m/1h/4h/1d/1w
get_tradesRecent trade history
get_exchange_infoTrading rules and symbol info
Accountget_balanceAll asset balances
get_accountFull account info
Tradingmake_orderLIMIT/MARKET orders
cancel_orderCancel single order
query_orderQuery order by ID
get_open_ordersAll open orders

API Authentication

BYDFi uses HMAC-SHA256 authentication:

signature = HMAC-SHA256(accessKey + timestamp + queryString + body)

Required headers:

  • X-API-KEY — API key
  • X-API-TIMESTAMP — Request timestamp (milliseconds)
  • X-API-SIGNATURE — HMAC-SHA256 signature

Rate Limits

EndpointLimit
Public endpoints60 requests/minute
Private endpoints30 requests/minute

Documentation

DocLink
Englishhttps://bt-api-bydfi.readthedocs.io/
中文https://bt-api-bydfi.readthedocs.io/zh/latest/
bt_api_basehttps://bt-api-base.readthedocs.io/
Main Projecthttps://cloudquant.github.io/bt_api_py/

License

MIT — see LICENSE.


Support



中文

bt_api 的 BYDFi 交易所插件 — 为现货交易提供统一的 REST API 和实时 WebSocket 支持。

bt_api_bydfibt_api 的运行时插件,连接 BYDFi 交易所。依赖 bt_api_base 提供核心基础设施。

资源链接
英文文档https://bt-api-bydfi.readthedocs.io/
中文文档https://bt-api-bydfi.readthedocs.io/zh/latest/
GitHubhttps://github.com/cloudQuant/bt_api_bydfi
PyPIhttps://pypi.org/project/bt_api_bydfi/
问题反馈https://github.com/cloudQuant/bt_api_bydfi/issues
bt_api_basehttps://bt-api-base.readthedocs.io/
主项目https://github.com/cloudQuant/bt_api_py

功能特点

资产类型

资产类型代码RESTWebSocket说明
现货BYDFI___SPOT现货交易

双 API 模式

  • REST API — 同步轮询:订单管理、余额查询、历史数据
  • WebSocket API — 实时流:行情、订单簿、K线、交易(计划中)

插件架构

通过 ExchangeRegistry 在导入时自动注册,与 BtApi 无缝协作:

frombt_api_pyimportBtApiapi=BtApi(exchange_kwargs={
"BYDFI___SPOT": {
"api_key": "your_key",
"secret": "your_secret",
}
})
ticker=api.get_tick("BYDFI___SPOT", "BTCUSDT")
balance=api.get_balance("BYDFI___SPOT")
order=api.make_order(exchange_name="BYDFI___SPOT", symbol="BTCUSDT", volume=0.001, price=50000, order_type="limit")

统一数据容器

所有交易所响应规范化为 bt_api_base 容器类型:

  • TickContainer — 24小时滚动行情
  • OrderBookContainer — 订单簿深度
  • BarContainer — K线/蜡烛图
  • TradeContainer — 逐笔成交
  • OrderContainer — 订单状态和成交
  • AccountBalanceContainer — 资产余额

安装

从 PyPI 安装(推荐)

pip install bt_api_bydfi

从源码安装

git clone https://github.com/cloudQuant/bt_api_bydfi
cd bt_api_bydfi
pip install -e .

系统要求

  • Python 3.93.14
  • bt_api_base >= 0.15
  • httpx HTTP 客户端

快速开始

1. 安装

pip install bt_api_bydfi

2. 获取行情(公开接口,无需 API key)

frombt_api_pyimportBtApiapi=BtApi()
ticker=api.get_tick("BYDFI___SPOT", "BTCUSDT")
print(f"BTCUSDT 价格: {ticker.last_price}")

3. 下单交易(需要 API key)

frombt_api_pyimportBtApiapi=BtApi(exchange_kwargs={
"BYDFI___SPOT": {
"api_key": "your_api_key",
"secret": "your_secret",
}
})
order=api.make_order(
exchange_name="BYDFI___SPOT",
symbol="BTCUSDT",
volume=0.001,
price=50000,
order_type="limit",
)
print(f"订单已下单: {order}")

4. 获取余额

frombt_api_pyimportBtApiapi=BtApi(exchange_kwargs={
"BYDFI___SPOT": {
"api_key": "your_api_key",
"secret": "your_secret",
}
})
balance=api.get_balance("BYDFI___SPOT")
print(f"余额: {balance}")

架构

bt_api_bydfi/
├── src/bt_api_bydfi/
│ ├── __init__.py # 包导出
│ ├── registry_registration.py # BYDFi feed/exchange_data 注册
│ ├── containers/
│ │ ├── __init__.py
│ │ ├── exchanges/
│ │ │ ├── __init__.py
│ │ │ └── bydfi_exchange_data.py # BYDFiExchangeData, BYDFiExchangeDataSpot
│ │ └── tickers/
│ │ ├── __init__.py
│ │ └── bydfi_ticker.py # BYDFiRequestTickerData
│ └── feeds/
│ ├── __init__.py
│ ├── request_base.py # BYDFiRequestData 基类
│ └── spot.py # BYDFiRequestDataSpot
├── tests/
├── docs/
├── pyproject.toml
└── README.md

支持的操作

类别操作说明
行情数据get_ticker24小时滚动行情
get_orderbook深度最高100档
get_bars周期: 1m/5m/15m/30m/1h/4h/1d/1w
get_trades近期成交历史
get_exchange_info交易规则和交易对信息
账户get_balance所有资产余额
get_account完整账户信息
交易make_order限价/市价订单
cancel_order撤销单笔订单
query_order按ID查询订单
get_open_orders所有挂单

API 认证

BYDFi 使用 HMAC-SHA256 认证:

signature = HMAC-SHA256(accessKey + timestamp + queryString + body)

必需请求头:

  • X-API-KEY — API 密钥
  • X-API-TIMESTAMP — 请求时间戳(毫秒)
  • X-API-SIGNATURE — HMAC-SHA256 签名

限流配置

端点限制
公开接口60 次/分钟
私有接口30 次/分钟

文档

文档链接
英文文档https://bt-api-bydfi.readthedocs.io/
中文文档https://bt-api-bydfi.readthedocs.io/zh/latest/
bt_api_basehttps://bt-api-base.readthedocs.io/
主项目https://cloudquant.github.io/bt_api_py/

许可证

MIT — 详见 LICENSE


技术支持

About

Exchange adapter package for bt_api

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages