{"id":224833,"date":"2025-06-02T12:12:08","date_gmt":"2025-06-02T16:12:08","guid":{"rendered":"https:\/\/ibkrcampus.com\/campus\/?p=224833"},"modified":"2025-06-02T12:12:02","modified_gmt":"2025-06-02T16:12:02","slug":"algorithmic-trading-guide-high-frequency-liquidity-taking-strategy","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\/","title":{"rendered":"Algorithmic Trading Guide: High-Frequency, Liquidity-Taking Strategy"},"content":{"rendered":"\n<p><em>The post &#8220;Algorithmic Trading Guide: High-Frequency, Liquidity-Taking Strategy&#8221; was originally published on <a href=\"https:\/\/databento.com\/blog\/liquidity-taking-strategy\">Databento<\/a> blog.<\/em><\/p>\n\n\n\n<p>In an earlier guide, we showed you how to build an algorithmic trading strategy with a model-based (machine learning) alpha in&nbsp;<a href=\"https:\/\/databento.com\/blog\/hft-sklearn-python\">Python with Databento and sklearn<\/a>.<\/p>\n\n\n\n<p>In this guide, we&#8217;ll walk you through how to build a rule-based algorithmic trading strategy instead. We&#8217;ll also show you how you can compute trading metrics like PnL online with Databento&#8217;s real-time feed. This example is adaptable to high-frequency trading (HFT) and mid-frequency trading scenarios.<\/p>\n\n\n\n<p>Before breaking down the strategy, let&#8217;s explain some terminology:<\/p>\n\n\n\n<p><strong>Feature<\/strong>: Any kind of basic independent variable that&#8217;s thought to have some predictive value. This follows machine learning nomenclature; others may refer to this as a predictor or regressor in a statistical or econometric setting.<\/p>\n\n\n\n<p><strong>Trading rule<\/strong>:&nbsp;A hardcoded trading decision. For example, &#8220;If there&#8217;s only one order left at the best offer, lift the offer; if there is only one order left at the best bid, hit the bid.&#8221; A trading rule may be a hardcoded trading decision taken when a feature value exceeds a certain threshold.<\/p>\n\n\n\n<p><strong>Rule-based strategy<\/strong>: A strategy that&#8217;s based on trading rules instead of model-based alphas.<\/p>\n\n\n\n<p><strong>Liquidity-taking&nbsp;strategy<\/strong>: A strategy that takes liquidity by crossing the spread with aggressive or marketable orders.<\/p>\n\n\n\n<p><strong>High-frequency&nbsp;strategy<\/strong>: A strategy characterized by a large number of trades. There&#8217;s no public consensus on what this means, but such strategies will usually show high directional turnover, at least 20 bps ADV, and small maximum position. Importantly, low latency and short holding period are not necessary conditions, but in practice, most such strategies exhibit sharp decay in PnL up to 15 microseconds wire-to-wire.<\/p>\n\n\n\n<p><strong>Mid-frequency strategy<\/strong>: There&#8217;s also no public convention on this term, but we&#8217;ll use it to refer to a relaxation of the low latency and directional turnover conditions as compared to a high-frequency strategy; a mid-frequency strategy will usually have intraday directional turnover in the order of hours for liquid instruments.<\/p>\n\n\n\n<p>Now that we have a few key terms defined, let&#8217;s dive into the strategy.<\/p>\n\n\n\n<p><strong>Book skew and trading rule<\/strong><\/p>\n\n\n\n<p>One of the simplest types of book feature is called the book skew, which is the imbalance between resting bid depth&nbsp; (<em>v<sub>b<\/sub><\/em>\u200b) &nbsp;and resting ask depth&nbsp; (<em>v<sub>a<\/sub><\/em>\u200b) &nbsp;at the top of the book. We can formulate this as some difference between&nbsp; <em>v<sub>b<\/sub><\/em>\u200b &nbsp;and&nbsp; <em>v<sub>a<\/sub><\/em>\u200b . It&#8217;s convenient to scale these by their order of magnitude, so we take their log differences instead.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"954\" height=\"84\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/skew-log-databento-formula.png\" alt=\"Algorithmic Trading Guide: High-Frequency, Liquidity-Taking Strategy\" class=\"wp-image-224837 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/skew-log-databento-formula.png 954w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/skew-log-databento-formula-700x62.png 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/skew-log-databento-formula-300x26.png 300w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/skew-log-databento-formula-768x68.png 768w\" data-sizes=\"(max-width: 954px) 100vw, 954px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 954px; aspect-ratio: 954\/84;\" \/><\/figure>\n\n\n\n<p>Notice that we picked this ordering simply because it&#8217;s useful to formulate features such that positive values imply that we expect prices to increase, making debugging your strategy easier. Intuitively, we expect higher bid depth to indicate higher buy demand and, hence, higher prices.<\/p>\n\n\n\n<p>We can introduce a trading rule that buys when this feature exceeds some skew threshold&nbsp;k and sells when it goes below some threshold&nbsp;<code>-k<\/code>.<\/p>\n\n\n\n<p><strong>Minimum order quantity<\/strong><\/p>\n\n\n\n<p>While there are some practical advantages to trading larger clips for a liquidity-taking strategy, we&#8217;ll start with a constant trade size equal to the minimum order quantity to minimize slippage and market impact considerations.<\/p>\n\n\n\n<p>The minimum order quantity depends on the trading platform or market that you&#8217;re on. For this sample strategy, we&#8217;ll use the E-mini S&amp;P 500 (ES) futures contract as an example and trade in clips of 1 contract.<\/p>\n\n\n\n<p class=\"has-text-align-center\">skew &gt;&nbsp;<em>k<\/em>&#8211;&gt; Buy 1 lot<\/p>\n\n\n\n<p class=\"has-text-align-center\">skew &gt;&nbsp;<em>-k<\/em>&#8211;&gt; Buy 1 lot<\/p>\n\n\n\n<p><strong>Commissions<\/strong><\/p>\n\n\n\n<p>Due to its volume, this strategy will be very sensitive to commissions, so we&#8217;ll include commissions on the estimated PnL. You can&nbsp;<a href=\"https:\/\/www.cmegroup.com\/company\/clearing-fees.html\" target=\"_blank\" rel=\"noreferrer noopener\">find these commissions&nbsp;here<\/a>.<\/p>\n\n\n\n<p><strong>Position and risk limits<\/strong><\/p>\n\n\n\n<p>This strategy is convenient because you don&#8217;t have to worry about complex order and position state management. You just let it build up whatever maximum position you want. You&#8217;ll eventually get out of position because we expect buys and sells to be symmetrically distributed in the long run. However, you might need more margin to build up arbitrarily large positions, so we&#8217;ll specify a maximum position of 10 contracts for proof of concept.<\/p>\n\n\n\n<p class=\"has-text-align-center\">skew &gt;&nbsp;<em>k<\/em>&nbsp;and abs pos &lt; 10 lots &#8211;&gt; Buy 1 lot<\/p>\n\n\n\n<p class=\"has-text-align-center\">skew &lt;&nbsp;<em>-k<\/em>&nbsp;and abs pos &gt; 10 lots &#8211;&gt; Sell 1 lot<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-implementation\">Implementation<\/h4>\n\n\n\n<p>Here are the parameters we have so far. We&#8217;re using the instrument with raw symbol&nbsp;<code>ESU3<\/code>&nbsp;(which is the September expiring contract). You&#8217;ll need to substitute this with your desired symbol.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import math\nfrom pprint import pprint\nfrom dataclasses import dataclass, field\nfrom decimal import Decimal\nfrom typing import Optional, List\n\nimport pandas as pd\nimport databento as db\n\n\n@dataclass(frozen=True)\nclass Config:\n    # Databento API Key\n    api_key: Optional[str] = None  # \"YOUR_API_KEY\"\n\n    # Alpha threshold to buy\/sell, k\n    skew_threshold: float = 1.7\n\n    # Databento dataset\n    dataset: str = \"GLBX.MDP3\"\n\n    # Instrument information\n    symbol: str = \"ES.c.0\"\n    stype_in: str = \"continuous\"\n    point_value: Decimal = Decimal(\"50\")  # $50 per index point\n\n    # Fees\n    venue_fees_per_side: Decimal = Decimal(\"0.39\")\n    clearing_fees_per_side: Decimal = Decimal(\"0.05\")\n\n    @property\n    def fees_per_side(self) -&gt; Decimal:\n        return self.venue_fees_per_side + self.clearing_fees_per_side\n\n    # Position limit\n    position_max: int = 10<\/pre>\n\n\n\n<p>Since we&#8217;re only simulating liquidity-taking at minimum size, our&nbsp;<code>mbp-1<\/code>&nbsp;<a href=\"https:\/\/docs.databento.com\/knowledge-base\/new-users\/fields-by-schema\/mbp-mbp-10-and-mbp-1\">schema<\/a>, which represents the top-of-book best bid and ask, is sufficient.<\/p>\n\n\n\n<p>To simplify this example, we&#8217;ll assume zero round-trip latency for any orders placed. This is unrealistic as this type of strategy will be extremely sensitive to latency, but allows us to demonstrate how to implement a simple, online calculation of PnL for our real-time trading simulation.<\/p>\n\n\n\n<p>An online algorithm like this is beneficial as the runtime and memory requirements do not increase with the number of data points used or number of orders placed in the simulation.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">@dataclass\nclass Strategy:\n    # Static configuration\n    config: Config\n\n    # Current position, in contract units\n    position: int = 0\n    # Number of long contract sides traded\n    buy_qty: int = 0\n    # Number of short contract sides traded\n    sell_qty: int = 0\n\n    # Total realized buy price\n    real_total_buy_px: Decimal = Decimal(\"0\")\n    # Total realized sell price\n    real_total_sell_px: Decimal = Decimal(\"0\")\n\n    # Total buy price to liquidate current position\n    theo_total_buy_px: Decimal = Decimal(\"0\")\n    # Total sell price to liquidate current position\n    theo_total_sell_px: Decimal = Decimal(\"0\")\n\n    # Total fees paid\n    fees: Decimal = Decimal(\"0\")\n\n    # List to track results\n    results: List[object] = field(default_factory=list)\n\n    def run(self) -&gt; None:\n        client = db.Live(self.config.api_key)\n        client.subscribe(\n            dataset=self.config.dataset,\n            schema=\"mbp-1\",\n            stype_in=self.config.stype_in,\n            symbols=[self.config.symbol],\n        )\n        for record in client:\n            if isinstance(record, db.MBP1Msg):\n                self.update(record)\n\n    def update(self, record: db.MBP1Msg) -&gt; None:\n        ask_size = record.levels[0].ask_sz\n        bid_size = record.levels[0].bid_sz\n        ask_price = record.levels[0].ask_px \/ Decimal(\"1e9\")\n        bid_price = record.levels[0].bid_px \/ Decimal(\"1e9\")\n\n        # Calculate skew feature\n        skew = math.log10(bid_size) - math.log10(ask_size)\n\n        # Buy\/sell based when skew signal is large\n        if (\n            skew &gt; self.config.skew_threshold\n            and self.position &lt; self.config.position_max\n        ):\n            self.position += 1\n            self.buy_qty += 1\n            self.real_total_buy_px += ask_price\n            self.fees += self.config.fees_per_side\n        elif (\n            skew &lt; -self.config.skew_threshold\n            and self.position &gt; -self.config.position_max\n        ):\n            self.position -= 1\n            self.sell_qty += 1\n            self.real_total_sell_px += bid_price\n            self.fees += self.config.fees_per_side\n\n        # Update prices\n        # Fill prices are based on BBO with assumed zero latency\n        # In practice, fill prices will likely be worse\n        if self.position == 0:\n            self.theo_total_buy_px = Decimal(\"0\")\n            self.theo_total_sell_px = Decimal(\"0\")\n        elif self.position &gt; 0:\n            self.theo_total_sell_px = bid_price * abs(self.position)\n        elif self.position &lt; 0:\n            self.theo_total_buy_px = ask_price * abs(self.position)\n\n        # Compute PnL\n        theo_pnl = (\n            self.config.point_value\n            * (\n                self.real_total_sell_px\n                + self.theo_total_sell_px\n                - self.real_total_buy_px\n                - self.theo_total_buy_px\n            )\n            - self.fees\n        )\n\n        # Print &amp; store results\n        result = {\n            \"ts_strategy\": record.pretty_ts_recv,\n            \"bid\": bid_price,\n            \"ask\": ask_price,\n            \"skew\": skew,\n            \"position\": self.position,\n            \"trade_ct\": self.buy_qty + self.sell_qty,\n            \"fees\": self.fees,\n            \"pnl\": theo_pnl,\n        }\n        pprint(result)\n        self.results.append(result)\n\n\nif __name__ == \"__main__\":\n    config = Config()\n    strategy = Strategy(config=config)\n    try:\n        strategy.run()\n    except KeyboardInterrupt:\n        pass\n    df = pd.DataFrame.from_records(strategy.results, index=\"ts_strategy\")\n    df.to_csv(\"strategy_log.csv\")<\/pre>\n\n\n\n<p><strong>Results<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"862\" height=\"543\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/hft_simulated_databento.jpg\" alt=\"\" class=\"wp-image-224841 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/hft_simulated_databento.jpg 862w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/hft_simulated_databento-700x441.jpg 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/hft_simulated_databento-300x189.jpg 300w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/hft_simulated_databento-768x484.jpg 768w\" data-sizes=\"(max-width: 862px) 100vw, 862px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 862px; aspect-ratio: 862\/543;\" \/><\/figure>\n\n\n\n<p>Source: Databento<\/p>\n\n\n\n<p><strong>Further improvements<\/strong><\/p>\n\n\n\n<p>This is a naive strategy to demonstrate the use of Databento and will usually show positive gross PnL before transaction costs and latency, but negative net PnL after. You should not deploy this into production as is.<\/p>\n\n\n\n<p>This implementation uses our simple synchronous client. For production applications, we recommend using our&nbsp;asynchronous client&nbsp;or&nbsp;callback model.<\/p>\n\n\n\n<p>There are various considerations to improve the strategy itself. This strategy only has an entry rule and only takes liquidity; it also has naive inventory management, and it will be sensitive to how the monetization parameter k is selected or optimized. A problem with the book skew is that spoofing may influence extreme values. One possibility is to modify the trading rule and introduce an upper limit as follows:<\/p>\n\n\n\n<p class=\"has-text-align-center\">skew &gt;&nbsp;<em>k<\/em>&nbsp;and abs(skew) &lt;&nbsp;<em>L<\/em>&nbsp;and abs(pos) &lt; 10 lots &#8211;&gt; Buy 1 lot<\/p>\n\n\n\n<p class=\"has-text-align-center\">skew &lt;&nbsp;<em>-k<\/em>&nbsp;and abs(skew) &lt;&nbsp;<em>L<\/em>&nbsp;and abs(pos) &lt; -10 lots &#8211;&gt; Sell 1 lot<\/p>\n\n\n\n<p>You can also replace or combine our rule-based signal here with a ML-based alpha, like the one found in the earlier tutorial on&nbsp;<a href=\"https:\/\/databento.com\/blog\/hft-sklearn-python\">Databento&#8217;s blog<\/a>.<\/p>\n\n\n\n<p>Finally, recall that we assumed zero delays in order placement and fill. It&#8217;s also important to incorporate a delay when extending this example.<\/p>\n\n\n\n<p>That&#8217;s all for this simple liquidity-taking strategy. To learn more, you can check out our&nbsp;<a href=\"https:\/\/docs.databento.com\/\">docs site<\/a>, see more&nbsp;<a href=\"https:\/\/docs.databento.com\/examples\">examples of our data<\/a>, or see our client libraries on our&nbsp;<a href=\"https:\/\/github.com\/databento\" target=\"_blank\" rel=\"noreferrer noopener\">GitHub<\/a>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-disclaimer\">Disclaimer<\/h4>\n\n\n\n<p>This post is for illustrative purposes only and is not intended as investment advice.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, we\u2019ll walk you through how to build a rule-based algorithmic trading strategy instead.<\/p>\n","protected":false},"author":186,"featured_media":224910,"comment_status":"open","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[339,343,349,338,341],"tags":[19594,19593,865,19595,1224],"contributors-categories":[18930],"class_list":{"0":"post-224833","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-data-science","8":"category-programing-languages","9":"category-python-development","10":"category-ibkr-quant-news","11":"category-quant-development","12":"tag-algorithmic-trading-high-frequency","13":"tag-databento-python-package","14":"tag-github","15":"tag-liquidity-taking-strategy","16":"tag-pandas","17":"contributors-categories-databento"},"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Algorithmic Trading Guide: High-Frequency, Liquidity-Taking Strategy<\/title>\n<meta name=\"description\" content=\"In this guide, we\u2019ll walk you through how to build a rule-based algorithmic trading strategy instead.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/224833\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Algorithmic Trading Guide: High-Frequency, Liquidity-Taking Strategy\" \/>\n<meta property=\"og:description\" content=\"In this guide, we\u2019ll walk you through how to build a rule-based algorithmic trading strategy instead.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-02T16:12:08+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/abstract-cubes-purple-blue.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"563\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Contributor Author\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Contributor Author\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\\\/\\\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"NewsArticle\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Contributor Author\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/e823e46b42ca381080387e794318a485\"\n\t            },\n\t            \"headline\": \"Algorithmic Trading Guide: High-Frequency, Liquidity-Taking Strategy\",\n\t            \"datePublished\": \"2025-06-02T16:12:08+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\\\/\"\n\t            },\n\t            \"wordCount\": 1144,\n\t            \"commentCount\": 0,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2025\\\/05\\\/abstract-cubes-purple-blue.jpg\",\n\t            \"keywords\": [\n\t                \"Algorithmic Trading. High-Frequency\",\n\t                \"databento Python package\",\n\t                \"GitHub\",\n\t                \"Liquidity-Taking Strategy\",\n\t                \"Pandas\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"Data Science\",\n\t                \"Programming Languages\",\n\t                \"Python Development\",\n\t                \"Quant\",\n\t                \"Quant Development\"\n\t            ],\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"CommentAction\",\n\t                    \"name\": \"Comment\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\\\/#respond\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\\\/\",\n\t            \"name\": \"Algorithmic Trading Guide: High-Frequency, Liquidity-Taking Strategy | IBKR Campus US\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2025\\\/05\\\/abstract-cubes-purple-blue.jpg\",\n\t            \"datePublished\": \"2025-06-02T16:12:08+00:00\",\n\t            \"description\": \"In this guide, we\u2019ll walk you through how to build a rule-based algorithmic trading strategy instead.\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\\\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2025\\\/05\\\/abstract-cubes-purple-blue.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2025\\\/05\\\/abstract-cubes-purple-blue.jpg\",\n\t            \"width\": 1000,\n\t            \"height\": 563,\n\t            \"caption\": \"Quant Abstract\"\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"name\": \"IBKR Campus US\",\n\t            \"description\": \"Financial Education from Interactive Brokers\",\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Organization\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\",\n\t            \"name\": \"Interactive Brokers\",\n\t            \"alternateName\": \"IBKR\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"logo\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\",\n\t                \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"width\": 669,\n\t                \"height\": 669,\n\t                \"caption\": \"Interactive Brokers\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\"\n\t            },\n\t            \"publishingPrinciples\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/about-ibkr-campus\\\/\",\n\t            \"ethicsPolicy\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/cyber-security-notice\\\/\"\n\t        },\n\t        {\n\t            \"@type\": \"Person\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/e823e46b42ca381080387e794318a485\",\n\t            \"name\": \"Contributor Author\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/contributor-author\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Algorithmic Trading Guide: High-Frequency, Liquidity-Taking Strategy","description":"In this guide, we\u2019ll walk you through how to build a rule-based algorithmic trading strategy instead.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/224833\/","og_locale":"en_US","og_type":"article","og_title":"Algorithmic Trading Guide: High-Frequency, Liquidity-Taking Strategy","og_description":"In this guide, we\u2019ll walk you through how to build a rule-based algorithmic trading strategy instead.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\/","og_site_name":"IBKR Campus US","article_published_time":"2025-06-02T16:12:08+00:00","og_image":[{"width":1000,"height":563,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/abstract-cubes-purple-blue.jpg","type":"image\/jpeg"}],"author":"Contributor Author","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Contributor Author","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\/"},"author":{"name":"Contributor Author","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/e823e46b42ca381080387e794318a485"},"headline":"Algorithmic Trading Guide: High-Frequency, Liquidity-Taking Strategy","datePublished":"2025-06-02T16:12:08+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\/"},"wordCount":1144,"commentCount":0,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/abstract-cubes-purple-blue.jpg","keywords":["Algorithmic Trading. High-Frequency","databento Python package","GitHub","Liquidity-Taking Strategy","Pandas"],"articleSection":["Data Science","Programming Languages","Python Development","Quant","Quant Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\/","name":"Algorithmic Trading Guide: High-Frequency, Liquidity-Taking Strategy | IBKR Campus US","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/abstract-cubes-purple-blue.jpg","datePublished":"2025-06-02T16:12:08+00:00","description":"In this guide, we\u2019ll walk you through how to build a rule-based algorithmic trading strategy instead.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/algorithmic-trading-guide-high-frequency-liquidity-taking-strategy\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/abstract-cubes-purple-blue.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/abstract-cubes-purple-blue.jpg","width":1000,"height":563,"caption":"Quant Abstract"},{"@type":"WebSite","@id":"https:\/\/ibkrcampus.com\/campus\/#website","url":"https:\/\/ibkrcampus.com\/campus\/","name":"IBKR Campus US","description":"Financial Education from Interactive Brokers","publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ibkrcampus.com\/campus\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/ibkrcampus.com\/campus\/#organization","name":"Interactive Brokers","alternateName":"IBKR","url":"https:\/\/ibkrcampus.com\/campus\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","width":669,"height":669,"caption":"Interactive Brokers"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/"},"publishingPrinciples":"https:\/\/www.interactivebrokers.com\/campus\/about-ibkr-campus\/","ethicsPolicy":"https:\/\/www.interactivebrokers.com\/campus\/cyber-security-notice\/"},{"@type":"Person","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/e823e46b42ca381080387e794318a485","name":"Contributor Author","url":"https:\/\/www.interactivebrokers.com\/campus\/author\/contributor-author\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/05\/abstract-cubes-purple-blue.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/224833","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/users\/186"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=224833"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/224833\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/224910"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=224833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=224833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=224833"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=224833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}