BotFed

4 posts

BotFed

BotFed

@BotFedAI

Quant-grade AI agents for on-chain yield optimization. Built for the adversarial DeFi environment.

شامل ہوئے Mart 2025
7 فالونگ33 فالوورز
David Simic
David Simic@DrDavidSimic·
When doing market making or cross exchange arb in crypto we discussed some of the issues of computing fair price from multiple geo-distributed data feeds. Your quotes will arrive asynchronously from Binance, Bybit, Coinbase and so on, and each will be an indirect measure of fair price. For example, how do you weigh the Binance and Bybit quotes that came in 35ms and 75ms ago against that Coinbase quote that came in 15ms ago? What about when the ordering is reversed? Each exchange has a different level of liquidity, error, and basis, so even if the quotes were all equally fresh, there'd still be some decisions to be made. But latency adds an additional layer of complexity. One mental model for this is ruler theory. Imagine trying to combine the measurements of a bunch of different rulers, each with their own bias (μ) and error (σ), into one optimal measurement. Bias means a particular ruler is on average off from the truth by a consistent amount. Error means there is a random fluctuation by how much it is off from this average amount, sometimes a lot, sometimes a little, but usually within one stdev around the truth. In physics, the way to weight each measurement is via precision weighting where each ruler is weighted by its inverse variance: ~ 1/σ² A quote from a particular exchange is like a ruler measurement of fair price in that it too has its own bias and error. The dominant part of bias is easy to measure, it is just basis, and a good start is to compute a rolling mean. Error is a bit more complex. It will depend on liquidity, spread, volatility ... and time elapsed. BTC-USDT on Binance is expected to be a less errorful measurement of BTC than the same instrument on say, Kucoin. But BTC-USDT on Binance 1 second ago is expected to be more errorful than BTC-USDT on Kucoin 10ms ago. So there is an innate component to error and a time component. Total error squared will look something like this: error² ≈ ε²_exchange + σ_price²·τ where τ is the amount of time that has elapsed from when the quote was emitted to when you registered it, and ε²_exchange is the error unique to that instrument on that exchange (and at that particular point in time). For the time dependence, the assumption here is Gaussian diffusion, which is a defensible first order approximation when you are not near a significant liquidity event. So errors have a component that grows at a speed proportional to variance, creating a kind of uncertainty cone as they propagate forward in time. This tells you roughly how to weigh different quotes from different exchanges arriving at different times. Below are plots from two models built on this intuition. Both are measurably better than just using the Binance mid-quote, and in production, more robust against feed glitches on any single exchange. We'll discuss in more detail some concrete models that incorporate this intuition, and some that work surprisingly well while ignoring parts of it, in a subsequent post.
David Simic tweet mediaDavid Simic tweet media
English
22
20
365
24.6K
David Simic
David Simic@DrDavidSimic·
Tired of being adversely selected? Previously we mentioned the multiple advantages to forecasting vol as a market maker or algo trader in crypto. But what are some sensible ways of forecasting vol? The first question I'd ask is, how do I even decide if I am doing a good job forecasting vol, or in more technical lingo, what loss function should I use? Obviously I need to compare realized vol to my forecasts, but how exactly? The first thing to note is that while variance has a heavily right-skewed distribution, and is never negative, log of variance has a roughly Gaussian distribution. See the graph below. So while MSE on var would be a lousy and poorly motivated loss function (MSE is derived from MLE assuming Gaussian), MSE on log var should work pretty well, and any fit using this loss function would be motivated by an application of Bayes theorem and MLE. Loss = (1/T)Σ (log σ²_t - log h_t)² where h_t is predicted vol and σ is realized vol. Can we do even better? Yes, a bit. Looking at the log variance distribution we notice that it has a significant skew and kurtosis. Any trader would know this intuitively. Volatility when it spikes, spikes in a massive way, interleaved with periods of unusually low vol and intermediate vol. The loss function that is best motivated in this case is QLike, and it turns out that you can show it is the optimal loss function to use with extremely relaxed assumptions on the underlying distributions: Loss = (1/T)Σ [σ²_t/h_t - log(σ²_t/h_t) - 1] And the beauty is we don't need to know which distribution it is. It could be a mixture of distributions (ie: corresponding to different regimes via a latent variable), for all we know (and as suggested by the plot in level space below). For our purposes though, as practical traders, the main thing to notice is that this loss function penalizes more when we underestimate vol (h smaller than σ) than when we overestimates (h larger than σ). This is good, as market makers we lose more when we underestimate vol (tighter quotes than optimal -> more adverse selection) than when we overestimate it (wider quotes than optimal -> no fills -> less adverse selection). In practice qlike vs mse might not be a game changer, given a good underlying model, however it is one of those optimizations to keep in mind. So now that we got that out of the way, which ways of modeling vol are good and which are bad? Stay tuned for the next post. 👇
David Simic tweet media
English
4
5
71
5.5K
ETHDenver 🏔🦬🦄
ETHDenver 🏔🦬🦄@EthereumDenver·
We want to connect with more of the BUIDLers in our community. Engage with this post if you need a follow 🙌
ETHDenver 🏔🦬🦄 tweet media
English
598
35
2K
111.2K
David Simic
David Simic@DrDavidSimic·
Are Trump’s Tariffs just the surface? Behind them is a deeper shift in currency flows and capital structure — engineered by Trump’s top economic advisor, Dr. Stephen Miran. A thread.
David Simic tweet media
English
3
0
2
202