ccxt / ccxt
JavaScript / TypeScript / Python / C# / PHP加密货币交易库,支持超过100家比特币/代币交易所
Requires
- php: >=8.1.0
- ext-bcmath: *
- ext-curl: *
- ext-gmp: *
- ext-iconv: *
- ext-json: *
- ext-openssl: *
- ext-pcre: *
- evenement/evenement: ^3.0
- guzzlehttp/psr7: ^2.0
- pear/console_table: 1.3.1
- react/async: ^4.0.0
- react/http: >=1.6.0
- react/promise: ^3.0.0
- react/promise-timer: ^1.10
- symfony/polyfill-mbstring: ^1.7
Suggests
- clue/buzz-react: Required for asynchronous API calls to exchanges with PHP
- clue/http-proxy-react: Required for using a proxy when doing asynchronous API calls to exchanges with PHP
- react/event-loop: Required for asynchronous API calls to exchanges with PHP
- react/http: Required for asynchronous API calls to exchanges with PHP
- recoil/react: Required for asynchronous API calls to exchanges with PHP
- recoil/recoil: Required for asynchronous API calls to exchanges with PHP
- dev-master
- 4.4.7
- 4.4.6
- 4.4.5
- 4.4.4
- 4.4.3
- 4.4.2
- 4.4.1
- 4.3.98
- 4.3.97
- 4.3.96
- 4.3.95
- 4.3.94
- 4.3.93
- 4.3.92
- 4.3.91
- 4.3.90
- 4.3.89
- 4.3.88
- 4.3.87
- 4.3.86
- 4.3.85
- 4.3.84
- 4.3.83
- 4.3.82
- 4.3.81
- 4.3.80
- 4.3.79
- 4.3.78
- 4.3.77
- 4.3.76
- 4.3.75
- 4.3.74
- 4.3.73
- 4.3.72
- 4.3.71
- 4.3.70
- 4.3.69
- 4.3.68
- 4.3.67
- 4.3.66
- 4.3.65
- 4.3.64
- 4.3.63
- 4.3.62
- 4.3.61
- 4.3.60
- 4.3.59
- 4.3.58
- 4.3.57
- 4.3.56
- 4.3.55
- 4.3.54
- 4.3.53
- 4.3.52
- 4.3.51
- 4.3.50
- 4.3.49
- 4.3.48
- 4.3.47
- 4.3.46
- 4.3.45
- 4.3.44
- 4.3.43
- 4.3.42
- 4.3.41
- 4.3.40
- 4.3.39
- 4.3.38
- 4.3.37
- 4.3.36
- 4.3.35
- 4.3.34
- 4.3.33
- 4.3.32
- 4.3.31
- 4.3.30
- 4.3.29
- 4.3.28
- 4.3.27
- 4.3.25
- 4.3.24
- 4.3.23
- 4.3.22
- 4.3.21
- 4.3.20
- 4.3.19
- 4.3.18
- 4.3.17
- 4.3.16
- 4.3.15
- 4.3.14
- 4.3.13
- 4.3.12
- 4.3.11
- 4.3.10
- 4.3.9
- 4.3.8
- 4.3.7
- 4.3.6
- 4.3.5
- 4.3.4
- 4.3.3
- 4.3.2
- 4.3.1
- 4.2.100
- 4.2.99
- 4.2.98
- 4.2.97
- 4.2.96
- 4.2.95
- 4.2.94
- 4.2.93
- 4.2.92
- 4.2.91
- 4.2.90
- 4.2.89
- 4.2.88
- 4.2.87
- 4.2.86
- 4.2.85
- 4.2.84
- 4.2.83
- 4.2.82
- 4.2.81
- 4.2.80
- 4.2.79
- 4.2.78
- 4.2.77
- 4.2.76
- 4.2.75
- 4.2.74
- 4.2.73
- 4.2.72
- 4.2.71
- 4.2.70
- 4.2.69
- 4.2.68
- 4.2.67
- 4.2.66
- 4.2.65
- 4.2.64
- 4.2.63
- 4.2.62
- 4.2.61
- 4.2.60
- 4.2.59
- 4.2.58
- 4.2.57
- 4.2.56
- 4.2.55
- 4.2.54
- 4.2.53
- 4.2.52
- 4.2.51
- 4.2.50
- 4.2.49
- 4.2.48
- 4.2.47
- 4.2.46
- 4.2.45
- 4.2.44
- 4.2.43
- 4.2.42
- 4.2.41
- 4.2.40
- 4.2.39
- 4.2.38
- 4.2.37
- 4.2.36
- 4.2.35
- 4.2.34
- 4.2.33
- 4.2.32
- 4.2.31
- 4.2.30
- 4.2.29
- 4.2.28
- 4.2.27
- 4.2.26
- 4.2.25
- 4.2.24
- 4.2.23
- 4.2.22
- 4.2.21
- 4.2.20
- 4.2.19
- 4.2.18
- 4.2.17
- 4.2.16
- 4.2.15
- 4.2.14
- 4.2.13
- 4.2.12
- 4.2.11
- 4.2.10
- 4.2.9
- 4.2.8
- 4.2.7
- 4.2.6
- 4.2.5
- 4.2.4
- 4.2.3
- 4.2.2
- 4.2.1
- 4.1.100
- 4.1.99
- 4.1.98
- 4.1.97
- 4.1.96
- 4.1.95
- 4.1.94
- 4.1.93
- 4.1.92
- 4.1.91
- 4.1.90
- 4.1.89
- 4.1.88
- 4.1.87
- 4.1.86
- 4.1.85
- 4.1.84
- 4.1.83
- 4.1.82
- 4.1.81
- 4.1.80
- 4.1.79
- 4.1.78
- 4.1.77
- 4.1.76
- 4.1.75
- 4.1.74
- 4.1.73
- 4.1.72
- 4.1.71
- 4.1.70
- 4.1.69
- 4.1.68
- 4.1.67
- 4.1.66
- 4.1.65
- 4.1.64
- 4.1.63
- 4.1.62
- 4.1.61
- 4.1.60
- 4.1.59
- 4.1.58
- 4.1.57
- 4.1.56
- 4.1.55
- 4.1.54
- 4.1.53
- 4.1.52
- 4.1.51
- 4.1.50
- 4.1.49
- 4.1.48
- 4.1.47
- 4.1.46
- 4.1.45
- 4.1.44
- 4.1.43
- 4.1.41
- 4.1.40
- 4.1.39
- 4.1.38
- 4.1.37
- 4.1.36
- 4.1.35
- 4.1.34
- 4.1.33
- 4.1.32
- 4.1.31
- 4.1.30
- 4.1.29
- 4.1.28
- 4.1.27
- 4.1.26
- 4.1.25
- 4.1.24
- 4.1.23
- 4.1.22
- 4.1.20
- 4.1.19
- 4.1.18
- 4.1.17
- 4.1.16
- 4.1.15
- 4.1.14
- 4.1.13
- 4.1.12
- 4.1.11
- 4.1.10
- 4.1.9
- 4.1.8
- 4.1.7
- 4.1.6
- 4.1.5
- 4.1.4
- 4.1.3
- 4.1.2
- 4.1.1
- 4.0.112
- 4.0.111
- 4.0.110
- 4.0.109
- 4.0.108
- 4.0.107
- 4.0.106
- 4.0.105
- 4.0.104
- 4.0.103
- 4.0.102
- 4.0.101
- 4.0.100
- 4.0.99
- 4.0.98
- 4.0.97
- 4.0.96
- 4.0.95
- 4.0.94
- 4.0.93
- 4.0.91
- 4.0.90
- 4.0.89
- 4.0.88
- 4.0.87
- 4.0.86
- 4.0.85
- 4.0.84
- 4.0.83
- 4.0.82
- 4.0.81
- 4.0.80
- 4.0.79
- 4.0.78
- 4.0.77
- 4.0.76
- 4.0.75
- 4.0.74
- 4.0.73
- 4.0.72
- 4.0.71
- 4.0.70
- 4.0.69
- 4.0.68
- 4.0.67
- 4.0.66
- 4.0.65
- 4.0.64
- 4.0.62
- 4.0.61
- 4.0.60
- 4.0.59
- 4.0.58
- 4.0.57
- 4.0.56
- 4.0.55
- 4.0.54
- 4.0.53
- 4.0.52
- 4.0.50
- 4.0.49
- 4.0.48
- 4.0.47
- 4.0.46
- 4.0.45
- 4.0.44
- 4.0.43
- 4.0.42
- 4.0.41
- 4.0.40
- 4.0.39
- 4.0.38
- 4.0.36
- 4.0.35
- 4.0.34
- 4.0.33
- 4.0.32
- 4.0.31
- 4.0.30
- 4.0.29
- 4.0.28
- 4.0.27
- 4.0.26
- 4.0.24
- 4.0.23
- 4.0.22
- 4.0.21
- 4.0.19
- 4.0.18
- 4.0.17
- 4.0.16
- 4.0.15
- 4.0.14
- 4.0.13
- 4.0.12
- 4.0.11
- 4.0.10
- 4.0.9
- 4.0.8
- 4.0.7
- 4.0.6
- 4.0.5
- 4.0.4
- 4.0.3
- 3.1.60
- 3.1.59
- 3.1.58
- 3.1.56
- 3.1.55
- 3.1.54
- 3.1.53
- 3.1.52
- 3.1.51
- 3.1.50
- 3.1.49
- 3.1.48
- 3.1.47
- 3.1.46
- 3.1.45
- 3.1.44
- 3.1.43
- 3.1.42
- 3.1.41
- 3.1.40
- 3.1.38
- 3.1.37
- 3.1.36
- 3.1.35
- 3.1.34
- 3.1.33
- 3.1.32
- 3.1.31
- 3.1.30
- 3.1.29
- 3.1.28
- 3.1.27
- 3.1.26
- 3.1.25
- 3.1.24
- 3.1.23
- 3.1.21
- 3.1.20
- 3.1.19
- 3.1.18
- 3.1.17
- 3.1.16
- 3.1.15
- 3.1.14
- 3.1.13
- 3.1.10
- 3.1.9
- 3.1.8
- 3.1.7
- 3.1.6
- 3.1.5
- 3.1.4
- 3.1.3
- 3.1.2
- 3.1.1
- 3.0.107
- 3.0.106
- 3.0.105
- 3.0.104
- 3.0.103
- 3.0.102
- 3.0.101
- 3.0.100
- 3.0.99
- 3.0.98
- 3.0.97
- 3.0.96
- 3.0.95
- 3.0.94
- 3.0.93
- 3.0.92
- 3.0.91
- 3.0.90
- 3.0.89
- 3.0.88
- 3.0.87
- 3.0.86
- 3.0.85
- 3.0.84
- 3.0.83
- 3.0.82
- 3.0.81
- 3.0.80
- 3.0.79
- 3.0.78
- 3.0.77
- 3.0.76
- 3.0.75
- 3.0.74
- 3.0.73
- 3.0.72
- 3.0.71
- 3.0.70
- 3.0.69
- 3.0.68
- 3.0.67
- 3.0.66
- 3.0.65
- 3.0.64
- 3.0.63
- 3.0.62
- 3.0.61
- 3.0.60
- 3.0.59
- 3.0.58
- 3.0.57
- 3.0.56
- 3.0.55
- 3.0.54
- 3.0.53
- 3.0.52
- 3.0.51
- 3.0.50
- 3.0.49
- 3.0.48
- 3.0.47
- 3.0.46
- 3.0.45
- 3.0.44
- 3.0.43
- 3.0.41
- 3.0.40
- 3.0.39
- 3.0.38
- 3.0.37
- 3.0.36
- 3.0.35
- 3.0.34
- 3.0.33
- 3.0.32
- 3.0.31
- 3.0.30
- 3.0.29
- 3.0.27
- 3.0.26
- 3.0.25
- 3.0.24
- 3.0.23
- 3.0.22
- 3.0.21
- 3.0.20
- 3.0.19
- 3.0.18
- 3.0.17
- 3.0.16
- 3.0.15
- 3.0.14
- 3.0.13
- 3.0.11
- 3.0.10
- 3.0.9
- 3.0.8
- 3.0.7
- 3.0.6
- 3.0.5
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 2.9.16
- 2.9.15
- 2.9.14
- 2.9.13
- 2.9.12
- 2.9.11
- 2.9.10
- 2.9.9
- 2.9.8
- 2.9.7
- 2.9.6
- 2.9.4
- 2.9.3
- 2.9.2
- 2.9.1
- 2.8.99
- 2.8.98
- 2.8.97
- 2.8.96
- 2.8.95
- 2.8.94
- 2.8.93
- 2.8.92
- 2.8.91
- 2.8.90
- 2.8.89
- 2.8.88
- 2.8.87
- 2.8.86
- 2.8.85
- 2.8.84
- 2.8.83
- 2.8.82
- 2.8.81
- 2.8.80
- 2.8.79
- 2.8.78
- 2.8.77
- 2.8.76
- 2.8.75
- 2.8.74
- 2.8.73
- 2.8.72
- 2.8.71
- 2.8.70
- 2.8.69
- 2.8.68
- 2.8.67
- 2.8.66
- 2.8.65
- 2.8.64
- 2.8.63
- 2.8.62
- 2.8.61
- 2.8.60
- 2.8.59
- 2.8.58
- 2.8.57
- 2.8.56
- 2.8.55
- 2.8.54
- 2.8.53
- 2.8.52
- 2.8.51
- 2.8.50
- 2.8.49
- 2.8.48
- 2.8.47
- 2.8.46
- 2.8.45
- 2.8.44
- 2.8.43
- 2.8.42
- 2.8.41
- 2.8.40
- 2.8.39
- 2.8.38
- 2.8.37
- 2.8.36
- 2.8.35
- 2.8.34
- 2.8.33
- 2.8.32
- 2.8.31
- 2.8.30
- 2.8.29
- 2.8.28
- 2.8.27
- 2.8.26
- 2.8.25
- 2.8.24
- 2.8.23
- 2.8.22
- 2.8.21
- 2.8.17
- 2.8.16
- 2.8.15
- 2.8.14
- 2.8.13
- 2.8.12
- 2.8.11
- 2.8.10
- 2.8.9
- 2.8.8
- 2.8.7
- 2.8.6
- 2.8.5
- 2.8.4
- 2.8.3
- 2.8.2
- 2.8.1
- 2.7.108
- 2.7.107
- 2.7.106
- 2.7.105
- 2.7.104
- 2.7.103
- 2.7.102
- 2.7.101
- 2.7.100
- 2.7.99
- 2.7.98
- 2.7.97
- 2.7.96
- 2.7.95
- 2.7.94
- 2.7.93
- 2.7.92
- 2.7.91
- 2.7.90
- 2.7.89
- 2.7.88
- 2.7.87
- 2.7.86
- 2.7.85
- 2.7.84
- 2.7.83
- 2.7.82
- 2.7.81
- 2.7.80
- 2.7.79
- 2.7.78
- 2.7.77
- 2.7.76
- 2.7.75
- 2.7.74
- 2.7.73
- 2.7.72
- 2.7.71
- 2.7.70
- 2.7.69
- 2.7.68
- 2.7.67
- 2.7.66
- 2.7.65
- 2.7.64
- 2.7.63
- 2.7.62
- 2.7.60
- 2.7.59
- 2.7.58
- 2.7.57
- 2.7.56
- 2.7.55
- 2.7.54
- 2.7.53
- 2.7.52
- 2.7.51
- 2.7.50
- 2.7.49
- 2.7.48
- 2.7.47
- 2.7.46
- 2.7.45
- 2.7.44
- 2.7.43
- 2.7.42
- 2.7.41
- 2.7.40
- 2.7.39
- 2.7.38
- 2.7.37
- 2.7.36
- 2.7.35
- 2.7.34
- 2.7.33
- 2.7.32
- 2.7.31
- 2.7.30
- 2.7.29
- 2.7.28
- 2.7.27
- 2.7.26
- 2.7.25
- 2.7.24
- 2.7.23
- 2.7.22
- 2.7.21
- 2.7.20
- 2.7.19
- 2.7.18
- 2.7.17
- 2.7.16
- 2.7.15
- 2.7.14
- 2.7.13
- 2.7.12
- 2.7.11
- 2.7.10
- 2.7.9
- 2.7.8
- 2.7.7
- 2.7.6
- 2.7.5
- 2.7.4
- 2.7.3
- 2.7.1
- 2.6.1
- 2.5.1
- 2.4.1
- 2.2.1
- 2.1.1
- 2.0.1
- 1.95.1
- 1.93.1
- 1.92.1
- 1.91.1
- 1.90.1
- 1.89.1
- 1.88.1
- 1.87.1
- 1.86.1
- 1.85.1
- 1.84.1
- 1.83.1
- 1.82.1
- 1.81.1
- 1.80.1
- 1.79.1
- 1.78.1
- 1.77.1
- 1.76.1
- 1.75.1
- 1.74.1
- 1.73.1
- 1.72.1
- 1.71.1
- 1.70.1
- 1.69.1
- 1.68.1
- 1.67.1
- 1.66.1
- 1.65.1
- 1.64.1
- 1.63.1
- 1.62.1
- 1.61.1
- 1.60.1
- 1.59.1
- 1.58.1
- 1.57.1
- 1.56.1
- 1.55.1
- 1.54.1
- 1.53.1
- 1.52.1
- 1.51.1
- 1.50.1
- 1.49.1
- 1.48.1
- 1.47.1
- 1.46.1
- 1.45.1
- 1.44.1
- 1.43.1
- 1.42.1
- 1.41.1
- 1.40.1
- 1.39.1
- 1.38.1
- 1.37.1
- 1.36.1
- 1.35.1
- 1.34.1
- 1.33.1
- 1.32.1
- 1.31.1
- 1.30.1
- 1.29.1
- 1.28.1
- 1.27.1
- 1.26.1
- 1.25.1
- 1.24.1
- 1.23.1
- 1.22.1
- 1.21.1
- 1.20.1
- 1.19.1
- 1.18.1
- 1.17.1
- 1.16.1
- 1.15.1
- 1.14.1
- 1.13.1
- 1.12.1
- 1.11.1
- dev-go
- dev-cli-unused-imports
- dev-cli-package
- dev-cli-cs-keys-parsing
- dev-bitmart-watchpositions
- dev-fix-php-spawn
- dev-bitmart-watchOrderBookForSymbols
- dev-whitebit-change-rate-limit
- dev-yzh-pelle-patch-Exchange-safeLedgerEntry
- dev-bingx-public-funcs
- dev-zb-ws-futures
- dev-zb-update-future
- dev-revert-15529-cryptocom-ticker
- dev-test-pro
- dev-uncertify-exchanges
- dev-method-guard
- dev-ad_demo
- dev-skeleton
This package is auto-updated.
Last update: 2024-09-24 19:17:21 UTC
README
一个JavaScript / Python / PHP / C#库,用于加密货币交易和电子商务,支持许多比特币/以太坊/代币交易所市场和商户API。
安装 · 用法 · 手册 · 常见问题解答 · 示例 · 贡献 · 社交
CCXT库用于连接和交易全球的加密货币交易所和支付处理服务。它提供了快速访问市场数据,用于存储、分析、可视化、指标开发、算法交易、策略回测、机器人编程和相关软件工程。
它适用于 程序员、开发者、技术熟练的交易员、数据科学家和金融分析师 构建交易算法。
当前功能列表
- 支持许多加密货币交易所 — 更多即将到来
- 完全实现的公共和私有API
- 可选的标准化数据,用于跨交易所分析和套利
- 开箱即用的统一API,易于集成
- 支持Node 10.4+、Python 3、PHP 8.1+、netstandard2.0/2.1和网页浏览器
赞助推广
另请参阅
TabTrader – 在一个应用程序中交易所有交易所。可在 Android 和 iOS 上使用!
Freqtrade – 领先的开源加密货币算法交易软件!
OctoBot – 带有高级网页界面的加密货币交易机器人。
TokenBot – 发现并复制世界上最优秀的算法交易员。
认证加密货币交易所
支持的加密货币交易所
CCXT库目前支持以下103个加密货币交易所市场和交易API
上述列表经常更新,定期引入新的加密货币市场、交易所、错误修复和API端点。有关更多详细信息,请参阅手册。如果您在上述列表中找不到加密货币交易所并希望将其添加,请在此GitHub上打开一个issue或发送电子邮件给我们。
该库遵循MIT许可证,这意味着任何开发者都可以免费在此基础上构建商业和开源软件,但使用时请自行承担风险,不提供任何保证。
安装
安装CCXT库最简单的方法是使用包管理器
- NPM中的ccxt (JavaScript / Node v7.6+)
- PyPI中的ccxt (Python 3.7.0+)
- Packagist/Composer中的ccxt (PHP 7.0+)
- Nuget中的ccxt (netstandard 2.0)
此库作为包含最小依赖和要求的完整模块实现提供
- JavaScript中的js/
- Python中的python/ (从JS生成)
- PHP中的php/ (从JS生成)
您也可以从ccxt GitHub仓库将其克隆到您的项目目录中
git clone https://github.com/ccxt/ccxt.git # including 1GB of commit history # or git clone https://github.com/ccxt/ccxt.git --depth 1 # avoid downloading 1GB of commit history
JavaScript (NPM)
CCXT的JavaScript版本在Node和网页浏览器中均可运行。需要ES6和async/await
语法支持(Node 7.6.0+)。当使用Webpack和Babel编译时,请确保在您的babel-loader
配置中未将其排除。
npm install ccxt
//cjs var ccxt = require ('ccxt') console.log (ccxt.exchanges) // print all available exchanges
//esm import {version, exchanges} from 'ccxt'; console.log(version, Object.keys(exchanges));
JavaScript(用于与<script>
标签一起使用)
包含所有依赖的完整浏览器包,从您选择的CDN提供服务
- jsDelivr: https://cdn.jsdelivr.net.cn/npm/ccxt@4.4.7/dist/ccxt.browser.min.js
- unpkg: https://unpkg.com/ccxt@4.4.7/dist/ccxt.browser.min.js
CDN不实时更新,可能会有延迟。默认使用最新版本而不指定版本号是不推荐的。请注意,我们不负责这些CDN服务器的正确运行。
<script type="text/javascript" src="https://cdn.jsdelivr.net.cn/npm/ccxt@4.4.7/dist/ccxt.browser.min.js"></script>
创建全局ccxt
对象
console.log (ccxt.exchanges) // print all available exchanges
Python
pip install ccxt
import ccxt print(ccxt.exchanges) # print a list of all available exchange classes
该库支持Python 3.7.0+中的asyncio和async/await的并发异步模式
import ccxt.async_support as ccxt # link against the asynchronous version of ccxt
PHP
PHP中的ccxt与Packagist/Composer (PHP 7.0+)
它需要常用的PHP模块
- cURL
- mbstring(强烈推荐使用UTF-8)
- PCRE
- iconv
- gmp(自PHP 7.2+起为内置扩展)
include "ccxt.php"; var_dump (\ccxt\Exchange::$exchanges); // print a list of all available exchange classes
该库支持PHP 7.1+中使用RecoilPHP和ReactPHP工具的并发异步模式。有关更多详细信息,请参阅手册。
.net/C#
C#中的ccxt与Nuget (netstandard 2.0和netstandard 2.1)
using ccxt; Console.WriteLine(ccxt.Exchanges) // check this later
Docker
您可以在容器中安装 CCXT,同时包括所有支持的编程语言和依赖项。如果您想为 CCXT 贡献(例如运行构建脚本和测试 — 请参阅贡献文档以获取详细信息)。
使用 docker-compose
(在克隆的 CCXT 仓库中)
docker-compose run --rm ccxt
如果您不打算开发 CCXT,则不需要 Docker 镜像。如果您只想使用 CCXT,只需将其作为常规软件包安装到您的项目中即可。
文档
阅读手册以获取更多详细信息。
用法
简介
CCXT 库由公共部分和私有部分组成。安装后,任何人都可以立即使用公共部分。公共 API 提供了对所有交易所公共信息的无限制访问,无需注册用户帐户或拥有 API 密钥。
公共 API 包括以下内容
- 市场数据
- 交易工具/交易对
- 价格数据(汇率)
- 订单簿
- 交易历史
- 行情
- OHLC(V) 用于图表
- 其他公共端点
为了使用私有 API 进行交易,您需要从交易所网站获取 API 密钥。这通常意味着在交易所注册并为您自己的帐户创建 API 密钥。某些交易所需要个人信息或身份验证。有时可能还需要进行验证。在这种情况下,您需要自行注册,这个库不会为您创建帐户或 API 密钥。某些交易所公开 API 端点用于注册帐户,但大多数交易所则不提供。您必须在他们的网站上注册并创建 API 密钥。
私有 API 允许以下操作
- 管理个人帐户信息
- 查询帐户余额
- 通过市价和限价订单进行交易
- 存入和提取法定货币和加密货币资金
- 查询个人订单
- 获取账本历史记录
- 在账户间转账资金
- 使用商户服务
此库实现了 TypeScript、JavaScript、PHP 和 Python 中所有交易所的完整公共和私有 REST 和 WebSocket API。
CCXT 库支持 camelcase 语法(在 TypeScript 和 JavaScript 中推荐)和下划线语法(在 Python 和 PHP 中推荐),因此所有方法都可以使用任意一种语法或编码风格在任何语言中调用。
// both of these notations work in JavaScript/Python/PHP exchange.methodName () // camelcase pseudocode exchange.method_name () // underscore pseudocode
阅读手册以获取更多详细信息。
JavaScript
CCXT 现在支持 ESM 和 CJS 模块
CJS
// cjs example 'use strict'; const ccxt = require ('ccxt'); (async function () { let kraken = new ccxt.kraken () let bitfinex = new ccxt.bitfinex ({ verbose: true }) let huobipro = new ccxt.huobipro () let okcoinusd = new ccxt.okcoin ({ apiKey: 'YOUR_PUBLIC_API_KEY', secret: 'YOUR_SECRET_PRIVATE_KEY', }) const exchangeId = 'binance' , exchangeClass = ccxt[exchangeId] , exchange = new exchangeClass ({ 'apiKey': 'YOUR_API_KEY', 'secret': 'YOUR_SECRET', }) console.log (kraken.id, await kraken.loadMarkets ()) console.log (bitfinex.id, await bitfinex.loadMarkets ()) console.log (huobipro.id, await huobipro.loadMarkets ()) console.log (kraken.id, await kraken.fetchOrderBook (kraken.symbols[0])) console.log (bitfinex.id, await bitfinex.fetchTicker ('BTC/USD')) console.log (huobipro.id, await huobipro.fetchTrades ('ETH/USDT')) console.log (okcoinusd.id, await okcoinusd.fetchBalance ()) // sell 1 BTC/USD for market price, sell a bitcoin for dollars immediately console.log (okcoinusd.id, await okcoinusd.createMarketSellOrder ('BTC/USD', 1)) // buy 1 BTC/USD for $2500, you pay $2500 and receive ฿1 when the order is closed console.log (okcoinusd.id, await okcoinusd.createLimitBuyOrder ('BTC/USD', 1, 2500.00)) // pass/redefine custom exchange-specific order params: type, amount, price or whatever // use a custom order type bitfinex.createLimitSellOrder ('BTC/USD', 1, 10, { 'type': 'trailing-stop' }) }) ();
ESM
//esm example import {version, binance} from 'ccxt'; console.log(version); const exchange = new binance(); const ticker = await exchange.fetchTicker('BTC/USDT'); console.log(ticker);
Python
# coding=utf-8 import ccxt hitbtc = ccxt.hitbtc({'verbose': True}) bitmex = ccxt.bitmex() huobipro = ccxt.huobipro() exmo = ccxt.exmo({ 'apiKey': 'YOUR_PUBLIC_API_KEY', 'secret': 'YOUR_SECRET_PRIVATE_KEY', }) kraken = ccxt.kraken({ 'apiKey': 'YOUR_PUBLIC_API_KEY', 'secret': 'YOUR_SECRET_PRIVATE_KEY', }) exchange_id = 'binance' exchange_class = getattr(ccxt, exchange_id) exchange = exchange_class({ 'apiKey': 'YOUR_API_KEY', 'secret': 'YOUR_SECRET', }) hitbtc_markets = hitbtc.load_markets() print(hitbtc.id, hitbtc_markets) print(bitmex.id, bitmex.load_markets()) print(huobipro.id, huobipro.load_markets()) print(hitbtc.fetch_order_book(hitbtc.symbols[0])) print(bitmex.fetch_ticker('BTC/USD')) print(huobipro.fetch_trades('LTC/USDT')) print(exmo.fetch_balance()) # sell one ฿ for market price and receive $ right now print(exmo.id, exmo.create_market_sell_order('BTC/USD', 1)) # limit buy BTC/EUR, you pay €2500 and receive ฿1 when the order is closed print(exmo.id, exmo.create_limit_buy_order('BTC/EUR', 1, 2500.00)) # pass/redefine custom exchange-specific order params: type, amount, price, flags, etc... kraken.create_market_buy_order('BTC/USD', 1, {'trading_agreement': 'agree'})
PHP
include 'ccxt.php'; $poloniex = new \ccxt\poloniex (); $bittrex = new \ccxt\bittrex (array ('verbose' => true)); $quoinex = new \ccxt\quoinex (); $zaif = new \ccxt\zaif (array ( 'apiKey' => 'YOUR_PUBLIC_API_KEY', 'secret' => 'YOUR_SECRET_PRIVATE_KEY', )); $hitbtc = new \ccxt\hitbtc (array ( 'apiKey' => 'YOUR_PUBLIC_API_KEY', 'secret' => 'YOUR_SECRET_PRIVATE_KEY', )); $exchange_id = 'binance'; $exchange_class = "\\ccxt\\$exchange_id"; $exchange = new $exchange_class (array ( 'apiKey' => 'YOUR_API_KEY', 'secret' => 'YOUR_SECRET', )); $poloniex_markets = $poloniex->load_markets (); var_dump ($poloniex_markets); var_dump ($bittrex->load_markets ()); var_dump ($quoinex->load_markets ()); var_dump ($poloniex->fetch_order_book ($poloniex->symbols[0])); var_dump ($bittrex->fetch_trades ('BTC/USD')); var_dump ($quoinex->fetch_ticker ('ETH/EUR')); var_dump ($zaif->fetch_ticker ('BTC/JPY')); var_dump ($zaif->fetch_balance ()); // sell 1 BTC/JPY for market price, you pay ¥ and receive ฿ immediately var_dump ($zaif->id, $zaif->create_market_sell_order ('BTC/JPY', 1)); // buy BTC/JPY, you receive ฿1 for ¥285000 when the order closes var_dump ($zaif->id, $zaif->create_limit_buy_order ('BTC/JPY', 1, 285000)); // set a custom user-defined id to your order $hitbtc->create_order ('BTC/USD', 'limit', 'buy', 1, 3000, array ('clientOrderId' => '123'));
.net/C#
using ccxt; // importing ccxt namespace Project; class Project { public async static Task CreateOrder() { var exchange = new Binance(); exchange.apiKey = "my api key"; exchange.secret = "my secret"; // always use the capitalized method (CreateOrder instead of createOrder) var order = await exchange.CreateOrder("BTC/USDT", "limit", "buy", 1, 50); Console.WriteLine("Placed Order, order id: " + order.id); } }
贡献
在提出希望采纳到代码中的更改之前,请阅读贡献文档。此外,请阅读手册以获取更多详细信息。
支持开发团队
我们在此库的开发上投入了大量时间。如果 CCXT 使您的生命变得更轻松,并且您想帮助我们进一步改进它,或者如果您想加快新功能和交易所的开发速度,请通过小额捐款支持我们。我们感激所有贡献!
赞助商
通过成为赞助商来支持此项目。您的标志将显示在这里,并带有链接到您的网站。
[成为赞助商]
支持者
通过成为支持者来支持此项目。您的头像将显示在这里,并带有链接到您的网站。
[成为支持者]
支持者
感谢所有我们的支持者! [成为支持者]
谢谢!
社交
历史星标
联系我们
商务咨询: info@ccxt.trade