Frank Morales Aguilera, BEng, MEng, SMIEEE
Boeing Associate Technical Fellow/ Engineer/ Scientist/ Innovator/ Cloud Option Architect/ Software Program Designer/ @ Boeing Global Provider
The rapid evolution of expert system (AI) has transformed markets, with economic markets, especially those associated with cryptocurrency trading, emerging as a prime recipient. In this context, the crypto_bot_agentic. py manuscript stands for a sophisticated example of an agentic AI system created to autonomously trade Ethereum (ETH) versus the US Buck (USD) on the Sea serpent exchange. This script is an effective tool for modern-day trading, constructed to run in a Google Colab Pro/Pro+ setting with a high-RAM CPU, leveraging a pre-trained CNN-LSTM version (crypto_model. keras, input form (1, 72, 12) to anticipate trading signals, incorporating advanced technological signs, adaptive risk monitoring, and robust error handling. This essay explores the manuscript’s style, its agentic qualities, and its implications for the future of AI-driven trading.
Introduction of the Trading Bot
The crypto_bot_agentic. py script automates trading on Kraken’s ETH/USD set making use of a 1 -hour duration, achieving an excellent 80 04 % validation precision throughout training. This recognition accuracy determines exactly how well the model forecasts on new, undetected data, showing the crawler’s capability to make precise predictions. The script fetches real-time OHLCV (Open up, High, Low, Close, Quantity) information, computes technical indications (RSI, MACD, Bollinger Bands, OBV, ATR), preprocesses information for version inference, predicts Buy/Sell/Hold signals, and implements market orders with ATR-based take-profit and stop-loss levels. Email notifications for trades and mistakes are sent out using Gmail, and logs are saved to Google Drive for monitoring. The robot sustains online trading (dry_run = False) or simulation (dry_run = Real), with safe and secure credential management by means of Google Colab customer data.
The manuscript’s agentic AI style splits duties right into five modular agents:
- Data Agent : Fetches and refines market information, calculating technological indicators.
- Prediction Representative : Preprocesses data and anticipates trading signals utilizing the CNN-LSTM model.
- Trading Representative : Implements professions with adaptive position sizing based on performance.
- Notification Representative : Sends out email signals for trades and errors.
- Planner Agent : Orchestrates representative interactions to ensure seamless operation.
This modular architecture, incorporated with flexible attributes and durable error handling, makes the crawler a prime example of an agentic AI system that runs autonomously, adapts to market conditions, and goes after the objective of making best use of successful trades while reducing risk.
Agentic AI Attributes
Autonomy
The crawler’s representatives run independently, calling for no hands-on treatment as soon as initialized. The Information Representative autonomously fetches OHLCV data from Kraken using the ccxt library (variation 4 5 3 and computes indicators, including the RSI (14 -duration), MACD (26, 12, 9, Bollinger Bands (20 -duration, 2 standard variances), OBV, and ATR (14 -duration). The Prediction Agent preprocesses data making use of a MinMaxScaler and runs reasoning on the CNN-LSTM version (tensorflow== 2 19.0), producing Buy (1, Offer (2, or Hold (0) signals with self-confidence scores. The Trading Agent executes market orders for high-confidence signals (higher than 0. 85, while the Alert Agent sends out emails without requiring user input. The Organizer Agent ties these jobs together, running per hour cycles lined up with candle shuts. This autonomy guarantees the crawler can run 24/ 7, limited just by Colab’s runtime constraints.
Adaptivity
A key agentic feature is the Trading Representative’s flexible setting sizing, which readjusts the trade dimension (initially 1 % of account balance) based upon the win rate of the last 10 trades. If the win price surpasses 70 %, the placement dimension boosts to an optimum of 2 % to capitalize on effective methods. If the setting size falls listed below 30 %, it is reduced to a minimum of 0. 5 % to mitigate danger. This system, implemented making use of a deque for profession background, simulates reinforcement knowing by dynamically reacting to efficiency, a hallmark of agentic AI. While the script consists of a placeholder for trade outcome tracking (currently returning neutral results), adding take-profit/stop-loss surveillance would certainly even more boost this adaptivity.
Goal-Oriented Behavior
The bot’s key objective is to optimize profitable professions while taking care of threat. It accomplishes this via:
- High-Confidence Trading : Just implements trades with design self-confidence above 0. 85, thus decreasing the possibility of incorrect positives.
- ATR-Based Threat Monitoring : Sets take-profit at ± 2 * ATR and stop-loss at ± ATR, balancing incentive and threat.
- Setting Sizing : Limits professions to a percent of account equilibrium, making sure capital conservation.
- Mistake Handling : Each representative catches and logs mistakes, with the Planner sending e-mail signals to ensure the bot stays operational or alerts the individual of any type of issues.
This ambitious design straightens with the crawler’s 80 04 % recognition accuracy, aiming for constant productivity in unstable cryptocurrency markets.
Technical Application
Dependencies and Configuration
The manuscript relies upon:
- TensorFlow 2 19.0 : For packing and running the CNN-LSTM version.
- ta 0. 11.0 : For technical signs, making use of on_balance_volume to repair the original ImportError.
- ccxt 4 5 3 : For Sea serpent API communications, with rate restricting to stay clear of bans.
- pandas , numpy , sklearn : For information processing and scaling.
- smtplib : For email notices through Gmail’s SMTP server.
The setup needs:
- Saving Sea Serpent API and Gmail qualifications in Colab Secrets.
- Mounting Google Drive to access crypto_model. keras and logs.
- Optionally loading an experienced MinMaxScaler (scaler.pkl) for constant attribute scaling.
Agent Design
The manuscript’s multi-agent layout improves modularity and extensibility:
- Information Representative : Fetches 122 candles (72 for design input + 50 for indicator computations), making sure enough information for indicators like MACD and Bollinger Bands, which call for lookback durations. It utilizes ccxt.kraken with rate limiting to prevent API overuse.
- Forecast Representative : Scales the 12 functions (OHLCV, RSI, MACD, MACD_Signal, BB_Upper, BB_Lower, OBV, ATR) and improves information to (1, 72, 12 for design inference. The CNN-LSTM design, trained with an accuracy of 80 04 %, anticipates signals based upon 72 -hour series.
- Trading Representative : Performs market orders for Buy/Sell signals, determining setting dimension as the minimum of the adaptive percent (0. 5 %– 2 %) or readily available funds. ATR-based take-profit and stop-loss guarantee disciplined danger management.
- Notice Representative : Sends out emails for trades (including position size, cost, TP/SL, self-confidence) and mistakes, making use of Gmail’s safe and secure SSL link.
- Coordinator Representative : Runs per hour, orchestrating agents and handling exceptions. It computes wait times to straighten with 1 -hour candle light shuts, making sure forecasts use fresh information.
Mistake Handling and Notices
Each representative consists of try-except blocks to catch errors (e.g., API failings, model filling problems, data preprocessing errors), logs information to trading_bot_agentic. log, and sends out e-mail alerts through the Notice Representative The Organizer Agent catches major loop errors and retries after 60 seconds to keep procedure. This durable error managing makes sure the bot either recuperates or notifies the individual, a critical attribute for independent trading.
Flexible Setting Sizing
The Trading Agent’s update_position_size method makes use of a deque to track the last 10 profession outcomes. If the win price goes beyond 70 %, it raises the setting size to capitalize on successful patterns; if it is listed below 30 %, it lowers exposure to alleviate losses. While the current application returns neutral outcomes (0) as a result of the lack of TP/SL tracking, this structure makes it possible for future improvements to track real profession outcomes, making the bot much more adaptive.
Ramifications for Cryptocurrency Trading
The crypto_bot_agentic. py script demonstrates the power of agentic AI in economic markets. Its multi-agent architecture provides a number of advantages:
- Scalability : New agents (e.g., for belief evaluation using X messages) can be included without interfering with existing capability.
- Maintainability : A modular style promotes less complicated debugging and updates, with agent-specific logs for improved traceability.
- Effectiveness : Comprehensive error handling and alerts ensure integrity in unstable markets.
- Adaptivity : Dynamic setting sizing reacts to market efficiency, decreasing risk during downturns and profiting from uptrends.
Nonetheless, constraints exist:
- Colab Constraints : Colab’s runtime may disconnect after 12– 24 hours, requiring a VPS (e.g., AWS EC 2 for 24/ 7 operation.
- Profession End Result Tracking : The flexible sizing counts on a placeholder; implementing TP/SL surveillance would certainly boost accuracy.
- View Evaluation : The script does not have real-time market belief due to API limitations in Colab, but it can integrate X-post evaluation with extra setup.
- Market Dangers : Cryptocurrency volatility and Kraken fees (~ 0. 16– 0. 26 %) influence profitability.
Future Enhancements
To better boost the bot’s agentic capabilities:
- Sentiment Agent : Incorporate X API or a library like vaderSentiment to assess market sentiment, readjusting self-confidence thresholds or position dimensions for bullish/bearish signals.
- End result Monitoring : Display take-profit/stop-loss hits to upgrade the profession history properly, making it possible for genuine support discovering.
- WebSocket Integration : Usage ccxt.asyncio.kraken for real-time information, reducing latency.
- Multi-Pair Trading : Extend to various other sets (e.g., BTC/USD) with different representatives per pair.
- Advanced Risk Management : Include tracking stops or maximum drawdown limitations (e.g., pause trading if losses go beyond 10 %).
- Alternate Notifications : Carry out Telegram informs making use of python-telegram-bot for faster interaction.
Deployment Considerations
For production:
VPS Release : Relocate to a VPS with schedule for hourly runs:
import routine
coordinator = CoordinatorAgent()
schedule.every(). hour.at(": 00). do(coordinator.execute)
while Real:
schedule.run _ pending()
time.sleep( 1
Security : Make certain Sea serpent API secrets have trading authorizations and keep Colab Keys safe and secure.
Examining : Run in dry_run = Real setting for 24– 48 hours to confirm signals and e-mails, then switch over to live trading with a tiny equilibrium ($ 100–$500
Keeping an eye on : Routinely inspect Kraken’s dashboard, logs, and e-mail signals for efficiency and issues.
Conclusion
The crypto_bot_agentic. py script stands for a significant innovation in AI-driven cryptocurrency trading, embodying the concepts of agentic AI via its self-governing, flexible, and goal-oriented design. Its multi-agent design, developed with tensorflow, ta, and ccxt, makes it possible for durable trading on Sea serpent’s ETH/USD pair, leveraging a CNN-LSTM design with 80 04 % precision.
Flexible position sizing and comprehensive mistake dealing with make it a durable tool for navigating unpredictable markets. While constraints like Colab runtime restraints and incomplete result monitoring exist, the manuscript’s modular layout paves the way for enhancements like belief analysis and multi-pair trading. As AI remains to improve money, this crawler acts as an engaging example of exactly how agentic systems can empower investors, providing a peek into the future of automated, intelligent trading strategies.