r/algorithmictrading • • Jun 14 '25

A Full Guide to Risk Management

10 Upvotes

https://www.vertoxquant.com/p/a-full-guide-to-risk-management

Released a really big article which is a full guide to risk management covering topics:

  • Risk Metrics

  • Volatility Modeling

  • Dependence Modeling

  • Stress Testing and Scenario Analysis

  • Liquidity-adjusted Value-at-Risk (LVaR) and Liquidity Modeling

  • Portfolio Optimization Under Tail Constraints


r/algorithmictrading • • Sep 10 '24

My initial Algorithmic Trading Architecture

10 Upvotes

Hello, I am working on my own trading system and I came across this architecture in a book. I made few changes based on what I already know.

The Celery workers fetch data from sources like Yahoo Finance,AlphaVantage and others, process it, and publish it via Redis. Bots subscribe to this data, make trading decisions, and execute orders through brokers like XTB and Bitso. I thinks it is scalable, and I am also planning to use Rapsberry Pis to support the architecture. I still need to design the bots and think about how to improve my backtesting, model training and monitoring workflows. what do you think? any suggestions?


r/algorithmictrading • • Jul 18 '24

Backtest A Mean-Reversion Strategy for US Crude Oil (WTI)

10 Upvotes

This strategy is mainly built on a single indicator that I found, the RSI Divergence from ProRealCode. This indicator detects bullish and bearish divergences between price and the RSI. A bullish divergence occurs when the stock price makes new lows while the indicator starts to climb upward. A bearish divergence occurs when the stock price makes new highs while the indicator starts to go lower. We also implement a moving average crossover as a filter. So with something as simple as one indicator and one filter we can get something quite interesting. Out-of-sample for this strategy is since 2021-01-01.

Setup for Backtest

Market: US Crude Oil (WTI)

Contract: 1 € per point

Broker: IG

Testing environment: ProRealtime 12

Timeframe: Daily

Time zone: CET

No fees and commissions are included.

Result

Total gain: 28 699.3 €

Average gain: 123.17 €

Total trades: 233

Winners: 172

Losers: 61

Breakeven: 0

Max drawdown: –2 887.7 €

Risk/reward ratio: 1.15

Total time in the market: 35.52 %

Average time in the market: 11 days, 15 hours

CAGR (10 000 € in starting capital): 4.61 %

Entry Conditions

~Long Entry~

  1. MA[20] is higher today than yesterday.

  2. A bullish signal from the RSI Divergence Indicator [3,40,70,20].

~Short Entry~

  1. MA[20] is lower than yesterday.

  2. MA[10] is also lower than yesterday.

  3. A bearish signal from the RSI Divergence Indicator [3,20,70,20].

Exit Conditions

~Long Exit~

  1. A bearish signal from the RSI Divergence Indicator [3,40,70,20]

  2. Or if the number of bars since entry exceeds 40.

~Short Exit~

  1. A bullish signal from the RSI Divergence Indicator [3,20,70,20]

  2. Or if the number of bars since entry exceeds 40.

If you have any improvements to this strategy let me know.


r/algorithmictrading • • Jan 22 '24

Learning Path for Beginner

10 Upvotes

Hey guys i am a software engineer with almost 4 years of industry experience. I also have extensive experience in startups. I just say this to say I'm not a newbie to software engineering, and I think I'm somewhere better than the average. I really want to challenge myself and become a quant dev or a maestro at algorithmic trading. I would love any ideas on extensive resources on where to start this new challenging journey so that I may land a job at top trading firm


r/algorithmictrading • • Jul 20 '23

Open-Sourcing High-Frequency Trading and Market-Making Backtesting Tool

10 Upvotes

https://www.github.com/nkaz001/hftbacktest

I know that numerous backtesting tools exist. But most of them do not offer comprehensive tick-by-tick backtesting, taking latencies and order queue positions into account.

Consequently, I developed a new backtesting tool that concentrates on thorough tick-by-tick backtesting while incorporating latencies, order queue positions, and complete order book reconstruction.

Key features:

  • Working in Numba JIT function.

  • Complete tick-by-tick simulation with a variable time interval.

  • Full order book reconstruction based on L2 feeds(Market-By-Price).

  • Backtest accounting for both feed and order latency, using provided models or your own custom model.

  • Order fill simulation that takes into account the order queue position, using provided models or your own custom model.

Example:

Here's an example of how to code your algorithm using HftBacktest. For more examples including market-making and comprehensive tutorials, please visit the documentation page here.

@njit
def simple_two_sided_quote(hbt, stat):
    max_position = 5
    half_spread = hbt.tick_size * 20
    skew = 1
    order_qty = 0.1
    last_order_id = -1
    order_id = 0

    # Checks every 0.1s
    while hbt.elapse(100_000):
        # Clears cancelled, filled or expired orders.
        hbt.clear_inactive_orders()

        # Obtains the current mid-price and computes the reservation price.
        mid_price = (hbt.best_bid + hbt.best_ask) / 2.0
        reservation_price = mid_price - skew * hbt.position * hbt.tick_size

        buy_order_price = reservation_price - half_spread
        sell_order_price = reservation_price + half_spread

        last_order_id = -1
        # Cancel all outstanding orders
        for order in hbt.orders.values():
            if order.cancellable:
                hbt.cancel(order.order_id)
                last_order_id = order.order_id

        # All order requests are considered to be requested at the same time.
        # Waits until one of the order cancellation responses is received.
        if last_order_id >= 0:
            hbt.wait_order_response(last_order_id)

        # Clears cancelled, filled or expired orders.
        hbt.clear_inactive_orders()

            last_order_id = -1
        if hbt.position < max_position:
            # Submits a new post-only limit bid order.
            order_id += 1
            hbt.submit_buy_order(
                order_id,
                buy_order_price,
                order_qty,
                GTX
            )
            last_order_id = order_id

        if hbt.position > -max_position:
            # Submits a new post-only limit ask order.
            order_id += 1
            hbt.submit_sell_order(
                order_id,
                sell_order_price,
                order_qty,
                GTX
            )
            last_order_id = order_id

        # All order requests are considered to be requested at the same time.
        # Waits until one of the order responses is received.
        if last_order_id >= 0:
            hbt.wait_order_response(last_order_id)

        # Records the current state for stat calculation.
        stat.record(hbt)

Additional features are planned for implementation, including multi-asset backtesting and Level 3 order book functionality.


r/algorithmictrading • • Jun 21 '22

new to algorithmic trading

10 Upvotes

I've just started learning how to code for a trading algorithm in Python. I use sterling trader pro and thinkorswim, which if either is better for python? Also what kind of software should I look for to interface my algorithm and trading platform? Any insight would be appreciated.


r/algorithmictrading • • Aug 22 '21

What is your data engineering infrastructure/setup & cost for trading data?

10 Upvotes

TL;DR - What kind of trading data are you storing and how/where are you storing it? Also how much does it cost for you per month?

I'm new to algorithmic trading, and I'm prototyping a platform with a friend (I'm working on the data engineering part, they are working on the data science part). We're looking at crypto opportunities, and specifically starting with 1m OHLCV data across a few different exchanges (considering all pairs per exchange).

I'm not sure what tools & infrastructure we'll use yet (likely use AWS for everything), but goes without saying: amount of data adds up fast! How do you all handle this? Specifically:

  1. What kind of data are you storing?

  2. What is your data engineering infrastructure? And where is it / where are you hosting?

  3. How much are you paying per month?

Any thoughts are much appreciated!


r/algorithmictrading • • May 05 '21

Reinforcement learning in speculative markets

10 Upvotes

Just wondering if anyone's used python reinforcement learning applied to speculative markets like crypto. I've started pursuing this but was wondering if anyone's had success.

The "environment" would be OCLHV data and other key features over time. Rewards are successful trades.


r/algorithmictrading • • Nov 30 '20

The Wild $50M Ride of the Flash Crash Trader

Thumbnail
youtu.be
10 Upvotes

r/algorithmictrading • • May 22 '20

Broker with API in Europe

10 Upvotes

I have been working on a trading bot recently and I would like to start testing it with a paper account and potentially real money at some point.

I have been looking for brokers with APIs but I could not find any that match my criteria yet.

  • Ideally, I would like the broker to have low to zero fees

  • has Official API

  • has Demo account

  • Can be used in Europe

I found Alpaca but this is U.S Based and they only offer margin accounts that are subject to the PDT rule.

Interactive brokers do not offer free trades outside US

I also came across trading 212 which has an unofficial python API that's using selenium. not ideal...

as a last resort I will apply my bot on binance on cryptos but ideally I would like to see it in the stock market.

Any recommendations?


r/algorithmictrading • • Apr 16 '19

The seven reasons most econometric investments fail « Mathematical Investor

Thumbnail
mathinvestor.org
10 Upvotes

r/algorithmictrading • • Mar 21 '19

Most of highest-earning hedge fund managers and traders are at quant firms

Thumbnail mathinvestor.org
10 Upvotes

r/algorithmictrading • • Dec 18 '18

Educational "Optimizing Trading Strategies without Overfitting" by Dr. Ernest Chan - QuantCon 2018

Thumbnail
youtube.com
10 Upvotes

r/algorithmictrading • • Nov 27 '18

The Triple Jeopardy of Ke Xu, a Chinese Hedge Fund Quant

Thumbnail bloomberg.com
10 Upvotes

r/algorithmictrading • • Aug 23 '18

Crypto trading platform launch this fall including AI and machine learning (Cryzen).

Thumbnail
medium.com
10 Upvotes

r/algorithmictrading • • Aug 08 '18

Building a cryptocurrency arbitrage bot - Part 1: Basics

Thumbnail
youtube.com
10 Upvotes

r/algorithmictrading • • Jun 17 '18

Best book to learn algorithmic trading?

10 Upvotes

It would be good if it was a book that explained things from a beginners prespective amd then go into more details since Im not very experiences in the algorithms


r/algorithmictrading • • May 22 '17

Bye Yahoo, and thanks for all the fish

Thumbnail
financial-hacker.com
10 Upvotes

r/algorithmictrading • • Aug 09 '15

WSJ: An Algo and a Dream for Day Traders

Thumbnail
wsj.com
10 Upvotes

r/algorithmictrading • • 3d ago

Strategy Put spread selling strategy

Post image
9 Upvotes

This is walk-forward of ensemble model for selling put spreads on "good days". The model was trained to find those good days - ca 60 trades per year (retrained each year with another year of training data added). The outcome looks quite good, yes, the risk is pretty high but due to high hit rate losses are rare. Would you normally consider such amount of walk-forward back testing enough to start?


r/algorithmictrading • • 27d ago

Strategy I tested 24 popular stock-trading "rules" on ~377,000 real signals. None of them beat a fair baseline.

9 Upvotes

Every night I log ~6,000 US stocks, including ones that later got delisted (no survivorship bias). I used ~1 year of these logs to test 24 popular one-line trading "rules."

Method
- For each rule (e.g. "RSI below 30 means a bounce is coming"), find every time it fired and check whether the stock was up 20 trading days later.
- Baseline: stocks with similar volatility on the same day, not the whole market. Otherwise volatile stocks look like winners just because they move more.
- Rules and pass criteria were fixed before looking at results. Benjamini-Hochberg correction across all 24.

Results (as of late Oct 2026)
- Real edge: 0 / 24
- No measurable difference: 13
- Volatility illusion (looked good only because the stocks were more volatile): 7
- Worse than baseline: 4

Examples
- RSI < 30 = bounce: 50.1% up vs 49.7% expected (9,871 cases)
- 52-week-high breakout: 52.3% vs 51.2%, volatility illusion (12,649 cases)
- Penny stocks under $5 run harder: 38.6% vs 42.8%, worse (15,857 cases)
- Buy after a 20%+ drop in 5 days: 38.6% vs 41.8%, worse (6,182 cases)
- CEO/CFO insider buys: 57.1% vs 53.0%, but only 837 cases, not significant after correction

Limitations
- ~1 year of data, mostly one market regime.
- "Up after 20 days" is one lens, not a full backtest with stops and position sizing.
- This doesn't show technical analysis is useless. Only that these one-line rules, alone, didn't beat a volatility-matched baseline in this sample.


r/algorithmictrading • • Oct 16 '26

Novice Resources to learn Algo trading

9 Upvotes

Hey i am a complete beginner who wants to learn Algorading. Can anybody suggest some good free resources where I can learn Algo trading from basics to advance.


r/algorithmictrading • • Oct 06 '26

Backtest Eight-module XAUUSD portfolio: frozen-parameter OOS and block-bootstrap results

9 Upvotes

I combined eight independent XAUUSD modules into a single portfolio and tested the final structure across development, frozen-parameter OOS and older stress periods.

TEST PROTOCOL

• 2022–2024: in-sample development

• 2025–2026: frozen-parameter out-of-sample validation

• 2021: separate stress/history period

• 2017–2018: additional survival checks

The purpose of the split was to separate the years that influenced module selection and parameter choices from the years used to evaluate the finished portfolio.

FULL REAL-TICK PORTFOLIO RUN

Period: January 2021 to September 2026

Initial balance: USD 1,000

Ending balance: USD 3,903.12

Closed trades: 1,511

Profit factor: 2.93

Maximum relative equity drawdown: 12.82%

The modules were evaluated together because nominal strategy count can hide concentrated XAUUSD exposure. Portfolio-level floating equity was therefore treated as the main risk measure.

YEAR-BY-YEAR RESULTS

2021: +45.03%, PF 3.03

2022: +32.36%, PF 2.71

2023: +16.22%, PF 2.82

2024: +13.62%, PF 1.94

2025 OOS: +16.84%, PF 3.01

2026 OOS through September: +31.79%, PF 7.18

Returns varied materially by year, but the edge did not disappear after the parameter freeze. Both OOS years remained profitable. The 2026 PF is a partial-year observation and should not be treated as a stable expectation.

BLOCK-BOOTSTRAP CHECK

I ran 10,000 paths using the complete 2021–2026 deal sequence and resampled 50-deal blocks to preserve short clusters of wins and losses.

Median ending balance: USD 3,896

5th–95th percentile ending balance: approximately USD 3,504–4,318

Median maximum realised-balance drawdown: 4.1%

95th-percentile maximum realised-balance drawdown: 8.0%

LIMITATIONS

The bootstrap rearranges realised deal results. It does not reconstruct every floating basket, reproduce broker-specific execution or invent unseen future regimes. Because of that, the observed MT5 relative equity drawdown of 12.82% remains the more relevant risk figure.

The next step is live observation of spreads, slippage, swap, execution and floating-basket behaviour. The backtest is evidence of historical robustness, not proof of future performance.


r/algorithmictrading • • Sep 06 '26

Novice New to Quant Finance , Need Advice on Starting and Sources

9 Upvotes

I am new to the world of Quant Finance , found many sources but I feel Distracted don't know how to start .
I already have a Background in Finance and Programming (C++ and Python ) I just Need Sources to learn Quant Finance