# About the Web Site High-Frequency Trading: A Practical Guide to Algorithmic Strategies and Trading Systems Book

An Avellaneda strategy feature that recalculates your hanging orders with aggregation of volume weighted, volume time weighted, and volume distance weighted. The spread (from mid-price) to defer the order refresh process to the next cycle. Vol_to_spread_multiplier will act as a threshold value to override max_spread when volatility is a higher value. The minimum spread related to the mid-price allowed by the user for bid/ask orders.

- Our algorithm works through 10 generations of instances of the AS model, which we will refer to as individuals, each with a different chromosomal makeup .
- The selection of features based on these three metrics reduced their number from 112 to 22 .
- These concerns are referred to the methodological part of the research and the writing style.
- You will need to hold a sufficient inventory of quote and or base currencies on the exchange to place orders of the exchange’s minimum order size.

The signals are determined by the approximate wealth changes during a fixed and limited holding period, during which we set stop-loss and take-profit points. These settings are heterogeneous for different stocks, and we provide a method to assign the values of these hyperparameters based on the historical average ratio of the best ask to the best bid price. Furthermore, the threshold of signals can be adjusted according to investors’ risk aversion. In 2008, Avellaneda and Stoikov published a procedure to obtain bid and ask quotes for high-frequency market-making trading . The successive orders generated by this procedure maximize the expected exponential utility of the trader’s profit and loss (P&L) profile at a future time, T , for a given level of agent inventory risk aversion.

## High-frequency trading and market performance

The goal with this approach is to offer a fair comparison of the former with the latter. By training with full-day backtests on real data respecting the real-time activity latencies, the models obtained are readily adaptable for use in a real market trading environment. Inventory management is therefore central to market making strategies , and particularly important in high-frequency algorithmic trading.

- However, adding secure points to a WANET can be costly in terms of price and time, so minimizing the number of secure points is of utmost importance.
- Instead of investing the same proportion consistently, we devise an optimization scheme using the fractional Kelly growth criterion under risk control, which is further achieved by the risk measure, value at risk .
- The spread (from mid-price) to defer the order refresh process to the next cycle.
- When parameters is closer to 1, will increase chances of one side of bid/ask to be executed with respect to the other, in that way forcing inventory to converge to target while decreasing the final profit.

Meanwhile, AS-https://www.beaxy.com/, again the best of the rest, won on Sortino on only 3 test days. The mean and the median of the Sortino ratio were better for both Alpha-AS models than for the Gen-AS model , and for the latter it was significantly better than for the two non-AS baselines. We performed genetic search at the beginning of the experiment, aiming to obtain the values of the AS model parameters that yield the highest Sharpe ratio, working on the same orderbook data. At each training step the parameters of the prediction DQN are updated using gradient descent.

## Robust Adversarial Reinforcement Learning

Your manuscript will remain under strict press embargo until 2 pm Eastern Time on the date of publication. If your institution or institutions have a press office, please notify them about your upcoming paper to help maximize its impact. If they’ll be preparing press materials, please inform our press team as soon as possible — no later than 48 hours after receiving the formal acceptance. In general, the legibility of the paper is hardly improved, and the revisions in this regards were mostly superficial. The reviewer can point in the directions and give some examples but it is simply impossible to list all of the specific details, and it should be on the authors to check the manuscript in detail.

Figures in parenthesis are the number of avellaneda-stoikov the Alpha-AS model in question was second best only to the other Alpha-AS model (and therefore would have computed another overall ‘win’ had it competed alone against the baseline and AS-Gen models). The btc-usd data for 7th December 2020 was used to obtain the feature importance values with the MDI, MDA and SFI metrics, to select the most important features to use as input to the Alpha-AS neural network model. A single parent individual is selected randomly from the current population , with a selection probability proportional to the Sharpe score it has achieved (thus, higher-scoring individuals have a greater probability of passing on their genes). The chromosome of the selected individual is then extracted and a truncated Gaussian noise is applied to its genes (truncated, so that the resulting values don’t fall outside the defined intervals).

Additionally, sensitivity to volatility changes will be included with a particular parameter vol_to_spread_multiplier, to modify spreads in big volatility scenarios. It’s no secret that foreign exchange market-makers offset the bulk of their risk internally by matching client trades against each other. By internalising risk, rather than hedging on external venues, dealers can avoid crossing spreads and paying brokerage fees.

The means of these thirty-two distributions ranged from 33 to 110 ticks per 5-second interval, the standard deviations from 21 to 67, the minimums ran from 0 to 20, the maximums from 233 to 1338, and the skew ranged from 1.0 to 4.4. Where Ψ(τi) is the open P&L for the 5-second action time step, I(τi) is the inventory held by the agent and Δm(τi) is the speculative P&L (the difference between the open P&L and the close P&L), at time τi, which is the end of the ith 5-second agent action cycle. The market-maker can post competitive bid and ask prices that improves on the current market price in order to manage the inventory. However, I do not see any specification of bounds for this reservation price and therefore I think there is no guarantee that ask prices computed by the market-maker will be higher or bid prices will be lower than the current price of the process. Our community is full of market makers and arbitrageurs who are willing to help each other make the best use of Hummingbot. You can join our Discord channel to talk about the hummingbot, strategies, liquidity mining, and anything else related to the cryptocurrency world and receive direct support from our team.

the model part is where it gets harder

if this gets any interest I’ll follow up with an ELI5 thread on the math behind a classical model from academia (Avellaneda & Stoikov)

it isn’t the full picture, but it’s definitely a strong starting point to being profitable as a MM

— ryuzaki (@0xRyuzaki) September 13, 2021

RARL is proposed, where an agent is trained to operate in the presence of a destabilizing adversary that applies disturbance forces to the system and the jointly trained adversary is reinforced – that is, it learns an optimal destabilization policy. Cricket teams are ranked to indicate their supremacy over their counter peers in order to get precedence. Various authors have proposed different statistical techniques in cricketing works to evaluate teams. However, it does not work well to realize the consistency of the teams’ performance.

The replay buffer obtained from the final iteration was used as the initial one for the test phase. At this point the trained neural network model had 10,000 rows of experiences and was ready to be tested out-of-sample against the baseline AS models. The two most important features for all three methods are the latest bid and ask quantities in the orderbook , followed closely by the bid and ask quantities immediately prior to the latest orderbook update and the latest best ask and bid prices . There is a general predominance of features corresponding to the latest orderbook movements (i.e., those denominated with low numerals, primarily 0 and 1). This may be a consequence of the markedly stochastic nature of market behaviour, which tends to limit the predictive power of any feature to proximate market movements.

It is then the latter that calculates the optimal bid and ask prices at each step. Consequently, the Alpha-AS agent adapts its bid and ask order prices dynamically, reacting closely (at 5-second steps) to the changing market. This 5-second interval allows the Alpha-AS algorithm to acquire experience trading with a certain bid and ask price repeatedly under quasi-current market conditions. As we shall see in Section 4.2, the parameters for the direct Avellaneda-Stoikov model to which we compare the Alpha-AS model are fixed at a parameter tuning step once every 5 days of trading data.

Avellaneda -Stoikov market making model – Quantitative Finance Stack Exchange https://t.co/BJMIqgi4XZ

— 🅳🅾︎🅼🅴 (@dome_cs) September 3, 2020

For instance, Avellaneda and Stoikov (ibid.) illustrate their method using a power law to model market order size distribution and a logarithmic law to model the market impact GAL of orders. Furthermore, as already mentioned, the agent’s risk aversion (γ) is modelled as constant in the AS formulas. Finally, as noted above, implementations of the AS procedure typically use the reservation price as an approximation for both the bid and ask indifference prices. The AS algorithm is static in its reliance on analytical formulas to generate bid and ask quotes based on the real-time input values for the market mid-price of the security and the current stock inventory held by the market maker.

making is a high-frequency trading problem for which solutions based on reinforcement learning are being explored increasingly. Two variants of the deep RL model (Alpha-AS-1 and Alpha-AS-2) were backtested on real data (L2 tick data from 30 days of bitcoin–dollar pair trading) alongside the Gen-AS model and two other baselines. The performance of the five models was recorded through four indicators (the Sharpe, Sortino and P&L-to-MAP ratios, and the maximum drawdown). Gen-AS outperformed the two other baseline models on all indicators, and in turn the two Alpha-AS models substantially outperformed Gen-AS on Sharpe, Sortino and P&L-to-MAP.

### Market-making by a foreign exchange dealer – Risk.net

Market-making by a foreign exchange dealer.

Posted: Wed, 10 Aug 2022 07:00:00 GMT [source]

AS-Gen had the best P&L-to-MAP ratio only for 2 of the test days, coming second on another 4. The mean and the median P&L-to-MAP ratio were very significantly better for both Alpha-AS models than the Gen-AS model. Table 6 compares the results of the Alpha-AS models, combined, against the two baseline models and Gen-AS. The figures represent the percentage of wins of one among the models in each group against all the models in the other group, for the corresponding performance indicator. For every day of data the number of ticks occurring in each 5-second interval had positively skewed, long-tailed distributions.

The agent’s action space itself can potentially also be enriched profitably, by adding more values for the agent to choose from and making more parameters settable by the agent, beyond the two used in the present study (i.e., risk aversion and skew). In the present study we have simply chosen the finite value sets for these two parameters that we deem reasonable for modelling trading strategies of differing levels of risk. This helps to keep the models simple and shorten the training time of the neural network in order to test the idea of combining the Avellaneda-Stoikov procedure with reinforcement learning. The results obtained in this fashion encourage us to explore refinements such as models with continuous action spaces. The logic of the Alpha-AS model might also be adapted to exploit alpha signals . The Alpha-AS agent receives an update of the orderbook every time a market tick occurs.

Experiments must have been conducted rigorously, with appropriate controls, replication, and sample sizes. Table 8 provides further insight combining the results for Max DD and P&L-to-MAP. From the negative values in the Max DD columns, we see that Alpha-AS-1 had a larger Max DD (i.e., performed worse) than Gen-AS on 16 of the 30 test days. However, on 13 of those days Alpha-AS-1 achieved a better P&L-to-MAP score than Gen-AS, substantially so in many instances.

A genetic algorithm is used to find the values of parameters used in Deep Deterministic Policy Gradient combined with Hindsight Experience Replay to help speed up the learning agent. A comprehensive ablation study is conducted to show that by utilizing deep reinforcement learning, a market making agent under order stacking framework successfully learns to improve the PL while reducing various risks. This survey paper aims to review the recent developments and use of RL approaches in finance, giving an introduction to Markov decision processes and introducing various algorithms with a focus on value and policy based methods that do not require any model assumptions. The analysis indicated that reinforcement learning techniques provide superior performance in terms of the risk-adjusted return over more standard market making strategies, typically derived from analytical models. On this performance indicator, AS-Gen was the overall best performing model, winning on 11 days.

This will set “boundaries” to the calculated optimal spread, so hummingbot will never create your orders with a spread smaller than the minimum nor bigger than the maximum. As usual, you can create a new strategy on Hummingbot using the create command. Since this is a market-making strategy, some configurations will be similar to the pure market-making strategy, so we will cover what is different in this article. Reading the paper, you won’t find any direct indication of calculating these two parameters’ values. So, as the trading session is getting closer to the end, order spreads will be smaller, and the reservation price position will be more “aggressive” on rebalancing the inventory. The Avellaneda & Stoikov model was created to be used on traditional financial markets, where trading sessions have a start and an end.

The genetic algorithm selects the best-performing values found for the Gen-AS parameters on the corresponding day of data. This procedure helps establish AS parameter values that fit initial market conditions. The same set of parameters obtained for the Gen-AS model are used to specify the initial Alpha-AS models.

Conversely, the gains may also be greater, a benefit which is indeed reflected unequivocally in the results obtained for the P&L-to-MAP performance indicator. Indeed, this result is particularly noteworthy as the Avellaneda-Stoikov method sets as its goal precisely to minimize the inventory risk. Nevertheless, the flexibility that the Alpha-AS models are given to move and stretch the bid and ask price spread entails that the Alpha-AS models can, and sometimes do, operate locally with higher risk.

Another distinctive feature of our work is the use of a genetic algorithm to determine the parameters of the AS formulas, which we use as a benchmark, to offer a fairer performance comparison to our RL algorithm. We have designed a market making agent that relies on the Avellaneda-Stoikov procedure to minimize inventory risk. The agent can also skew the bid and ask prices output by the Avellaneda-Stoikov procedure, tweaking them and, by so doing, potentially counteract the limitations of a static Avellaneda-Stoikov model by reacting to local market conditions.