Skip to main content

Tokenometry

PyPI version Python versions License: MIT

A sophisticated, multi-strategy crypto analysis bot for generating trading signals based on technical analysis, market sentiment, and on-chain data.

🚀 Features

  • Multi-Strategy Support: Day trading, swing trading, and long-term investment strategies
  • Multi-Timeframe Analysis: Combines higher timeframe trends with lower timeframe signals
  • Technical Indicators: EMA/SMA crossovers, RSI, MACD, ATR for comprehensive analysis
  • Volume Filter: Optional volume spike confirmation for improved signal quality
  • Signal Strength Analysis: Advanced scoring system rating signals as "Low", "Medium", or "Strong"
  • Risk Management: Automatic stop-loss calculation and position sizing
  • Professional Logging: Comprehensive audit trail and monitoring
  • API Integration: Coinbase Advanced Trade API for real-time data
  • Configurable: Easy strategy customization through configuration dictionaries

📦 Installation

pip install tokenometry

🎯 Quick Start

from tokenometry import Tokenometry
import logging

# Configure your strategy
config = {
    "STRATEGY_NAME": "Day Trader",
    "PRODUCT_IDS": ["BTC-USD", "ETH-USD"],
    "GRANULARITY_SIGNAL": "FIVE_MINUTE",
    "GRANULARITY_TREND": "ONE_HOUR",
    "SHORT_PERIOD": 9,
    "LONG_PERIOD": 21,
    "RISK_PER_TRADE_PERCENTAGE": 0.5,
    "ATR_STOP_LOSS_MULTIPLIER": 2.0,
    # ... more configuration options
}

# Initialize the bot
logger = logging.getLogger("MyBot")
bot = Tokenometry(config=config, logger=logger)

# Run analysis
signals = bot.scan()
for signal in signals:
    print(f"Signal: {signal}")
    print(f"Strength: {signal.get('strength', 'Unknown')}")

🔍 Signal Strength Analysis

When a valid BUY or SELL signal is found, the bot performs a secondary analysis to score its strength based on three key factors:

RSI Extremity

How deep into "oversold" or "overbought" territory is the RSI? A signal that occurs when the RSI is below 30 (for a buy) is stronger than one that occurs when it's at 50.

MACD Momentum

What is the momentum behind the crossover? This is measured by the MACD Histogram (the distance between the MACD line and its signal line). A large, expanding histogram indicates powerful momentum and a stronger signal.

Volume Conviction

How significant was the volume spike? A crossover that occurs on a volume spike 3x the recent average is a much stronger signal than one that occurs on a 1.5x spike.

These factors are combined into a "strength score," which is then translated into a simple "Low," "Medium," or "Strong" rating that is included with the signal notification. This allows you to prioritize and have more confidence in the high-strength signals.

🎲 Strategy Configurations

Day Trader (High-Frequency)

  • Timeframe: 5-minute signals, 1-hour trend
  • Best for: Active day traders, scalping
  • Risk: 0.5% per trade

Swing Trader (Medium-Term)

  • Timeframe: 4-hour signals, daily trend
  • Best for: Part-time traders, swing trading
  • Risk: 1.0% per trade

Long-Term Investor

  • Timeframe: Daily signals, weekly trend
  • Best for: Position traders, long-term investors
  • Risk: 1.0% per trade

🔧 Configuration Options

config = {
    "STRATEGY_NAME": "Custom Strategy",
    "PRODUCT_IDS": ["BTC-USD", "ETH-USD", "SOL-USD"],
    "GRANULARITY_SIGNAL": "FIVE_MINUTE",  # Signal timeframe
    "GRANULARITY_TREND": "ONE_HOUR",      # Trend timeframe
    "SHORT_PERIOD": 9,                    # Fast EMA/SMA period
    "LONG_PERIOD": 21,                    # Slow EMA/SMA period
    "RSI_PERIOD": 14,                     # RSI calculation period
    "RSI_OVERBOUGHT": 70,                 # RSI overbought threshold
    "RSI_OVERSOLD": 30,                   # RSI oversold threshold
    "MACD_FAST": 12,                      # MACD fast period
    "MACD_SLOW": 26,                      # MACD slow period
    "MACD_SIGNAL": 9,                     # MACD signal period
    "ATR_PERIOD": 14,                     # ATR calculation period
    "VOLUME_FILTER_ENABLED": True,        # Enable volume filter (optional)
    "VOLUME_MA_PERIOD": 20,               # Volume moving average period
    "VOLUME_SPIKE_MULTIPLIER": 2.0,       # Volume spike multiplier
    "HYPOTHETICAL_PORTFOLIO_SIZE": 100000.0,  # Portfolio size for calculations
    "RISK_PER_TRADE_PERCENTAGE": 1.0,    # Risk per trade percentage
    "ATR_STOP_LOSS_MULTIPLIER": 2.5,     # ATR multiplier for stop-loss
}

📊 Signal Types

  • BUY: Golden cross + bullish trend + RSI not overbought + MACD bullish + volume spike (if enabled)
  • SELL: Death cross + bearish trend + RSI not oversold + MACD bearish + volume spike (if enabled)
  • HOLD: No clear signal or conflicting indicators

Each signal includes a strength rating ("Low", "Medium", or "Strong") based on:

  • RSI extremity (how deep into oversold/overbought territory)
  • MACD momentum (histogram size and expansion)
  • Volume conviction (spike magnitude relative to average)

🔧 Volume Filter

The volume filter improves signal quality by requiring significant volume spikes to confirm technical crossovers:

# Enable volume filter
config["VOLUME_FILTER_ENABLED"] = True
config["VOLUME_MA_PERIOD"] = 20          # Volume moving average period
config["VOLUME_SPIKE_MULTIPLIER"] = 2.0  # Current volume must be 2x the average

# Disable volume filter (default)
config["VOLUME_FILTER_ENABLED"] = False

Benefits:

  • Reduces false signals by requiring volume confirmation
  • Only trades with significant volume spikes
  • Configurable sensitivity via multiplier
  • Optional feature - can be disabled for more signals

🛡️ Risk Management

  • Automatic Stop-Loss: Calculated using ATR for volatility-adjusted stops
  • Position Sizing: Based on your risk percentage and stop-loss distance
  • Portfolio Protection: Each trade risks only the specified percentage

📝 Logging & Monitoring

import logging

# Set up logging
logger = logging.getLogger("MyBot")
logger.setLevel(logging.INFO)

# Console output
console_handler = logging.StreamHandler()
logger.addHandler(console_handler)

# File logging
file_handler = logging.FileHandler("trading_bot.log")
logger.addHandler(file_handler)

🔌 API Requirements

  • Coinbase Advanced Trade API: Required for price data
  • NewsAPI (optional): For sentiment analysis
  • Glassnode API (optional): For on-chain data

📚 Examples

Check out the examples/ directory for complete working examples:

  • example_usage.py: Basic usage with all three strategies
  • Custom strategy configurations
  • Risk management examples

🧪 Testing

# Install development dependencies
pip install tokenometry[dev]

# Run tests
pytest tests/

📈 Performance

  • Analysis Speed: Optimized for real-time trading
  • Memory Usage: Efficient data handling with pandas
  • API Efficiency: Smart pagination and rate limiting
  • Scalability: Configurable for multiple assets and timeframes

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Disclaimer

This tool is for analytical and educational purposes only. It is not financial advice. The signals generated are based on algorithmic analysis and do not guarantee any specific outcome. Always conduct your own research and consult with a qualified financial advisor before making investment decisions.


Made with ❤️ for the crypto trading community

Metadata

Release files for tokenometry 1.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tokenometry 1.0.7
File Size Uploaded
tokenometry-1.0.7.tar.gz 22.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tokenometry 1.0.7
File Interpreter ABI Platform
tokenometry-1.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 33.3 kB

Release files / tokenometry-1.0.7.tar.gz

Download URL tokenometry-1.0.7.tar.gz
Size 22.4 kB
Tags Source
SHA-256 checksum
How to use checksums
47ce52c32085c369e6055eb5e2c7c1899c441f45ca3e7590d8567b6ef36437f9
BLAKE2b-256 checksum
How to use checksums
425398f8b1ae3282a51a54eac2df71f2700c097ea4e74593c83f926d23a6eb0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.6

Release files / tokenometry-1.0.7-py3-none-any.whl

Download URL tokenometry-1.0.7-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0332b6657e389546c066dd2a42829d6803767179a62963be55c39f8f72dd84ef
BLAKE2b-256 checksum
How to use checksums
1349c4d605e9a4991a2391527e36be0a6540b8495a2d00b07c0ca4ebb598e741
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.6

Release history Release notifications | RSS feed

This release

1.0.7 This release

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page