Skip to main content

Candle data management tool

Project description

Candle Data Manager

Candle data management tool for cryptocurrency and stock markets.

Installation

pip install candle-data-manager

Requirements

  • Python >= 3.10
  • MySQL Server

Overview

Initialize

from candle_data_manager import CandleDataAPI

# Default: mysql+pymysql://root@localhost/candle_data_manager
api = CandleDataAPI()

# Or with custom database URL
api = CandleDataAPI(database_url="mysql+pymysql://user:password@host/dbname")

Active Update

Fetch and store all historical data for symbols.

# Update all Binance Futures PERPETUAL markets
result = api.active_update(
    archetype="CRYPTO",
    exchange="BINANCE",
    tradetype="FUTURES"
)

# Update specific symbol with filters
result = api.active_update(
    archetype="CRYPTO",
    exchange="BINANCE",
    tradetype="SPOT",
    base="BTC",
    quote="USDT",
    timeframe="1d"
)

print(f"Success: {result.success_count}, Failed: {result.fail_count}, Rows: {result.total_rows}")

Passive Update

Incremental update for registered symbols.

result = api.passive_update(
    archetype="CRYPTO",
    exchange="BINANCE"
)

Load Data

Load candle data as Market objects.

markets = api.load(
    archetype="CRYPTO",
    exchange="BINANCE",
    tradetype="SPOT",
    base="BTC",
    quote="USDT",
    timeframe="1h",
    start_at=1609459200,
    end_at=1609545600
)

for market in markets:
    print(market.symbol)
    print(market.candles)  # pandas DataFrame

API Reference

CandleDataAPI

Method Description
__init__(database_url=None) Initialize API with MySQL connection. Creates database schema and tables if not exists. Default: mysql+pymysql://root@localhost/candle_data_manager
active_update(archetype, exchange, tradetype, base, quote, timeframe) Register new symbols from exchange market list and fetch all historical candle data from the earliest available timestamp. Filters can be string or list (e.g., base=["BTC", "ETH"]). Returns UpdateResult with success/fail counts and total rows.
passive_update(archetype, exchange, tradetype, base, quote, timeframe, buffer_size) Incremental update for registered symbols. Fetches candles from the last stored timestamp to current time, updating the last candle and appending new candles. Returns UpdateResult.
load(archetype, exchange, tradetype, base, quote, timeframe, start_at, end_at) Load candle data from database as Market objects. Each Market contains symbol and candles (pandas DataFrame with OHLCV columns). Auto-fetches missing data if not in database.
get_symbol(symbol_str) Get Symbol object by string identifier. Format: "ARCHETYPE-EXCHANGE-TRADETYPE-BASE-QUOTE-TIMEFRAME" (e.g., "CRYPTO-BINANCE-SPOT-BTC-USDT-1h"). Returns None if not found.
close() Close all database connections and release resources.

Supported Providers

Provider Archetype Exchange TradeType
Binance Spot CRYPTO BINANCE SPOT
Binance Futures CRYPTO BINANCE FUTURES
Upbit CRYPTO UPBIT SPOT

License

MIT License

Project details


Download files

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

Source Distribution

candle_data_manager-0.1.0.tar.gz (178.8 kB view details)

Uploaded Source

Built Distribution

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

candle_data_manager-0.1.0-py3-none-any.whl (113.5 kB view details)

Uploaded Python 3

File details

Details for the file candle_data_manager-0.1.0.tar.gz.

File metadata

  • Download URL: candle_data_manager-0.1.0.tar.gz
  • Upload date:
  • Size: 178.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for candle_data_manager-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cabd16e6ae08617e7a57e856677f88ebf42c6d1262588e61de734f6e3a34aa7a
MD5 d7c988e05a5caeec0371a598e302ba9d
BLAKE2b-256 4f937eba67a8c7673f898821be2fc3b0f59e58e266e4b2551059a4ff8dfb9e60

See more details on using hashes here.

File details

Details for the file candle_data_manager-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for candle_data_manager-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dfdb5ab5b1ec1f655bf86f89c8ead0ccc8f2b6b9f08807789d28e58ff52385d3
MD5 7850f1da5c6a5b91a9ed31a477d87afb
BLAKE2b-256 311859992eca45aa5bc19ea7a0304aa1d35eafad52624acdb9e8f14d4a5b13dd

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