From 2e315240d93772931abdfbee716a2123cfa279c0 Mon Sep 17 00:00:00 2001 From: zenix Date: Wed, 30 Nov 2022 12:41:25 +0900 Subject: [PATCH] feature: add sync_time.sh utility --- README.md | 17 +++++++++++++++++ scripts/sync_time.sh | 3 +++ 2 files changed, 20 insertions(+) create mode 100755 scripts/sync_time.sh diff --git a/README.md b/README.md index e73bd531f..d7bad59f2 100644 --- a/README.md +++ b/README.md @@ -232,6 +232,23 @@ bbgo pnl --exchange binance --asset BTC --since "2019-01-01" ## Advanced Configuration +### Synchronize System Time With Binance + +BBGO provides the script for UNIX systems/subsystems to synchronize date with Binance. `jq` and `bc` are required to be installed in previous. +To install the dependencies in Ubuntu, try the following commands: + +```bash +sudo apt install -y bc jq +``` + +And to synchronize the date, try: + +```bash +sudo ./scripts/sync_time.sh +``` + +You could also add the script to crontab so that the system time could get synchronized with Binance regularly. + ### Testnet (Paper Trading) Currently only supports binance testnet. To run bbgo in testnet, apply new API keys diff --git a/scripts/sync_time.sh b/scripts/sync_time.sh new file mode 100755 index 000000000..c3765bf9f --- /dev/null +++ b/scripts/sync_time.sh @@ -0,0 +1,3 @@ +#!/usr/bin/sh + +date -s @`echo "$(curl https://api.binance.com/api/v3/time 2>/dev/null | jq .serverTime)/1000"|bc -l`