
Explore statistical arbitrage with Python by building the STAT Bot, from strategy to execution, including testnet trading, order types like limit orders, and understanding how the markets move.
Master the principles of statistical arbitrage in crypto trading with python; you don’t need genius math—test with data, break problems down, and persist through limit and market orders.
Get the code from GitHub per this article
Understand that math defines the edge you need to profit; with odds against you, fees and spread erode returns, so aim for a multi percent edge and Bybit's paid trading.
Apply the Kelly Criterion to determine optimal position sizing for crypto statistical arbitrage, balancing win probability and payout to avoid overcapitalizing.
Learn to manage exchange and volatility risk in crypto arbitrage by using fiat-pegged assets like usdt, trading perpetual contracts on bybit, and applying careful position sizing to protect profits.
Explore statistical arbitrage and cointegration, including correlation versus cointegration, z-scores, and hedge ratios guiding mean-reverting crypto pair trading.
Place and manage long positions using market and limit orders on crypto exchanges. Learn take-profit, stop-loss, fees, rebates, and how order type choices affect execution and liquidity.
learn how shorting crypto works using derivatives to profit from down markets and why it's essential for statistical arbitrage, with careful risk management.
Understand conditional orders and how limit or market orders trigger at price moves, while tracking open positions, order history, and closed P&L on Bybit for building Albert in Python.
Create and fund a Bybit testnet account to safely test trading bots, transfer dummy funds to the derivatives account, and apply API testing principles with responsive chat support.
Create a Bybit api key and secret with read/write permissions for orders, positions, usdc, and derivatives trading. Copy and securely store the keys; note testnet versus mainnet and ip restrictions.
Learn to navigate Bybit API documentation, distinguish public and private endpoints, and connect via REST and WebSocket for market data, authentication, and account actions using API keys.
Master the Bybit api in a Google Colab workbook, distinguishing public and private endpoints, using testnet keys, and pulling order books and klines with rest vs web socket insights.
Connect to a web socket for streaming market data and subscriptions. Learn when to use web sockets vs REST for public and private data, and respect rate limits.
Retrieve tradable symbols from the API, filter for US currency pairs with trading status and negative maker fees, and compile a clean symbol list for price history.
Load and analyze price data, save and open the price file, then compute co-integrated pairs and extract close prices using a dedicated Python function.
Develop calculation functions to extract close prices and compute trade details from the order book, then determine mid-price, stop loss, and quantity with precise rounding.
Analyze liquidity by querying public trades to estimate the average order size, then place limit orders aligned with that liquidity to improve fill probability while exploring price calls.
Reuse existing z-score and spread logic to build a new func stats module, compute a z-score list, and return it with the current flag via the execution config API.
Implement functions to check open positions and active orders via the execution API, returning true when any position or active order exists, and defaulting to true on errors for safety.
Implement a query_existing_order function to fetch an active order’s price, quantity, and status using a ticker and order id, with API-based response handling.
Assemble the final trade management function to orchestrate new trades, integrate z-score thresholds, tradable capital, and order execution, and save bot status for the crypto arbitrage Python bot.
Compute the latest z-score and trigger hot trading when it clears the signal threshold, while monitoring liquidity through average liquidity and last price for tickers.
Demonstrates testing a crypto statistical arbitrage bot in Python: running trades, printing order states and z-scores, verifying remaining capital and position logic, and debugging for reliable mean-reversion trades.
Restore the bot to its intended config by fixing the kill switch logic, ensuring trades close and reopen on z-score signals, and updating api settings for Matic and SGX.
As requested by the Crypto Wizards community, this course provides you with:
An intuitive understanding of trading principles in crypto (and other) markets
Optimal calculations for risk, position sizing and entry/exit signals
Everything you need to know to practically get started in Statistical Arbitrage
How to find edge in multiple places and stack as many odds in your favour as possible
Pairs trading concepts which can profit in upwards, sideways and downwards (all) market conditions
An understand of Statistical Arbitrage and associated metrics
An understand on how trading works on a Crypto Exchange
How to tap into exchange price information at lightening speed via WebSockets and REST API
Python code and walkthrough (line-by-line) for finding your own co-integrated statistical arbitrage trading pairs
Python code and walkthrough (line-by-line) for developing your own trading bot
Most retail traders never learn some of what you will come across here, either because those who understand the concepts have not taken the time to break this down so that anyone can follow, or because there is so much nonsense existing today that filtering through the noise can be challenging.
In this course, we aim to break down barriers so that absolutely ANYONE can understand and tap into the advantages that these techniques can provide. The lecturer, Shaun McDonogh, himself admits that he is not a math wiz, nor needs to be. Once you understand these principles, you can apply them anywhere.
We will be using the ByBit exchange (taking advantage of one major benefit offered by the exchange) to build and test our bot. At no point do we use real money for testing. Rather, we use the testate funds provided by the exchange for ensuring forward testing in a "live" testate environment.
IMPORTANT: This course is for educational purposes only. Nothing you learn in this course is promising favourable or adverse results. You will be learning known methods for calculating statistical arbitrage and building trading bots. How you test and implement this knowledge is up to you.