Hardik Manish Runwal

Stochastic processes · Quantitative engineering

LambdaLab: modeling trade arrivals with Hawkes processes

An exploratory quantitative-modeling application connecting point-process theory, parameter fitting, simulation, and interactive visualization.

View source on GitHub ↗

1. What motivated LambdaLab?

I built LambdaLab to explore the intersection of stochastic processes, quantitative finance, and software engineering.

Financial markets generate event streams in which the timing of trades can contain meaningful information. Rather than treating trades as events arriving independently at a constant average rate, I wanted to investigate models that can capture temporal dependence and clustering.

This led me to Hawkes processes, a class of self-exciting point processes in which past events can temporarily increase the probability of future events.

I was interested in both the mathematical question and the engineering challenge: could I implement a point-process model, estimate its parameters from event timestamps, compare it against a simpler baseline, and expose the resulting analysis through an interactive application?

LambdaLab became an independent quantitative-modeling project designed to connect mathematical theory, numerical optimization, simulation, and interactive visualization.

2. What problem does the system solve?

LambdaLab provides a framework for exploring and modeling the arrival times of financial market events.

Given a sequence of event timestamps, the system is designed to help users investigate whether arrivals exhibit temporal clustering and whether a self-exciting Hawkes process describes the observed event stream better than a homogeneous Poisson process.

The intended users include students exploring stochastic processes, quantitative-finance enthusiasts, and researchers interested in event-driven modeling.

The system brings several capabilities together:

  • Fitting a point-process model to timestamped event data.
  • Estimating parameters that characterize baseline activity and event excitation.
  • Comparing Hawkes-process behavior against a Poisson baseline.
  • Simulating event streams from a fitted or specified model.
  • Visualizing event arrivals and the evolution of conditional intensity.
  • Exploring how model parameters influence the behavior of simulated processes.

The objective is to make point-process modeling more accessible and inspectable, rather than hiding the mathematical model behind a black-box interface.

3. What is the mathematical model?

The project uses an exponential-kernel Hawkes process to model self-exciting event arrivals.

For event times \(t_i\), the conditional intensity is:

\[ \lambda(t)=\mu+ \sum_{t_i<t}\alpha e^{-\beta(t-t_i)} \]

The intensity represents the instantaneous event-arrival rate conditional on the observed history.

The parameters have the following interpretations:

  • \(\mu\): Baseline event-arrival intensity.
  • \(\alpha\): Excitation contributed by each previous event.
  • \(\beta\): Rate at which the effect of a previous event decays over time.

When an event occurs, the intensity increases. Its contribution then decays exponentially, allowing the model to represent periods of heightened activity followed by a return toward the baseline rate.

For this parameterization, the branching ratio is:

\[ n=\frac{\alpha}{\beta} \]

Under the usual stationary univariate Hawkes-process assumptions, \(n<1\) is the stability condition for the exponential-kernel model.

This provides a useful interpretation of the model: the branching ratio describes the expected number of directly induced offspring events per event in the associated branching-process representation.

The model therefore offers more than a descriptive fit. Its parameters help characterize baseline activity, the strength of self-excitation, and the persistence of event clustering.

4. How did you implement parameter estimation?

LambdaLab uses maximum likelihood estimation to fit the Hawkes-process parameters to observed event timestamps.

For event times \(t_1,\ldots,t_N\) observed over \([0,T]\), the point-process log-likelihood is:

\[ \ell(\theta)= \sum_{i=1}^{N}\log\lambda(t_i) -\int_0^T\lambda(t)\,dt \]

where \(\theta=(\mu,\alpha,\beta)\).

The first term rewards the model for assigning high intensity to observed event times. The integral penalizes models that predict excessive overall event activity.

For the exponential-kernel formulation, the compensator can be expressed as:

\[ \int_0^T\lambda(t)\,dt = \mu T+ \frac{\alpha}{\beta} \sum_{i=1}^{N} \left(1-e^{-\beta(T-t_i)}\right) \]

This makes the likelihood practical to evaluate numerically.

The implementation uses Python's numerical and scientific-computing ecosystem, including NumPy and SciPy, with Pandas for working with tabular event data.

The estimation workflow involves evaluating the likelihood, optimizing the parameters, and examining the resulting model fit. The intended implementation also needs to respect parameter constraints, such as positive baseline intensity and nonnegative excitation and decay parameters.

For a robust fitting procedure, I would additionally document initialization, optimization bounds, convergence criteria, and handling of failed optimization runs.

The precise optimizer configuration and the extent of the implemented convergence checks should be confirmed from the source code before making more specific claims.

5. What data did you use?

The project was designed to work with timestamped financial event data, including CSV-based tick data.

The modeling pipeline operates on event arrival times, which are prepared from the input data before fitting the point-process model.

Important preprocessing considerations include:

  • Parsing timestamps consistently.
  • Sorting events chronologically.
  • Establishing the observation interval.
  • Handling duplicate or invalid timestamps.
  • Converting timestamps to a consistent time unit.
  • Accounting for the observation window when evaluating the likelihood.

The earlier project description refers to approximately one million market events. Before publishing that figure as a verified experimental dataset size, I would confirm the exact event count and whether it refers to a dataset actually used in fitting, simulation, or benchmarking.

The precise market-data provider, instrument, collection period, and any licensing or redistribution restrictions also need to be established from the original data files.

I would disclose the source and event count only after verifying those details, and I would not publish raw market data unless its licensing terms permit redistribution.

6. What experiments did you conduct?

The main experimental direction was to compare a self-exciting Hawkes process with a homogeneous Poisson-process baseline.

A homogeneous Poisson process assumes a constant event-arrival intensity:

\[ \lambda(t)=\mu \]

This provides a useful baseline because it models the average event rate without explicitly representing self-excitation.

The Hawkes process extends this by allowing previous events to influence future intensity. Comparing the two models helps investigate whether temporal dependence provides a better explanation of the observed arrival sequence.

The project also incorporates simulation and visualization as ways to inspect model behavior. Ogata's thinning algorithm provides a method for generating event times from a specified conditional intensity, enabling simulated event streams to be compared with observed patterns.

Other useful analyses include:

  • Comparing fitted log-likelihoods.
  • Examining estimated Hawkes parameters and branching ratios.
  • Visualizing event clustering and conditional-intensity trajectories.
  • Investigating how changes in excitation strength and decay rate affect simulated activity.
  • Comparing observed and simulated event-arrival statistics.

I would distinguish the implemented modeling workflow from any additional statistical validation that has not been verified in the experiment records. In particular, goodness-of-fit tests, residual diagnostics, and comprehensive sensitivity analyses should be claimed only if they were actually conducted.

7. What results can you verify?

The project description associated with my CV reports a 34% improvement in log-likelihood relative to a Poisson baseline.

Before publishing this as a quantitative result, I would verify the original Hawkes and Poisson log-likelihood values, the dataset and observation interval used, and the precise calculation.

For example, a relative improvement might be defined as:

\[ \frac{\ell_{\text{Hawkes}}-\ell_{\text{Poisson}}} {|\ell_{\text{Poisson}}|}\times100\% \]

However, this is only one possible definition, and it is not necessarily the calculation used in the original experiment. Log-likelihood improvements also need careful interpretation because the models have different numbers of parameters and the likelihood depends on the observation interval and time units.

For a more rigorous comparison, I would report the fitted log-likelihoods, parameter estimates, and an appropriate model-selection criterion such as AIC, alongside goodness-of-fit diagnostics.

I would also be explicit about whether the comparison uses the same event sequence and observation window for both models.

Until the underlying numbers and calculation are verified, the 34% figure should be treated as a reported result rather than a fully substantiated benchmark.

8. How did you build the application?

LambdaLab combines a Python-based modeling backend with an interactive web interface.

The core technology stack includes:

  • Python: Numerical modeling, simulation, and data processing.
  • NumPy and SciPy: Numerical operations and parameter optimization.
  • Pandas: Tabular data handling and timestamp preprocessing.
  • FastAPI: Backend API layer for exposing modeling functionality.
  • React and TypeScript: Interactive frontend.
  • Plotly: Interactive visualizations of event streams and model behavior.

The application is designed to connect the mathematical modeling pipeline to a usable interface.

A typical workflow is to provide event timestamps, prepare the data, fit a model, inspect the estimated parameters, and visualize the resulting intensity or simulated event stream.

The interactive components make it possible to explore the relationship between model parameters and event-arrival behavior without manually rewriting the underlying mathematical implementation.

CSV-based data input and parameter exploration are part of the intended application workflow. The exact API endpoints, currently supported controls, and extent of the deployed functionality should be verified against the repository before describing every capability as production-ready.

9. What were the main challenges?

Numerical optimization: The likelihood depends nonlinearly on the Hawkes parameters. Optimization requires suitable initialization, valid parameter constraints, and checks for convergence.

Numerical stability: The likelihood contains logarithms of conditional intensities. Invalid parameter values or incorrectly computed intensities can produce numerical failures.

Event-stream preprocessing: Timestamp order, observation-window boundaries, and consistent time units are essential. Errors in preprocessing can change the model's interpretation and likelihood.

Computational efficiency: Fitting a model to a large event stream requires efficient evaluation of the conditional intensity. Repeatedly recomputing every past event's contribution can become expensive, making recursive updates valuable for exponential kernels.

Model interpretation: A better likelihood does not automatically establish that a model captures every relevant property of financial-market behavior. Goodness-of-fit diagnostics and out-of-sample analysis are important for stronger conclusions.

Visualization and API integration: A mathematical model becomes more useful when its inputs, parameters, and outputs can be inspected through a clear interface. This requires connecting numerical computation with appropriate API boundaries and visual representations.

These challenges made LambdaLab an exercise in both mathematical modeling and the engineering required to make a quantitative method accessible.

10. What did you learn, and what would you improve?

LambdaLab helped me connect stochastic-process theory with numerical estimation and interactive software development.

I learned how conditional intensity describes event-arrival behavior, how self-excitation creates temporal clustering, and how maximum likelihood can be used to estimate a model from observed timestamps.

The project also reinforced the distinction between fitting a model and validating it. A higher likelihood is evidence about relative fit on the evaluated data, but stronger conclusions require appropriate model-selection procedures, residual analysis, and out-of-sample evaluation.

If I extended LambdaLab, I would prioritize:

  1. Residual diagnostics: Use time-rescaling and related point-process goodness-of-fit checks to investigate whether the fitted model captures the observed event dynamics.
  2. Out-of-sample evaluation: Fit on one observation window and evaluate predictive performance on a separate interval.
  3. Robust optimization: Compare initializations, document convergence, and report uncertainty in fitted parameters.
  4. Performance improvements: Optimize intensity evaluation and benchmark fitting time as the number of events increases.
  5. Model comparisons: Compare Hawkes and Poisson models using clearly defined likelihood and model-selection criteria.
  6. Richer event models: Investigate marked or multivariate Hawkes processes to model different event types or interactions between instruments.
  7. Application improvements: Add clearer diagnostics, exportable results, reproducible model configurations, and more informative interactive visualizations.

These extensions would help move the project from an exploratory modeling application toward a more rigorous framework for studying temporal dependence in event-driven data.

11. What links and assets are available?

GitHub repository: https://github.com/HardikLovesTech/LambdaLab

The repository is the primary artifact for inspecting the project.

For the portfolio, I would highlight:

  • A diagram of the Hawkes conditional-intensity function.
  • An explanation of the maximum-likelihood objective.
  • A comparison between Hawkes and Poisson models.
  • A visualization of event arrivals and conditional intensity.
  • A simulation demonstrating how excitation strength and decay rate influence event clustering.
  • An architecture diagram showing the Python modeling backend, FastAPI API layer, React frontend, and Plotly visualizations.
  • An example dataset or reproducible demonstration, provided the data can legally be shared.

The central contribution is the integration of point-process modeling, numerical estimation, simulation, and interactive visualization into a single quantitative software project.

LambdaLab represents my interest in turning mathematical models into tools that people can explore, inspect, and use to build intuition about complex systems.