Skip to content

adielliot37/ArithmoAI-Endgame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ArithmoAI

ArithmoAI is your Gen-Z friendly, quant-powered, AI-supercharged crypto trading companion. Built as a Telegram bot, it unifies multi-exchange portfolio management, AI chat, quantitative metrics, technical analysis, and automated futures strategies into a single, easy-to-use interface.


πŸš€ Features

  • Multi-CEX Management

    • Connect Binance (and other CEX) via API keys
    • View spot & futures balances, open orders, positions
    • Place market buy/sell orders directly from Telegram
  • Natural-Language Interface (NLP)

    • Classify messages into intents (portfolio_health, market_sentiment, coin_analysis, should_buy, buy_token, sell_token, replace_coin, portfolio_diversity, tax_implications, etc.)
    • Extract symbols & amounts automatically
  • QuantMetrics Integration

    • Fetch Sharpe ratio, volatility, max drawdown, daily return from TokenMetrics /quantmetrics API
    • Fetch long-form AI analyses via /ai-reports
  • AI Chat & Summaries

    • TokenMetrics AI Chat (/tmai) for open-ended questions (β€œnext 100Γ— coin?”)
    • OpenAI GPT for summarization & enrichment
  • Technical Analysis (TA-Lib)

    • ATR (Average True Range) β†’ dynamic stop-loss & take-profit
    • RSI, MACD, Bollinger Bands, MA (SMA/EMA) for entry/exit signals
    • Entry: MA crossovers, volatility breakouts, divergence checks
  • Risk & Money Management

    • Stop-Loss: entry_price – 1.5 Γ— ATR
    • Take-Profit: entry_price + 2.0 Γ— ATR
    • Position Sizing via Kelly Criterion:
      f_star = (win_rate * (avg_win_loss + 1) - 1) / avg_win_loss
  • Automated Futures Trading

    • Trend-following, mean-reversion hooks
    • Scheduled checks & market orders
  • Portfolio Analysis & Rebalancing

    • Real-time USD valuation via CCXT/Binance
    • Allocation %, portfolio Sharpe & volatility, risk score
    • Identify weakest Sharpe coin and recommend replacements from top QuantMetrics picks
  • Market Sentiment Dashboard

    • Pull headlines from TokenMetrics sentiments API
    • Summarize & tag tokens as bullish or bearish
  • Tax & Compliance Aid

    • Generate tailored tax-reporting guidance based on portfolio composition

πŸ—οΈ Architecture

User ↔ Telegram Bot β”œβ”€ Intent Classification β†’ OpenAI GPT β”œβ”€ QuantMetrics APIs β†’ /quantmetrics, /ai-reports, /tmai β”œβ”€ CCXT Library β†’ Binance spot & futures β”œβ”€ TA-Lib Library β†’ ATR, RSI, MACD, Bollinger, MA… └─ OpenAI β†’ Summarization & Q&A enhancements

πŸ”§ Installation

  1. Clone & enter

    git clone https://github.com/yourname/arithmoai.git
    cd arithmoai
  2. Create & activate virtualenv

    python3 -m venv venv
    source venv/bin/activate
  3. Install dependencies

    pip install -r requirements.txt
  4. Environment variables

    Copy .env.example to .env and set:

    TELEGRAM_BOT_TOKEN=your_telegram_token
    OPENAI_API_KEY=your_openai_key
    TOKENMETRICS_API_KEY=your_tokenmetrics_key
    
  5. Run

    python bot.py

βš™οΈ Configuration & Commands

/start

Connect your Binance account if not already connected.
If already connected, it shows demo queries you can try like:

  • portfolio health
  • buy ETH 10
  • replace weakest coin

/cex

List currently connected exchanges and their connection status.

/auto

Trigger the automated futures strategy using quant + TA indicators.

/positions

Display your current open positions (spot + futures).

πŸ’¬ Usage Examples

Command Description
portfolio health πŸ“Š Detailed portfolio analytics & risk assessment
market sentiment πŸ“° News summary + per-token bullish/bearish outlook
analyze BTC πŸ” Coin-specific Quant & AI analysis
should I buy SOL? βœ…/❌ Quant signal + metrics breakdown
which coin to buy ✨ Top 5 QuantMetrics picks
buy ETH 10 πŸ’Έ Market-buy $10 USDT of ETH
sell ADA all πŸ’Έ Market-sell your full ADA position
replace weakest coin πŸ”„ Suggest replacement for lowest Sharpe token
portfolio diversity πŸ”„ HHI concentration score & diversity rating
tax implications πŸ’° Custom crypto tax guidance
/auto πŸ€– Run automated futures strategy with dynamic leverage
/positions πŸ€– Show current futures & spot positions

🧠 Technical Deep-Dive

πŸ”Œ APIs

TokenMetrics

  • GET /quantmetrics?symbol=...
    β†’ Fetches detailed quantitative metrics like Sharpe ratio, volatility, max drawdown, and average daily return.

  • GET /ai-reports?symbol=...
    β†’ Returns natural-language investment analysis generated by TokenMetrics AI.

  • POST /tmai
    β†’ Sends user prompts to TokenMetrics AI Chatbot for conversational insights and recommendations.

  • GET /trading-signals?symbol=...
    β†’ Retrieves AI-generated buy/sell/neutral signals used for auto-futures strategies and short-term trading.

  • GET /sentiments
    β†’ Provides aggregated market sentiment and recent news summaries with bullish/bearish classifications.

OpenAI GPT-3.5

  • Intent classification from user input
  • Summarization of AI insights

CCXT

  • Binance spot & futures order placement
  • Portfolio balance fetching

πŸ“Š TA-Lib Indicators

Indicator Technical Role Strategy Weightage
ATR Measures volatility to size stop-loss & take-profit 🟒 High (SL/TP calc)
RSI Identifies overbought/oversold momentum zones 🟑 Medium
MACD Confirms trend direction + momentum crossover signals 🟒 High (entry logic)
Bollinger Bands Volatility envelopes for breakout & mean-reversion 🟑 Medium
SMA/EMA Defines short/long trend bias and crossover strategies 🟒 High (entry logic)
Stochastic RSI Combines RSI + momentum for micro timing 🟑 Medium-Low
CCI Detects price divergence vs mean (momentum filtering) βšͺ Optional
WMA Weighted moving average for smoother trend reactions βšͺ Optional
ADX Measures trend strength to filter weak signals βšͺ Optional

βš™οΈ Only high-confidence indicators (like ATR, MACD, SMA/EMA) are directly used in auto-trading entries and stop logic. Others enhance edge in confluence zones.

πŸ“ˆ Kelly Criterion (Position Sizing)

The Kelly Criterion is a formula used to determine the optimal bet size for maximizing long-term capital growth while minimizing risk. It balances win probability and risk-reward ratio.

Formula:

  • f* = (p Γ— R - (1 - p)) / R

Where:

  • f* is the optimal fraction of capital to risk per trade
  • p is the win probability (success rate)
  • R is the risk-reward ratio (average win / average loss)

πŸ”Έ How ArithmoAI Applies It

In practice:

  • We cap f* at 25% to reduce overexposure

  • If the Kelly fraction is negative, we fallback to a safer default stop-loss (e.g., 5%)

  • Final stop-loss is calculated as:

  • SL = entry_price Γ— (1 - f*) if f* > 0 SL = entry_price Γ— 0.95 if f* ≀ 0

This makes position sizing dynamic and risk-aware, adapting to market volatility and historical performance.

πŸ“‰ Risk Management

  • Entry Signal:

    • Moving average crossover
    • Volatility breakout (Bollinger Band spike)
  • Stop-Loss:

    • SL = Entry Price - (1.5 Γ— ATR)
  • Take-Profit:

    • TP = Entry Price + (2.0 Γ— ATR)
  • Position Sizing (Kelly Criterion):

win_rate     = wins / total_trades
avg_win_loss = avg_profit / avg_loss
f_star       = (win_rate * (avg_win_loss + 1) - 1) / avg_win_loss

πŸ”„ Portfolio Rebalancing

  • πŸ“₯ Fetch current holdings using CCXT
  • πŸ’΅ Compute USD value and % allocation of each token
  • πŸ“‰ Rank tokens by Sharpe Ratio to identify the weakest asset
  • πŸ” Recommend replacement from the top QuantMetrics picks

🀝 Contributing

  1. Fork this repository
  2. Create a feature branch (git checkout -b feature-name)
  3. Implement & test your changes
  4. Push your branch (git push origin feature-name)
  5. Open a Pull Request describing your enhancement


πŸ“„ License

This project is licensed under the MIT License.

Β© Aditya Chaplot – Feel free to use, fork, and build on it.


About

Won 2nd PrizeπŸ† at Endgame Hackathon , Austin,TX

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages