Skip to content

Commit

Permalink
initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
joakimhellum committed Dec 1, 2024
1 parent 0c4578c commit 90cedaa
Show file tree
Hide file tree
Showing 8 changed files with 898 additions and 2 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: test
on:
pull_request:
jobs:
test:
runs-on: ubuntu-latest
container:
image: ghcr.io/system4-tech/task-runner:ubuntu
steps:
- name: Checkout repository
uses: actions/checkout@v4

- run: make deps

- name: Check scripts
run: make shellcheck

- name: Run tests
run: make test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib/
2 changes: 2 additions & 0 deletions .shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
external-sources=true
source-path=SCRIPTDIR
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
all: clean deps shellcheck test build
deps:
@wget https://raw.githubusercontent.com/system4-tech/binance-sh/refs/heads/main/lib/binance.sh -qP lib/
build:
@awk -f inline.awk src/main.sh > dist/binance-data-downloader.sh
@chmod +x dist/binance-data-downloader.sh
clean:
@rm -f lib/*.sh dist/*.sh
test:
@bats tests/*.bats
shellcheck:
@shellcheck src/*.sh
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,28 @@
# binance-data-downloader
Downloads Binance public market data in various formats (NJSON, CSV and TSV).
# [`binance-data-downloader.sh`](dist/binance-data-downloader.sh)

This repository contains shell scripts for downloading Binance public market data in various formats (NDJSON, CSV and TSV).

## Usage

```sh
$ binance-data-downloader -h
Usage: $0 -p <product> -i <interval> -s <start_time> [-e <end_time>] [-f <format>] [-o <output_dir>]

Options:
-p Product: spot, um, cm [required]
-i Interval (e.g., 1d, 1h, 15m) [required]
-s Start time [required]
-e End time (default: current time)
-f Output format: csv, tsv, ndjson (default: csv)
-o Output directory (default: current directory)
-h Show this help message

# Download CSV data for all spot symbols since 2019-01-01
$ binance-data-downloader.sh -p spot -i 1d -s 2019-01-01 -f csv -o data/spot/
data/spot/BTCUSDT_2019-01-01_2024-11-29.csv
data/spot/ETHUSDT_2019-01-01_2024-11-29.csv
data/spot/BNBUSDT_2019-01-01_2024-11-29.csv
...
```

See [tests](tests/) for more examples.
Loading

0 comments on commit 90cedaa

Please sign in to comment.