YieldYatra (DefAIAgent) is an autonomous Artificial Intelligence agent tailored for Decentralized Finance (DeFi) trading. This innovative platform optimizes yield, manages risk dynamically, and automates portfolio rebalancing actions through seamless integration with the Aptos blockchain. It harnesses advanced Japanese-inspired crypto trading strategies, making it particularly suited for volatile cryptocurrency markets.
- Autonomous Trading: Automated portfolio management and strategy execution.
- Blockchain Integration: Secure transactions on Aptos blockchain via the official Aptos SDK.
- Advanced Algorithms: Combines Yield Score, Risk Index, and dynamic allocation models.
- Interactive Visualization: Real-time insights and visual analytics using Plotly and Streamlit.
YieldYatra consists of several integrated modules:
- Data Acquisition (
CCXT
, CSV sources) - Metrics Computation: Yield Score, Risk Index calculation.
- Trading Strategies: Japanese-inspired mathematical frameworks (KAGE, KITSUNE, RYU, SAKURA, HIKARI, TENSHI, ZEN).
- Rebalancing Signals: Automated triggers for portfolio adjustments.
- Frontend Interface: Streamlit application for easy user interaction.
- Logging & Monitoring: Detailed trade logs and interactive visualizations.
YieldYatra/
βββ backend/
β βββ aptos_backend.py
βββ frontend/
β βββ aptos_frontend.py
βββ docs/
β βββ Aptos AI Agent.pdf
β βββ aptos trader.pdf
β βββ japanses-inspired-trading-strategy.pdf
βββ design
β βββ Activity Diagram.png
β βββ system-design.png
β βββ user flow diagram.png
βββ output
βββ trades.log
The defAI strategy autonomously optimizes yields, manages risks, and triggers rebalancing transactions using:
-
Yield Score: $$ \text{Yield Score}(t) = \frac{\mu_r(t)}{\sigma_r(t) + \epsilon} $$ where ( \mu_r(t) ) is the rolling mean return, and ( \sigma_r(t) ) is volatility.
-
Risk Index: $$ \text{Risk Index}(t) = \sigma_r(t) \times 100 $$
-
Rebalancing Signal:
if |allocation - target| > 0.1, execute blockchain rebalance transaction.
- Uses GARCH volatility modeling and Hidden Markov Models (HMM) for market state detection.
- Employs Dynamic Time Warping (DTW) and Neural Networks for price forecasting.
- Applies fractal dimensions and Lyapunov exponent calculations to identify chaotic market conditions.
- Implements regression with mirror constraints for trend prediction and trading signals.
- Leverages Principal Component Analysis (PCA) for momentum-based trade signals.
- Uses topological data analysis (persistent homology) for identifying significant market features.
- Incorporates wavelet analysis for trend and cycle detection, signaling trades based on market rhythms.
Interactive Web Dashboard:
- User-friendly GUI for configuring strategies, exchanges, symbols, RSI/MA parameters, and backtesting.
- Real-time visualization of trade results and performance metrics.
- Easy downloading of historical trade logs and CSV data.
The backend API provides endpoints for:
- Market data acquisition (using CCXT or local CSV files)
- Execution of trading strategies (RSI, MA, RSI_MA, advanced Japanese-inspired frameworks)
- Blockchain Transactions (via Aptos SDK integration)
- Plot generation (matplotlib and Plotly-based visuals for market analysis)
git clone https://github.com/yourusername/YieldYatra.git
cd YieldYatra
pip install -r requirements.txt
Ensure the backend Flask server is running:
python backend/aptos_backend.py
Start the frontend Streamlit application:
streamlit run frontend/aptos_frontend.py
- Launch the frontend UI at: http://localhost:8501
- Configure parameters in the sidebar.
- Execute backtesting by clicking "Run Backtest".
-
Interactive Plotly charts displaying:
- Yield Scores
- Risk Indices
- Trade entry and exit points.
-
Performance Metrics:
- Total Trades
- Win Rate (%)
- Total Return (%)
- Average Return per Trade (%)
The system leverages the Aptos SDK to securely execute on-chain transactions:
- Portfolio rebalancing
- Yield harvesting
- Secure and transparent execution of automated trading strategies.
Detailed technical and theoretical documentation are provided:
We welcome contributions! Fork this repository, create your feature branch, and submit a pull request.
Distributed under the MIT License.
YieldYatra is a comprehensive, sophisticated DeFi solution integrating mathematical rigor with practical blockchain execution. It is designed for researchers, crypto enthusiasts, and professional traders seeking automated, AI-driven trading solutions.
π Note: Ensure the backend Flask service and Aptos blockchain access are correctly configured for optimal performance.