Downloads · 30 days
0
baonathor/xtrade-v1
xtrade-v1 is a machine learning model from baonathor. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
This project implements an Event-Driven Price Reaction (EDPR) model designed to predict short-term price movements of cryptocurrency assets following specific social or market events.
Downloads · 30 days
0
Access
Public
Updated Dec 8, 2025
Repo size
457 MB
Likes
3
Public
Click a slice to open those files.
.pt457 MB · 100%
From the Hugging Face model README
This project implements an Event-Driven Price Reaction (EDPR) model designed to predict short-term price movements of cryptocurrency assets following specific social or market events.
Unlike generic trend-following algorithms, this model focuses on the immediate market reaction to a combination of Social Sentiment (tweets, news) and Market Microstructure (volatility, volume, returns). It utilizes a hybrid architecture combining BERT for text analysis and a Multi-Layer Perceptron (MLP) for quantitative data to forecast price direction over 3-minute and 30-minute horizons.
The following diagram illustrates how the model processes information to generate a signal:
[Tweet Input] ──────> [BERT Encoder] ──────> [Text Embeddings] ──────┐
│
▼
[Fusion Layer] ────> [Classifier] ────> [3m & 30m Probs]
(Cross-Attn)
▲
│
[Market Data] ──────> [Scaler] ────────────> [MLP Encoder] ──────────┘
The core innovation of this model is how it fuses market data with text. Instead of simple concatenation, it uses the market state to "query" the text, focusing on the most relevant parts of the tweet given the current price action.
$$ \text{Attention}(Q, K, V) = \text{softmax}\left(\frac{QK^T}{\sqrt{d_k}}\right)V $$
Where:
The model was trained on a historical dataset of cryptocurrency market events aligned with social media activity. The dataset comprises ~38,000 tweets from official Twitter accounts corresponding to over 500 cryptocurrencies listed on Binance.
The EDPR model is trained as a supervised multi-class classifier, predicting the short-term direction (Up, Down, Neutral) for 3-minute and 30-minute horizons.
To ensure robust generalization, the data was partitioned as follows:
Users should be aware of the specific behavioral biases inherent in this model, which stem from the historical training data. The model functions primarily as a Mean Reversion engine.
The following examples show the actual output from the inference engine and how to interpret the results.
Performance Benchmark:
Note: The input market features (e.g., feat_ret_1m) represent the price action leading up to the tweet.
--- Scenario: FOMO / Strong Uptrend ---
Tweet: BREAKING: Major exchange listing confirmed! 🚀 #ToTheMoon
Key Feats: feat_ret_1m=0.02, feat_volume_60m=2000000, feat_fear_greed_index=80
Signal: NORMAL
3m Probs: Down=0.674, Neutral=0.066, Up=0.261
Time: 10.42 ms
--- Scenario: Panic Dump / Crash ---
Tweet: URGENT: Security breach detected. Do not interact with contracts.
Key Feats: feat_ret_1m=-0.05, feat_volume_60m=5000000, feat_fear_greed_index=10
Signal: EXTREME UP
3m Probs: Down=0.170, Neutral=0.013, Up=0.818
Time: 10.52 ms
--- Scenario: Slow Bleed / Bear Market ---
Tweet: Weekly development update. Progress is slow but steady.
Key Feats: feat_ret_1m=-0.001, feat_volume_60m=100000, feat_fear_greed_index=30
Signal: NORMAL
3m Probs: Down=0.333, Neutral=0.030, Up=0.637
Time: 9.70 ms
--- Scenario: Sideways / Stable ---
Tweet: Just a normal day building. #Crypto
Key Feats: feat_ret_1m=0.0, feat_volume_60m=50000, feat_fear_greed_index=50
Signal: NORMAL
3m Probs: Down=0.429, Neutral=0.230, Up=0.341
Time: 10.30 ms
--- Scenario: Divergence: Good News + Bad Price ---
Tweet: Partnership with Google Cloud announced!
Key Feats: feat_ret_1m=-0.02, feat_volume_60m=300000, feat_fear_greed_index=40
Signal: EXTREME UP
3m Probs: Down=0.177, Neutral=0.007, Up=0.815
Time: 10.67 ms
While powerful, the EDPR model is not a crystal ball. It is optimized for specific conditions and may fail in others:
Install the required Python packages:
pip install torch transformers pandas numpy scikit-learn
It is highly recommended to use PyTorch version 2.10 (pytorch-nightly) to avoid potential compatibility errors.
The model checkpoint file (checkpoints_market_event_multitask/best_model_extreme.pt) is stored using Git Large File Storage (LFS).
best_model_extreme.pt. It should be over 400MB.best_model_extreme.pt manually and replace the pointer file.Directory Structure: Ensure your project folder follows this structure:
/project_root
├── public_inference_extreme.py # Main inference script
├── README.md # This documentation
└── checkpoints_market_event_multitask/ # Model artifacts folder
├── config.json
├── best_model_extreme.pt # PyTorch model weights
├── scaler.pkl # Feature scaler
├── vocab.txt # Tokenizer vocabulary
└── ... (other tokenizer files)
Model Weights:
Place your trained model files (best_model_extreme.pt, scaler.pkl, etc.) inside the checkpoints_market_event_multitask directory.
You can run the inference script directly to test various market scenarios:
python public_inference_extreme.py
To use the model in your own trading bot or application:
from public_inference_extreme import ExtremeModelPredictor
# 1. Initialize
predictor = ExtremeModelPredictor("checkpoints_market_event_multitask")
# 2. Prepare Data
tweet_text = "Partnership announcement coming soon! #BTC"
market_features = {
"feat_ret_1m": -0.005, # 1-min return (-0.5%)
"feat_ret_5m": -0.008, # 5-min return
"feat_ret_15m": -0.01, # 15-min return
"feat_volatility_60m": 0.02, # Volatility
"feat_num_trades_60m": 200, # Number of trades
"feat_volume_60m": 800000, # Volume
"feat_tweet_freq_24h": 20, # Tweet frequency
"feat_time_since_prev_tweet": 30,
"feat_btc_ret_60m": -0.005, # BTC 1h return
"feat_btc_ret_24h": -0.02, # BTC 24h return
"feat_fear_greed_index": 30, # Macro: Fear & Greed
"feat_btc_dominance": 52, # Macro: BTC Dominance
"feat_altseason_index": 15 # Macro: Altseason Index
}
# 3. Predict
result = predictor.predict("ProjectName", "SYMBOL", tweet_text, market_features)
print(f"Signal: {result['extreme_signal']}")
print(f"Probabilities: {result['3m_probs']}")
The model requires 13 specific features to function correctly.
Important: All numerical features should be passed as raw values. They will be transformed internally using scaler.pkl before inference. Do not manually normalize them.
| Feature Name | Description |
|---|---|
feat_ret_1m | Price return over the last 1 minute. |
feat_ret_5m | Price return over the last 5 minutes. |
feat_ret_15m | Price return over the last 15 minutes. |
feat_volatility_60m | Standard deviation of returns over the last hour. |
feat_num_trades_60m | Total number of trades in the last hour. |
feat_volume_60m | Total trading volume in the last hour. |
feat_tweet_freq_24h | Number of tweets about the project in the last 24h. |
feat_time_since_prev_tweet | Time (seconds) since the last tweet. |
feat_btc_ret_60m | Bitcoin price return over the last hour. |
feat_btc_ret_24h | Bitcoin price return over the last 24 hours. |
feat_fear_greed_index | Crypto Fear & Greed Index (0-100). |
feat_btc_dominance | Bitcoin Dominance percentage. |
feat_altseason_index | Altcoin Season Index. |
Disclaimer: This software is for educational and research purposes only. It does not constitute financial advice. Trading cryptocurrencies involves significant risk.