UBCI(Upbit Crypto Index) Query Module
Project description
pyubci
UBCI (Upbit Crypto Index) Query Module for Python
Overview
UBCI is a Python module that provides access to cryptocurrency indices from the UBCI(https://www.ubcindex.com). This module interfaces with the UBC Index API to fetch and manage a subset of available indices, including market indices, strategy indices, theme indices, and sector indices.
Features
- Access to multiple index types (Market, Strategy, Theme, Sector) from UBCI
- Efficient caching mechanism with disk persistence
- Command-line interface for easy querying
- Comprehensive logging system
- Real-time data updates
Class: UBCI
Initialization
from pyubci import UBCI
# Create UBCI instance
ubci = UBCI()
Key Properties
MARKET_CODES: List of market index codesSTRATEGY_CODES: List of strategy index codesTHEME_CODES: List of theme index codesSECTOR_CODES: List of sector index codes
Methods
Data Management
update_index_data(): Updates all index data from UBC Index API with daily caching_load_cache_from_disk(): Loads cached data from disk_save_cache_to_disk(): Saves current cache data to disk_cleanup_old_cache(days_to_keep=7): Cleans up old cache entries
Data Retrieval
get_markets_by_ticker(ticker): Get market indices for a ticker, returns a list of tuples of (index_code, index_name)get_strategies_by_ticker(ticker): Get strategy indices for a ticker, returns a list of tuples of (index_code, index_name)get_themes_by_ticker(ticker): Get theme indices for a ticker, returns a list of tuples of (index_code, index_name)get_sectors_by_ticker(ticker): Get sector indices for a ticker, returns a list of tuples of (index_code, index_name)get_all_markets(): Get all available market indices, returns a list of tuples of (index_code, index_name)get_all_sectors(): Get all available sector indices, returns a list of tuples of (index_code, index_name)get_all_strategies(): Get all available strategy indices, returns a list of tuples of (index_code, index_name)get_all_themes(): Get all available theme indices, returns a list of tuples of (index_code, index_name)get_tickers_by_market(market_code): Get all tickers in a market index, returns a list of tuples of (ticker_name, weight)get_tickers_by_strategy(strategy_code): Get all tickers in a strategy index, returns a list of tuples of (ticker_name, weight)get_tickers_by_theme(theme_code): Get all tickers in a theme index, returns a list of tuples of (ticker_name, weight)get_tickers_by_sector(sector_code): Get all tickers in a sector index, returns a list of tuples of (ticker_name, weight)
Caching System
The UBCI module implements an efficient caching system that:
- Stores API responses locally
- Updates cache daily
- Maintains a 7-day cache history
- Persists data between sessions
Command Line Interface
The UBCI module includes a command-line interface for easy querying:
# Direct index queries
ubci UBMI # List all tickers in market UBMI
ubci SCTIDXA # List all tickers in sector SCTIDXA
ubci UBSI001 # List all tickers in strategy UBSI001
ubci THMIDX17 # List all tickers in theme THMIDX17
ubci KRW-BTC # Show information for ticker KRW-BTC
# List available indices by type
ubci market # List all available markets
ubci market UBMI # List all tickers in market UBMI
ubci sector # List all available sectors
ubci sector SCTIDXA # List all tickers in sector SCTIDXA
ubci strategy # List all available strategies
ubci strategy UBSI001 # List all tickers in strategy UBSI001
ubci theme # List all available themes
ubci theme THMIDX17 # List all tickers in theme THMIDX17
Error Handling
The module implements comprehensive error handling:
- API request failures
- Cache read/write errors
- Invalid ticker formats
- Data validation errors
Logging
Logging is configured with multiple handlers:
- File logging for general operations (INFO level)
- Console logging for warnings (WARNING level)
- Debug logging for detailed troubleshooting
Best Practices
- Initialize UBCI once and reuse the instance
- Let the caching system handle data updates
- Use appropriate error handling when querying data
- Monitor logs for potential issues
Dependencies
- requests: For API calls
- logging: For logging system
- datetime: For timestamp handling
- json: For cache serialization
Example Usage
from pyubci import UBCI
# Initialize UBCI
ubci = UBCI()
# Get market information for BTC
btc_market_indices = ubci.get_markets_by_ticker('KRW-BTC')
for index_code, index_name in btc_market_indices:
print(f'{index_code}: {index_name}')
# Get sector information for ETH
eth_sector_indices = ubci.get_sectors_by_ticker('KRW-ETH')
Notes
- The module automatically handles cache updates
- API rate limiting is handled internally
- Cache is maintained for 7 days by default
- All timestamps are in local time
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyubci-0.1.0.tar.gz.
File metadata
- Download URL: pyubci-0.1.0.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3b86a5c6ee14ce7a79d0e09b3a0e8cc3e69d5504698d7cb4c3134345dc4adc46
|
|
| MD5 |
96c43ee74fdf0661959868d60cfb5c1c
|
|
| BLAKE2b-256 |
919395e044861a953da0986c4f484c3a178f9d57457b303185cf17b89976fc22
|
Provenance
The following attestation bundles were made for pyubci-0.1.0.tar.gz:
Publisher:
publish.yml on kyungw00k/pyubci
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyubci-0.1.0.tar.gz -
Subject digest:
3b86a5c6ee14ce7a79d0e09b3a0e8cc3e69d5504698d7cb4c3134345dc4adc46 - Sigstore transparency entry: 171488305
- Sigstore integration time:
-
Permalink:
kyungw00k/pyubci@77912496d5a16eb98cc075c8841a3b491fef47f3 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kyungw00k
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@77912496d5a16eb98cc075c8841a3b491fef47f3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pyubci-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyubci-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
158a2367728d5a5d979ca407383dbe0f6f71ddc4df35ed34d20f5efaef9159b2
|
|
| MD5 |
6e06aab8a85ada10a039dee4ae9a730b
|
|
| BLAKE2b-256 |
e1b4fff78560ee71591561f8c12d955effcb61e510a2b86155b9df801304b808
|
Provenance
The following attestation bundles were made for pyubci-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on kyungw00k/pyubci
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyubci-0.1.0-py3-none-any.whl -
Subject digest:
158a2367728d5a5d979ca407383dbe0f6f71ddc4df35ed34d20f5efaef9159b2 - Sigstore transparency entry: 171488307
- Sigstore integration time:
-
Permalink:
kyungw00k/pyubci@77912496d5a16eb98cc075c8841a3b491fef47f3 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/kyungw00k
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@77912496d5a16eb98cc075c8841a3b491fef47f3 -
Trigger Event:
push
-
Statement type: