MarketMakingAgent<T>

Models & Types · AiDotNet.Finance.Trading.Agents

Specialized market making agent using reinforcement learning for optimal quoting.

Inheritance: ReinforcementLearningAgentBase<T> → TradingAgentBase<T> → MarketMakingAgent<T>

Implements: IGeneratedParameterRegistrar<T>, IGradientComputable<T, Vector<T>, Vector<T>>

For Beginners

A market making agent learns to provide liquidity by continuously placing buy and sell orders (quotes) in the market. It earns money from the spread between its buy and sell prices while managing the risk of holding inventory. Using reinforcement learning, it learns when to quote aggressively or conservatively based on market conditions, volatility, and its current position.

Example

// Define architecture for market making policy (10 state features, bid/ask offset output)
var architecture = new NeuralNetworkArchitecture<double>(
    inputType: InputType.OneDimensional,
    taskType: NeuralNetworkTaskType.Regression,
    inputSize: 10, outputSize: 2);
            
// Create market making agent that learns optimal bid/ask quoting
var options = new MarketMakingOptions<double>();
var model = new MarketMakingAgent<double>(architecture, options);
            
// Parameterless constructor with default architecture
var defaultModel = new MarketMakingAgent<double>();

Constructors

Constructor Summary
MarketMakingAgent() Initializes a new instance with paper-default options.
MarketMakingAgent(MarketMakingOptions<T> options) Initializes a new instance from MarketMakingOptions alone, building the policy-network architecture from StateSize and ActionSize.
MarketMakingAgent(NeuralNetworkArchitecture<T> architecture, MarketMakingOptions<T> options)

Properties

Property Summary
int FeatureCount { get; }

Methods

Method Summary
Dictionary<string, T> GetTradingMetrics()
ModelMetadata<T> GetModelMetadata() Executes GetModelMetadata for the MarketMakingAgent.
ModelOptions GetOptions()
T Train()
Vector<T> ComputeGradients(Vector<T> input, Vector<T> target, ILossFunction<T> lossFunction) Executes ComputeGradients for the MarketMakingAgent.
Vector<T> SelectAction(Vector<T> state, bool training)
byte[] Serialize() Auto-generated common model serialization surface.
void ApplyGradients(Vector<T> gradients, T learningRate) Executes ApplyGradients for the MarketMakingAgent.
void Deserialize(byte[] data) Auto-generated common model deserialization surface.
void LoadModel(string filepath) Executes LoadModel for the MarketMakingAgent.
void SaveModel(string filepath) Executes SaveModel for the MarketMakingAgent.
void StoreExperience(Vector<T> state, Vector<T> action, T reward, Vector<T> nextState, bool done) Executes StoreExperience for the MarketMakingAgent.
void Train(Vector<T> state, Vector<T> target) Performs a one-shot supervised update for the training/test harness.