2022-03-07 04:06:16 +00:00
|
|
|
# pybbgo
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
```sh
|
|
|
|
cd <path/to/bbgo/python>
|
|
|
|
pip install .
|
|
|
|
```
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
### Stream
|
|
|
|
|
|
|
|
```python
|
2022-04-13 15:25:23 +00:00
|
|
|
from loguru import logger
|
|
|
|
|
2022-03-07 04:06:16 +00:00
|
|
|
from bbgo import Stream
|
2022-04-13 15:25:23 +00:00
|
|
|
from bbgo.data import Event
|
|
|
|
from bbgo.handlers import UpdateHandler
|
|
|
|
|
|
|
|
|
|
|
|
class LogBook(UpdateHandler):
|
|
|
|
|
|
|
|
def handle(self, event: Event) -> None:
|
|
|
|
logger.info(event)
|
|
|
|
|
|
|
|
|
|
|
|
host = '127.0.0.1'
|
|
|
|
port = 50051
|
|
|
|
|
|
|
|
stream = Stream(host, port)
|
|
|
|
stream.subscribe('max', 'book', 'BTCUSDT', 'full')
|
|
|
|
stream.subscribe('max', 'book', 'ETHUSDT', 'full')
|
|
|
|
stream.add_event_handler(LogBook())
|
2022-03-07 04:06:16 +00:00
|
|
|
stream.start()
|
2022-03-15 14:10:39 +00:00
|
|
|
```
|