Skip to main content

Binance API wrapper with backtesting tools.

Project description

Welcome to BinPan's documentation!

PyPI version Python License: MIT

BinPan is a Python wrapper for the Binance API oriented towards market data analysis: candlestick (kline) data, trades, technical indicators, plotting, and strategy backtesting.

It is intended to be useful in Jupyter Notebooks, the Python console, or any data pipeline.

Requires Python >= 3.12. Published on PyPI under the MIT license.

Features

  • Fetch candlestick (OHLCV) data with timezone and indexing options.
  • Fetch atomic and aggregated trades.
  • Native technical indicators (EMA, SMA, RSI, MACD, Bollinger Bands, Supertrend, Ichimoku, VWAP, Stochastic, fractals, and more).
  • Interactive candlestick charts with Plotly: indicators, buy/sell markers, trade bubble charts, order book, market profile.
  • Support and resistance detection via K-Means clustering (static, rolling, discrete interval).
  • Strategy tagging and backtesting engine with stop loss, target, entry filters, and ROI/profit metrics.
  • Exchange metadata: order types, filters, fees, coin networks, 24h volume ranking.
  • CSV export/import for klines and trades.
  • PostgreSQL/TimescaleDB integration for historical data storage.
  • Heikin-Ashi candles, reversal charts from tick data, kline resampling.

An example of a candlestick chart with indicators:

BinPan contains no Binance order method, withdraw method or any dangerous command.

If you decide to add API keys for account methods, BinPan will encrypt them in a file and in memory, but it is recommended not to enable trading capability in your Binance API key configuration.

Be careful out there!

Installation

pip install binpan

Any API key or secret will be prompted when needed and encrypted in a file.

Quick Start

import binpan

btcusdt = binpan.Symbol(symbol='btcusdt',
                        tick_interval='15m',
                        time_zone='Europe/Madrid',
                        limit=200)

btcusdt.ema(21)
btcusdt.supertrend()
btcusdt.plot()

Example Notebooks

The notebooks/ folder contains example Jupyter Notebooks organized by topic:

# Notebook Topic
01 basic_tutorial Getting started: data, indicators, plots, trades
02 data_analysis Analysis: indicators, trades, market profile, order book
03 technical_indicators Full indicator catalogue
04 plotting All visualization capabilities
05 reversal_charts Reversal candles from atomic trades
06 tagging_and_backtesting Strategy signals and backtesting
07 support_resistance_kmeans S/R with K-Means clustering
08-10 ichimoku_* Ichimoku analysis and backtesting
11 exchange_info Exchange class: metadata, filters, fees
12 export_csv CSV export/import
13-15 database_* PostgreSQL/TimescaleDB integration

Documentation

Full Sphinx documentation: https://nand0san.github.io/binpan_studio/

GitHub repo

https://github.com/nand0san/binpan_studio

Google Colab

Google Colab is not available for the Binance API due to IP restrictions.

BinanceAPIException: APIError(code=0): Service unavailable from a restricted location...

Jupyter Import Troubleshooting

If you encounter import errors in Jupyter, install packages directly to the kernel:

import sys
!{sys.executable} -m pip install binpan

License

MIT

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

binpan-0.9.6.tar.gz (185.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

binpan-0.9.6-py3-none-any.whl (195.5 kB view details)

Uploaded Python 3

File details

Details for the file binpan-0.9.6.tar.gz.

File metadata

  • Download URL: binpan-0.9.6.tar.gz
  • Upload date:
  • Size: 185.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for binpan-0.9.6.tar.gz
Algorithm Hash digest
SHA256 c0d2107af44a7cf84f37831045c3075261055017b31fbe45d63e91eff021edbf
MD5 f672b19a09d463a32fe12c9f534f03d0
BLAKE2b-256 e5f6d443c12f2bcf0e7dab087806de2016beb382d5978735dde5e5aa8790ba4c

See more details on using hashes here.

File details

Details for the file binpan-0.9.6-py3-none-any.whl.

File metadata

  • Download URL: binpan-0.9.6-py3-none-any.whl
  • Upload date:
  • Size: 195.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for binpan-0.9.6-py3-none-any.whl
Algorithm Hash digest
SHA256 e491ced1135e622ef16d3f6e54f31ed3b8e8584bd02dc4725460235364ccac8a
MD5 e0e70e76f9e910e7acd29f17df758e49
BLAKE2b-256 a9aab30552e737d28cf2256ced2d187bceed9ac9e5ea1768fd62d8b46b2e0316

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page