Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
BinanceKlines - A tool to download OHLCV candlestick data (K-Lines) from Binance. Written in Python.
BinanceKlines downloader is a simple command line tool and Python library used to download OHLCV k-lines from Binance. It works asynchronously to download candlestick market data from multiple symbols concurrently.
$ git clone git@github.com:fievelk/binance-klines.git # Clone the project
$ cd binance-klines/
$ pip install .
BinanceKlines can be used both as command line tool and Python module. The tool fetches data from Binance's GET /api/v3/klines
endpoint.
You can check all the available options using binance-klines --help
.
$ binance-klines --help
usage: binance-klines [-h] [-v] --start-date START_DATE [--end-date END_DATE] [-o OUTPUT_DIR]
[--timeframe {1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M}]
symbols [symbols ...]
positional arguments:
symbols The list of currencies whose OHLCV will be fetched.
options:
-h, --help show this help message and exit
-v, --verbose Increase output verbosity. -v: INFO, -vv: DEBUG.
Default: WARNING.
--start-date START_DATE
(Required) Start downloading data from this date. E.g.: 2019-01-24 00:00:00
--end-date END_DATE Download data up to this date. E.g.: 2020-05-30 00:00:00.
Default: now.
-o OUTPUT_DIR, --output-dir OUTPUT_DIR
The data directory to store the output CSV files.
Default: the current directory.
--timeframe {1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w,1M}
The frequency of the OHLCV data to be downloaded.
Default: 1h.
Here is an example of how to download 1-minutes candlestick data for BTC/USDT and ETH/USDT from 18th July 2022 to 20th July 2022:
$ binance-klines --start-date "2022-07-18 00:00:00" \
--end-date "2022-07-20 23:59:00" --timeframe '1m' --output-dir .data/ \
--symbols BTC/USDT ETH/USDT
import asyncio
import datetime
import pytz
from binance_klines.downloader import BinanceKLinesDownloader
async def main():
downloader = BinanceKLinesDownloader()
start_date = datetime.datetime(2020, 9, 1).replace(tzinfo=pytz.utc)
end_date = datetime.datetime(2020, 9, 2).replace(tzinfo=pytz.utc)
# Download data for a single symbol. Data is downloaded in batches.
results = await downloader.fetch_klines(
symbols=["BTC/USDT", "ETH/USDT"],
start_date=start_date,
end_date=end_date,
timeframe="30m",
)
# Results contain the klines for each symbol, in the order that was passed to the
# `symbols` argument.
btc_batches = results[0]
eth_batches = results[1]
if __name__ == "__main__":
asyncio.run(main())
Tests are written using pytest
. To test compatibility among several Python versions, install the dev dependencies using Poetry and run tests using tox:
$ poetry install --with dev # Install dependencies
$ poetry shell # Activate Poetry environment
$ tox
You are welcome to contribute by opening a PR with your improvements. Please make sure to run the Black linter before you do. You can use tox
for this:
$ tox -e lint
FAQs
BinanceKlines - A tool to download OHLCV candlestick data (K-Lines) from Binance. Written in Python.
We found that binance-klines demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.