SmartFlow — Autonomous, Risk-Aware Institutional Order Execution

What it does

SmartFlow is an autonomous execution agent designed to help institutional traders execute large orders more intelligently by adapting to real-time market microstructure, liquidity conditions, and adverse-selection risk.

The system ingests Level 2 and Level 3 limit-order-book ticks and computes microstructure features, including micro-price, Order Flow Imbalance (OFI), spread in basis points, momentum, realized volatility, and Cumulative Volume Delta (CVD). An XGBoost model estimates adverse-selection risk over a 10-tick horizon, using leakage-aware data splits and a heuristic fallback.

SmartFlow combines these signals with the Almgren–Chriss optimal execution framework to calculate execution trajectories and dynamically select among Market, TWAP, VWAP, Passive Maker, Aggressive Taker, and AC-based slicing strategies.

NVIDIA Nemotron powers the system's decision explanations and market-regime analysis. Through Nebius Token Factory's OpenAI-compatible inference API, Nemotron-3-Nano supports the fast decision-explanation path, while Nemotron-3-Ultra generates more detailed market-regime reports. Caching and a local heuristic fallback help manage inference latency and maintain functionality when the inference API is unavailable.

The platform evaluates seven execution strategies across ten market regimes using a common market-replay framework. A Bloomberg-inspired dashboard built with Streamlit and React/FastAPI components presents execution behavior and Implementation Shortfall metrics for analysis.

Inspiration

Institutional order execution is not simply about buying or selling at the best displayed price. Large orders must be executed while balancing market impact, transaction costs, urgency, and the risk of trading against better-informed participants.

Passive execution strategies can suffer from adverse selection: a resting bid may fill just before the market price falls, while a resting ask may fill just before the price rises. Static execution schedules such as TWAP can also fail to respond adequately to changing liquidity and toxic order flow.

We built SmartFlow around one central question:

What if an execution agent could detect changing market conditions, adapt its strategy, and explain why it made each decision?

Our goal is to move beyond static execution rules toward risk-aware, explainable execution that can be evaluated under consistent market-replay conditions.

How we built it

SmartFlow combines a Python execution engine, machine-learning risk scoring, optimal execution mathematics, market simulation, and an AI-powered explanation layer.

1. Market data and feature engineering

The system processes Level 2 and Level 3 limit-order-book ticks and computes micro-price, Order Flow Imbalance, bid-ask spread in basis points, momentum, realized volatility, and Cumulative Volume Delta. These features help characterize liquidity, order-flow pressure, and short-term market behavior.

2. Adverse-selection risk modeling

We compare Logistic Regression and XGBoost for adverse-selection risk scoring over a 10-tick prediction horizon. The training and evaluation workflow uses leakage-aware data splits, with a heuristic fallback available when the machine-learning model cannot be used.

3. Almgren–Chriss optimal execution

The execution engine implements the Almgren–Chriss framework to calculate optimal execution trajectories and evaluate expected execution costs, risk, and utility. The implementation includes a hyperbolic-sine execution trajectory and corresponding expected-cost and variance calculations.

4. Adaptive strategy selection

The strategy engine dynamically selects among Market, TWAP, VWAP, Passive Maker, Aggressive Taker, and Almgren–Chriss-based slicing strategies based on market conditions, risk signals, and execution objectives.

5. Market simulation and backtesting

The simulator incorporates queue decay, adverse-biased fill behavior, depth walking, and 15 ms simulated latency. The backtesting framework compares seven execution strategies across ten market regimes under a shared market-replay setup, using Implementation Shortfall in basis points as an evaluation metric.

6. NVIDIA Nemotron explainability

The AI layer integrates NVIDIA Nemotron through Nebius Token Factory's OpenAI-compatible inference API. Nemotron-3-Nano supports fast-path decision explanations, while Nemotron-3-Ultra is used for more detailed market-regime analysis and backtest summaries.

The FastAPI endpoint /api/v1/explain serves explanations to the user interface. The system uses caching and local heuristic fallbacks to help manage inference latency and API failures.

7. News context and dashboard

Tavily provides news-based market-regime context that can inform volatility adjustments. The interactive dashboard combines Streamlit and React/FastAPI components to visualize execution behavior, strategy comparisons, and Implementation Shortfall metrics.

Challenges

Preventing lookahead leakage

Financial time-series models can produce misleading results when future information leaks into training or evaluation. We addressed this through a defined prediction horizon and leakage-aware data splits.

Modeling realistic execution fills

Real-world execution is affected by queue position, changing liquidity, adverse selection, market depth, and latency. We incorporated queue decay, adverse-biased fills, depth walking, and simulated latency to make the replay environment more representative of execution conditions.

Balancing AI reasoning with execution latency

Detailed AI reasoning can take longer than latency-sensitive execution decisions can tolerate. We separated the fast Nano explanation path from the slower Ultra reporting path and incorporated caching and a local heuristic fallback.

Making decisions understandable

Quantitative execution systems can be difficult to interpret. Nemotron-generated explanations help communicate the rationale behind execution decisions, while the numerical execution engine remains responsible for its calculations and strategy constraints.

Comparing strategies fairly

We use a shared market-replay framework to evaluate seven strategies across ten regimes, enabling comparisons under consistent simulation conditions.

Accomplishments

SmartFlow brings together quantitative execution, risk-aware strategy selection, simulation, and AI-generated explanations in an end-to-end prototype.

  • Built an execution workflow that can be launched using python main.py --run.
  • Implemented a backtesting workflow using python main.py --backtest across ten market scenarios.
  • Integrated machine-learning risk scoring with Logistic Regression and XGBoost comparison and a heuristic fallback.
  • Implemented Almgren–Chriss execution trajectories and multiple execution strategies.
  • Developed a market-replay simulator with queue-decay and adverse-selection-aware fill behavior.
  • Integrated NVIDIA Nemotron inference through Nebius Token Factory.
  • Exposed AI-generated explanations through a FastAPI endpoint.
  • Built a dashboard for examining execution decisions and comparing Implementation Shortfall.
  • Incorporated news-regime context through Tavily.
  • Designed separate fast-path and analytical-reporting workflows to accommodate different inference-latency requirements.

The project reports an XGBoost ROC-AUC obtained from model training and Implementation Shortfall improvements over TWAP/VWAP in high-adverse-selection regimes. The final submission should include the actual measured values and evaluation details to substantiate these results.

What's next

Multi-venue smart order routing

Extend routing across venues with different liquidity, fees, and execution characteristics to improve execution quality.

Market-data calibration

Calibrate Almgren–Chriss parameters, including eta and gamma, against FIX/ITCH-derived market data to improve model realism.

Learning-based execution control

Explore a PPO-based controller that uses structured execution state and evaluates the contribution of Nemotron-generated reasoning.

Continuous paper trading

Develop a continuously running paper-trading deployment on Nebius infrastructure, with monitoring, operational safeguards, and performance tracking.

Expanded evaluation

Test across additional market regimes, transaction-cost assumptions, latency conditions, and model-failure scenarios to assess robustness.

These are planned extensions rather than claims of completed functionality.

Nebius + NVIDIA usage

NVIDIA Nemotron and Nebius are central to SmartFlow's AI-powered explainability and analytical workflow.

  • Nebius Token Factory: Provides the OpenAI-compatible inference API used for runtime Nemotron calls.
  • Nemotron-3-Nano: Supports the fast-path decision-explanation workflow.
  • Nemotron-3-Ultra: Supports more detailed market-regime reports and backtest analysis.
  • Nebius Serverless Endpoints: Used as part of the API inference deployment workflow.
  • Nebius Serverless Jobs: Used as part of the scenario-based backtesting workflow.
  • Tavily: Supplies news context for market-regime analysis and volatility adjustments.

The architecture separates execution calculations from explanatory inference. The model's explanations complement numerical execution logic rather than replacing market-data calculations, risk controls, or execution constraints.

During the hackathon, the existing Smart Order Routing foundation was extended with Token Factory integration, a Nemotron explainer and ask endpoint, Tavily-based news-regime context, serverless deployment work, a demo video, a public MIT-licensed repository, and README run instructions.

Required feedback: Nebius + NVIDIA

Our experience with Nebius Token Factory and NVIDIA Nemotron was positive. We were able to set up the OpenAI-compatible inference endpoint in approximately 15 minutes, and the documentation made integration straightforward.

Nemotron-3-Nano was useful for the fast-path explanation workflow, with observed latency of approximately 400 ms in our setup. Nemotron-3-Ultra produced more detailed and insightful market-regime analysis for backtest summaries, but its observed response time was approximately 3–4 seconds. This led us to separate latency-sensitive explanations from slower analytical reporting.

Nebius AI Cloud Serverless Jobs were a good fit for our ten-scenario backtesting workloads. We observed a cold-start time of approximately eight seconds. The serverless approach also reduced the need to manage our own inference GPU infrastructure.

Nemotron followed our microstructure-oriented JSON inputs effectively, and we found its regime-level explanations useful compared with our Llama baseline. We also integrated Tavily-based news context into our volatility-adjustment workflow with a small amount of code.

Our main improvement requests are streaming-token support, a per-model usage dashboard, and a Python SDK example demonstrating retries and resilient error handling.

Overall, Nebius Token Factory and NVIDIA Nemotron helped us integrate AI-powered reasoning into SmartFlow without having to host our own inference GPUs. The combination of fast-path and analytical models was especially useful for balancing execution-oriented workflows with richer explanations.

Conclusion

SmartFlow combines market-microstructure analysis, machine-learning-based adverse-selection risk scoring, optimal execution mathematics, and adaptive strategy selection with NVIDIA Nemotron-powered explanations.

By integrating Nemotron through Nebius Token Factory and evaluating execution strategies through a shared market-replay framework, SmartFlow aims to make institutional order execution more adaptive, measurable, and understandable.

Our next step is to strengthen empirical validation, extend routing across venues, calibrate execution models against real market data, and progress toward continuously monitored paper trading.

Built With

  • fastapi
  • nebius-serverless-endpoints
  • nebius-token-factory
  • nvidia-nemotron-3-nano
  • nvidia-nemotron-3-ultra
  • plotly
  • react
  • scikit-learn
  • streamlit
  • tavily
  • xgboost
Share this project:

Updates

Submission history