Skip to content

Adityas221b/Crypto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 

Repository files navigation

🧠 CryptoSentimentTrader πŸ“Š

A smart crypto trading pipeline that combines social sentiment, news analysis, on-chain metrics, and machine learning to generate and backtest trading signals for Bitcoin.

πŸš€ Features

  • πŸ”Ž Multi-source Data Collection:

    • Reddit posts (r/Bitcoin)
    • News articles (via NewsAPI)
    • Blockchain on-chain transaction data
  • πŸ“ˆ Sentiment Analysis:

    • VADER and TextBlob sentiment scores
    • Optional BERT-based transformer sentiment
    • Rolling sentiment smoothing
  • πŸ’‘ Trading Signal Generation:

    • Simple rules based on sentiment thresholds
    • Buy/Hold/Sell labeling
  • πŸ§ͺ Backtesting with Backtrader:

    • Strategy simulation on real-time BTC prices
    • Final portfolio value calculation
  • πŸ€– Machine Learning Classifier:

    • XGBoost model trained on historical sentiment/price data
    • Accuracy and classification reporting
  • βš™οΈ Sharpe Ratio Optimization:

    • Automated threshold tuning for maximum risk-adjusted returns

πŸ“‚ File Structure

Crypto.py                # Main script
sentiment_data.csv       # Intermediate file with collected raw sentiment data
sentiment_trading_data.csv # Processed file with sentiment + signals

πŸ› οΈ Setup & Installation

  1. Clone this repository:

    git clone https://github.com/your-username/CryptoSentimentTrader.git
    cd CryptoSentimentTrader
  2. Install required packages:

    pip install -r requirements.txt

    Example requirements.txt:

    praw
    requests
    pandas
    newsapi-python
    nltk
    textblob
    transformers
    backtrader
    xgboost
    scikit-learn
    tf-keras
    
  3. Download NLTK data:

    import nltk
    nltk.download("vader_lexicon")
  4. Replace the following with your own API keys:

    • client_id, client_secret in the Reddit section
    • NEWS_API_KEY for the NewsAPI

πŸ“Š Example Output

βœ… Accuracy: 0.78
πŸ“ˆ Best Sharpe Ratio: 1.42
πŸš€ Optimized Buy Threshold: 0.75
πŸ’° Final Portfolio Value: $11,326.52

πŸ“Œ Notes

  • API rate limits may affect large data pulls.
  • Transformer sentiment is optional but can be enabled for deeper NLP insight.
  • Model assumes short-term predictionβ€”do not use for long-term financial advice.

🀝 Contribution

Feel free to fork, improve, or contribute PRs. Suggestions welcome!

πŸ“œ License

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages