Implementation of heterogeneous agents with neural decision-making capabilities for the ANNEM framework. Each agent has a specific type, neural network weights, memory, and performance tracking.
Character string for agent ID
Agent type (neural_momentum, contrarian_ai, etc.)
Initial wealth amount (default: 1,000,000) Neural Network Forward Pass
Numeric vector of input features
List containing prices, returns, volatility
Numeric, signals from connected agents
Numeric, market sentiment score
Numeric, portfolio return for this period
Numeric decision value in -1, 1 Make Trading Decision
Numeric decision value (negative = sell, positive = buy) Update Agent Wealth
The ANNEMAgent class implements six different agent types as described in the mathematical framework:
neural_momentum: Trend-following with neural enhancement
contrarian_ai: Mean-reversion with AI signals
fundamentalist_ml: Technical analysis with machine learning
adaptive_noise: Random strategy with adaptive learning
social_network: Peer influence and herding behavior
meta_learning: MAML-inspired strategy adaptation
id
Character string identifying the agent
type
Agent type (one of six types)
wealth
Current wealth of the agent
risk_tolerance
Risk tolerance parameter 0,1
nn_weights
List containing neural network weights
memory
List containing agent's memory of past observations
connections
Numeric vector of connected agents
performance_history
Numeric vector of past performance
initialize(agent_id, agent_type, initial_wealth = 1e+06)
Initialize a new ANNEM agent with specified parameters
make_decision(market_data, network_signals = 0, sentiment = 0)
Generate trading decision based on agent type and neural network
neural_decision(state_vector)
Forward propagation through neural network with ReLU activation
update_wealth(portfolio_return)
Update agent wealth based on portfolio return and perform learning
if (FALSE) { # \dontrun{
# Create a neural momentum agent
agent <- ANNEMAgent$new("agent_001", "neural_momentum", 1000000)
# Make a decision based on market data
decision <- agent$make_decision(market_data, network_signals = 0.1, sentiment = 0.05)
# Update wealth based on portfolio return
agent$update_wealth(0.02) # 2% return
} # }