Skip to content

Commit

Permalink
examples
Browse files Browse the repository at this point in the history
  • Loading branch information
oliver-zehentleitner committed May 17, 2024
1 parent c80d498 commit 7ece840
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 37 deletions.
31 changes: 31 additions & 0 deletions examples/binance_depth_cache_limit_count/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Binance DepthCache Limit the number of returned list elements.
## Overview
Limit the number of returned list elements of `get_asks()` and `get_bids` with the parameter `limit_count`.

## Prerequisites
Ensure you have Python 3.7+ installed on your system.

Before running the provided script, install the required Python packages:
```bash
pip install -r requirements.txt
```

## Get a UNICORN Binance Suite License
To run modules of the *UNICORN Binance Suite* you need a [valid license](https://shop.lucit.services)!

## Usage
### Running the Script:
```bash
python binance_depth_cache_limit_count.py
```

### Graceful Shutdown:
The script is designed to handle a graceful shutdown upon receiving a KeyboardInterrupt (e.g., Ctrl+C) or encountering
an unexpected exception.

## Logging
The script employs logging to provide insights into its operation and to assist in troubleshooting. Logs are saved to a
file named after the script with a .log extension.

For further assistance or to report issues, please [contact our support team](https://www.lucit.tech/get-support.html)
or [visit our GitHub repository](https://github.com/LUCIT-Systems-and-Development/unicorn-binance-local-depth-cache).
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# ¯\_(ツ)_/¯

from unicorn_binance_local_depth_cache import BinanceLocalDepthCacheManager, DepthCacheOutOfSync
from unicorn_binance_rest_api import BinanceRestApiManager
from typing import Optional
import asyncio
import logging
Expand All @@ -22,6 +21,7 @@


async def main():
ubra = ubldc.get_ubra_manager()
markets: list = ['BTCUSDT', 'ETHUSDT', 'BNBUSDT']

print(f"Starting DepthCaches for markets: {markets}")
Expand All @@ -46,10 +46,8 @@ async def main():
time.sleep(0.2)


ubra = BinanceRestApiManager(exchange=exchange)
with BinanceLocalDepthCacheManager(exchange=exchange,
init_time_window=5,
ubra_manager=ubra,
websocket_ping_interval=10,
websocket_ping_timeout=15,
depth_cache_update_interval=update_interval_ms) as ubldc:
Expand Down
1 change: 0 additions & 1 deletion examples/binance_depth_cache_limit_count/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
python-dotenv
unicorn-binance-local-depth-cache>=2.0.0
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Version of this Package
# UBLDC Multi Markets
## Overview
This is the original script from https://ubldc-demo.lucit.tech
This example starts 40 DepthCaches with 1 second interval.

## Prerequisites
Ensure you have Python 3.7+ installed on your system.
Expand All @@ -16,7 +16,7 @@ To run modules of the *UNICORN Binance Suite* you need a [valid license](https:/
## Usage
### Running the Script:
```bash
python ubldc-demo.py
python binance_depth_cache_multi_markets.py
```

### Graceful Shutdown:
Expand All @@ -28,4 +28,4 @@ The script employs logging to provide insights into its operation and to assist
file named after the script with a .log extension.

For further assistance or to report issues, please [contact our support team](https://www.lucit.tech/get-support.html)
or [visit our GitHub repository](https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api).
or [visit our GitHub repository](https://github.com/LUCIT-Systems-and-Development/unicorn-binance-local-depth-cache).
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# ¯\_(ツ)_/¯

from unicorn_binance_local_depth_cache import BinanceLocalDepthCacheManager
from unicorn_binance_rest_api import BinanceRestApiManager
from typing import Optional
import asyncio
import logging
Expand Down Expand Up @@ -31,6 +30,7 @@ async def main():
'WANUSDT', 'DOCKUSDT', 'STORMUSDT', 'MFTUSDT', 'PERLUSDT', 'COCOSUSDT', 'NPXSUSDT',
'USDSBUSDT', 'GTOUSDT', 'WINUSDT', 'CVCUSDT', 'TOMOUSDT', 'COSUSDT', 'ERDUSDT', 'BUSDUSDT',
'BEAMUSDT', 'HCUSDT', 'MCOUSDT', 'CTXCUSDT']
ubra = ubldc.get_ubra_manager()
all_markets: list = [item['symbol'] for item in ubra.get_all_tickers() if item['symbol'].endswith("USDT")]
markets: list = []

Expand Down Expand Up @@ -58,10 +58,8 @@ async def main():
time.sleep(1)


ubra = BinanceRestApiManager(exchange=exchange)
with BinanceLocalDepthCacheManager(exchange=exchange,
init_time_window=5,
ubra_manager=ubra,
websocket_ping_interval=10,
websocket_ping_timeout=20,
depth_cache_update_interval=update_interval_ms) as ubldc:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
python-dotenv
unicorn-binance-local-depth-cache>=2.0.0
32 changes: 32 additions & 0 deletions examples/binance_depth_cache_threshold_volume/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Binance DepthCache Limits the number of returned list items by volume.
## Overview
Limit the number of returned list elements of `get_asks()` and `get_bids` by volume with the parameter
`threshold_volume`.

## Prerequisites
Ensure you have Python 3.7+ installed on your system.

Before running the provided script, install the required Python packages:
```bash
pip install -r requirements.txt
```

## Get a UNICORN Binance Suite License
To run modules of the *UNICORN Binance Suite* you need a [valid license](https://shop.lucit.services)!

## Usage
### Running the Script:
```bash
python binance_depth_cache_threshold_volume.py
```

### Graceful Shutdown:
The script is designed to handle a graceful shutdown upon receiving a KeyboardInterrupt (e.g., Ctrl+C) or encountering
an unexpected exception.

## Logging
The script employs logging to provide insights into its operation and to assist in troubleshooting. Logs are saved to a
file named after the script with a .log extension.

For further assistance or to report issues, please [contact our support team](https://www.lucit.tech/get-support.html)
or [visit our GitHub repository](https://github.com/LUCIT-Systems-and-Development/unicorn-binance-local-depth-cache).
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# ¯\_(ツ)_/¯

from unicorn_binance_local_depth_cache import BinanceLocalDepthCacheManager, DepthCacheOutOfSync
from unicorn_binance_rest_api import BinanceRestApiManager
from typing import Optional
import asyncio
import logging
Expand All @@ -23,6 +22,7 @@

async def main():
markets: list = ['BTCUSDT', 'ETHUSDT', 'BNBUSDT']
ubra = ubldc.get_ubra_manager()

print(f"Starting DepthCaches for markets: {markets}")
ubldc.create_depth_cache(markets=markets)
Expand All @@ -46,10 +46,8 @@ async def main():
time.sleep(0.2)


ubra = BinanceRestApiManager(exchange=exchange)
with BinanceLocalDepthCacheManager(exchange=exchange,
init_time_window=5,
ubra_manager=ubra,
websocket_ping_interval=10,
websocket_ping_timeout=15,
depth_cache_update_interval=update_interval_ms) as ubldc:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
python-dotenv
unicorn-binance-local-depth-cache>=2.0.0
2 changes: 1 addition & 1 deletion examples/ubldc-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ The script employs logging to provide insights into its operation and to assist
file named after the script with a .log extension.

For further assistance or to report issues, please [contact our support team](https://www.lucit.tech/get-support.html)
or [visit our GitHub repository](https://github.com/LUCIT-Systems-and-Development/unicorn-binance-websocket-api).
or [visit our GitHub repository](https://github.com/LUCIT-Systems-and-Development/unicorn-binance-local-depth-cache).
4 changes: 1 addition & 3 deletions examples/ubldc-demo/ubldc-demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

from dotenv import load_dotenv
from unicorn_binance_local_depth_cache import BinanceLocalDepthCacheManager, DepthCacheOutOfSync
from unicorn_binance_rest_api import BinanceRestApiManager
from typing import Optional
import asyncio
import logging
Expand All @@ -28,6 +27,7 @@


async def main():
ubra = ubldc.get_ubra_manager()
ubldc.create_depth_cache(markets=markets)
while ubldc.is_stop_request() is False:
add_string = (f"binance_api_status={ubra.get_used_weight(cached=True)}\r\n "
Expand Down Expand Up @@ -66,10 +66,8 @@ async def main():
await asyncio.sleep(10)


ubra = BinanceRestApiManager(exchange=exchange)
with BinanceLocalDepthCacheManager(exchange=exchange,
init_time_window=5,
ubra_manager=ubra,
websocket_ping_interval=10,
websocket_ping_timeout=15,
depth_cache_update_interval=update_interval_ms) as ubldc:
Expand Down
23 changes: 23 additions & 0 deletions examples/ubldc_package_update_check/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Version of this Package
## Overview
This shows how to obtain information about new versions programmatically.

## Prerequisites
Ensure you have Python 3.7+ installed on your system.

Before running the provided script, install the required Python packages:
```bash
pip install -r requirements.txt
```

## Get a UNICORN Binance Suite License
To run modules of the *UNICORN Binance Suite* you need a [valid license](https://shop.lucit.services)!

## Usage
### Running the Script:
```bash
python ubldc_package_update_check.py
```

For further assistance or to report issues, please [contact our support team](https://www.lucit.tech/get-support.html)
or [visit our GitHub repository](https://github.com/LUCIT-Systems-and-Development/unicorn-binance-local-depth-cache).
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# File: example_version_of_this_package.py
#
# Part of ‘UNICORN Binance Local Depth Cache’
# Project website: https://www.lucit.tech/unicorn-binance-local-depth-cache.html
# Github: https://github.com/LUCIT-Systems-and-Development/unicorn-binance-local-depth-cache
# Documentation: https://unicorn-binance-local-depth-cache.docs.lucit.tech
# PyPI: https://pypi.org/project/unicorn-binance-local-depth-cache
# LUCIT Online Shop: https://shop.lucit.services/software
#
# License: LSOSL - LUCIT Synergetic Open Source License
# https://github.com/LUCIT-Systems-and-Development/unicorn-binance-local-depth-cache/blob/master/LICENSE
#
# Author: LUCIT Systems and Development
#
# Copyright (c) 2022-2024, LUCIT Systems and Development (https://www.lucit.tech)
# All rights reserved.
# ¯\_(ツ)_/¯

from unicorn_binance_local_depth_cache import BinanceLocalDepthCacheManager

Expand Down

0 comments on commit 7ece840

Please sign in to comment.