Skip to main content

连接 Huobi 火币交易所,获取实时行情、历史行情,保存到mysql数据库同时redis广播,供 IBATS 交易平台进行策略回测、分析,交易使用

Project description

# [Huobi Feeder](https://github.com/IBATS/IBATS_HuobiFeeder)
连接火币交易所

通过 feed.md_feeder 接受事实行情及补充历史数据

通过 backend.handler 处理实时行情,保持到数据库,进行redis广播

该项目作为 IBATS 框架的 Feeder 组件可独立部署



## 安装

#### 系统环境要求:

> Python 3.6
>
> MySQL 5.7 [配置方法总结了一下,见下文](#mysql-配置方法)
>
> Redis 3.0.6

#### 安装必要python包

Windows环境

> pip install -r requirements.txt

Linux环境

> pip3 install -r requirements.txt

#### 配置文件

config.py
基础配置

1 ) MYSQL数据库用户名、密码
```python
DB_SCHEMA_MD = 'md_huobi'
DB_URL_DIC = {
DB_SCHEMA_MD: 'mysql://m*:****@10.0.3.66/' + DB_SCHEMA_MD
}
```
2 ) 火币交易所 EXCHANGE_ACCESS_KEY、EXCHANGE_SECRET_KEY
```python
# api configuration
EXCHANGE_ACCESS_KEY = ""
EXCHANGE_SECRET_KEY = ""
```

可选配置

1 ) Redis 路径
```python
# redis info
REDIS_PUBLISHER_ENABLE = True
REDIS_INFO_DIC = {'REDIS_HOST': 'localhost',
'REDIS_PORT': '6379',
}
```
#### 启动方法

直接运行 run.bat

启动过程中会自动建立相应数据库表结构



## 存储及服务

存储mysql数据库

> md_min1_tick_bc tick数据
>
> my_min1_bc 一分钟数据
>
> md_min60_bc 一小时数据
>
> md_daily_bc 日数据

## 实时行情Redis广播服务

channel格式:

```
md.{market}.{period}.{symbol}
# 例如:
# md.huobi.Min1.ethusdt
# md.huobi.Tick.eosusdt
```
订阅方式:
SUBSCRIBE md.huobi.Tick.eosusdt


## 欢迎赞助

#### 微信

![微信支付](https://github.com/mmmaaaggg/ABAT_trader_4_blockchain/blob/master/mass/webchat_code200.png?raw=true)

#### 支付宝

![微信支付](https://github.com/mmmaaaggg/ABAT_trader_4_blockchain/blob/master/mass/alipay_code200.png?raw=true)

#### 微信打赏(¥10)

![微信打赏](https://github.com/mmmaaaggg/ABAT_trader_4_blockchain/blob/master/mass/dashang_code200.png?raw=true)

## MySQL 配置方法

1. Ubuntu 18.04 环境下安装 MySQL,5.7

```bash
sudo apt install mysql-server
```
2. 默认情况下,没有输入用户名密码的地方,因此,安装完后需要手动重置Root密码,方法如下:

```bash
cd /etc/mysql/debian.cnf
sudo more debian.cnf
```
出现类似这样的东西
```bash
# Automatically generated for Debian scripts. DO NOT TOUCH!
[client]
host = localhost
user = debian-sys-maint
password = j1bsABuuDRGKCV5s
socket = /var/run/mysqld/mysqld.sock
[mysql_upgrade]
host = localhost
user = debian-sys-maint
password = j1bsABuuDRGKCV5s
socket = /var/run/mysqld/mysqld.sock
```

以debian-sys-maint为用户名登录,密码就是debian.cnf里那个 password = 后面的东西。
使用mysql -u debian-sys-maint -p 进行登录。
进入mysql之后修改MySQL的密码,具体的操作如下用命令:
```mysql
use mysql;

update user set authentication_string=PASSWORD("Dcba4321") where user='root';

update user set plugin="mysql_native_password";

flush privileges;
```
3. 然后就可以用过root用户登陆了

```bash
mysql -uroot -p
```

4. 创建用户 mg 默认密码 Abcd1234

```mysql
CREATE USER 'mg'@'%' IDENTIFIED BY 'Abcd1234';
```
5. 创建数据库 bc_md

```mysql
CREATE DATABASE `bc_md` default charset utf8 collate utf8_general_ci;
```
6. 授权

```mysql
grant all privileges on bc_md.* to 'mg'@'localhost' identified by 'Abcd1234';

flush privileges; #刷新系统权限表
```


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

IBATS_Huobi_Feeder-0.1.3.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

IBATS_Huobi_Feeder-0.1.3-py3-none-any.whl (31.0 kB view details)

Uploaded Python 3

File details

Details for the file IBATS_Huobi_Feeder-0.1.3.tar.gz.

File metadata

  • Download URL: IBATS_Huobi_Feeder-0.1.3.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.13.0 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.5.5

File hashes

Hashes for IBATS_Huobi_Feeder-0.1.3.tar.gz
Algorithm Hash digest
SHA256 93a033f124acb7cc86d090da466da2ebb3689b896de82f10ed33d49c32365177
MD5 e2f4619c388423a1ad8e20d38165215c
BLAKE2b-256 069db1976ec281395c44273fb664317e29d59a702ade213a7df13710217dc790

See more details on using hashes here.

File details

Details for the file IBATS_Huobi_Feeder-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: IBATS_Huobi_Feeder-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 31.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.13.0 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.5.5

File hashes

Hashes for IBATS_Huobi_Feeder-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 824a9fa19434e4fdda1ea3df65f360c54b14b9c0da61b70ddc6e79af9bab8d48
MD5 fdd673fdff7b59eef7aa0651b57ba346
BLAKE2b-256 e3894b7f9bb16d17456abe4ec83fd71e3f0e8c47d566f8acac64d615a26888f5

See more details on using hashes here.

Supported by

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