{"id":246995,"date":"2026-06-25T11:40:41","date_gmt":"2026-06-25T15:40:41","guid":{"rendered":"https:\/\/ibkrcampus.com\/campus\/?p=246995"},"modified":"2026-06-25T11:43:06","modified_gmt":"2026-06-25T15:43:06","slug":"applying-transformers-to-financial-time-series","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/applying-transformers-to-financial-time-series\/","title":{"rendered":"Applying Transformers to Financial Time Series"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><em>The article &#8220;Applying Transformers to Financial Time Series&#8221; was originally published on <a href=\"https:\/\/predictnow.ai\/applying-transformers-to-financial-time-series\/\">PredictNow.ai<\/a>.<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In the previous&nbsp;<a href=\"https:\/\/open.substack.com\/pub\/gatambook\/p\/a-poor-persons-transformer?r=7j9m8&amp;utm_campaign=post&amp;utm_medium=web&amp;showWelcomeOnShare=false\">blog post<\/a>, we gave a very simple example of how traders can use self-attention transformers as a feature selection method: in this case, to select which previous returns of a stock to use for predictions or optimizations. To be precise, the transformer assigns weights on the different transformed features for downstream applications. In this post, we will discuss how traders can incorporate different feature series from this stock while adding a sense of time. The technique we discuss is based partly on Prof. Will Cong\u2019s&nbsp;<a href=\"https:\/\/papers.ssrn.com\/sol3\/papers.cfm?abstract_id=3554486\">AlphaPortfolio paper<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Recall that in the simple example in a Poor Person\u2019s Transformer, the input X is just a n-vector with previous returns X=[R(t), R(t-1), \u2026, R(t-n+1)]<sup>T<\/sup>. Some of you fundamental analysts will complain \u201cWhat about the fundamentals of a stock? Shouldn\u2019t they be part of the input?\u201d Sure they should! Let\u2019s say, following AlphaPortfolio, we add B\/M, EPS, \u2026, all 51 fundamental variables of a company as input features. Furthermore, just as for the returns, we want to know the n previous snapshots of these variables. So we expand X from 1 to 52 columns (including the returns column). For concreteness, let\u2019s say we use n=12 snapshots, captured at monthly intervals, and regard R(t) as the monthly return from t-1 to t. X is now a 12 \u00d7 52 matrix.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" width=\"768\" height=\"243\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-1.png\" alt=\"\" class=\"wp-image-247570 lazyload\" style=\"--smush-placeholder-width: 768px; aspect-ratio: 768\/243;width:768px;height:auto\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-1.png 768w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-1-700x221.png 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-1-300x95.png 300w\" data-sizes=\"(max-width: 768px) 100vw, 768px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Are we ready to use them as input to our transformer? Goodness, no! As we said in our previous blog post, raw heterogeneous features, i.e. features that are from different spaces such as returns vs EPS, can\u2019t be mixed up in a transformer without normalization. In AlphaPortfolio, the authors normalize them cross-sectionally, i.e. for each snapshot of time, compute the mean and std of a feature across the universe of stocks and thus turn every feature into a z-score. In our case, we only have 1 stock, so we have to normalize temporally, i.e. compute the mean and std of a feature in a lookback period in order to compute z-scores. For simplicity, we might as well use 12 months as the lookback period.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After normalizing all these features into z-scores, are we ready to use them as input to our transformer? Goodness, no! We usually project (linearly transform) the raw features into a higher dimensional embedding space before input to a transformer. In our case, we will project the 52 features into a 64-dimensional space (the embedding space dimension is usually a power of 2 and is larger than the original feature space):<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"548\" height=\"92\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-2.png\" alt=\"\" class=\"wp-image-247573 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-2.png 548w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-2-300x50.png 300w\" data-sizes=\"(max-width: 548px) 100vw, 548px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 548px; aspect-ratio: 548\/92;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">where W<sub>embed<\/sub>(t) is a 52 \u00d7 64 projection \/ embedding matrix, with values to be optimized based on the downstream objective function, and X<sub>embed<\/sub>(t) is a 12 \u00d7 64 input matrix projected to the embedding space.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After this embedding, are we ready to use them as input to our transformer? Goodness, no! (Ernie has been reading too much Pete The Cat to his kids, hence the idiom.) Unlike a LSTM, our transformer does not know that feature X(t) comes after X(t-1) in time: there is no sense of time ordering. We need to apply \u201cpositional encoding\u201d. This is done by adding a \u201cpositional encoding vector\u201d PE to each input that encodes its position in the time series:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"626\" height=\"78\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-3.png\" alt=\"\" class=\"wp-image-247575 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-3.png 626w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-3-300x37.png 300w\" data-sizes=\"(max-width: 626px) 100vw, 626px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 626px; aspect-ratio: 626\/78;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">where i is the lookback from 0 to 11 months with i=0 pointing to the current time t, and j is the feature index in the embedding space, and<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"768\" height=\"175\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-4.png\" alt=\"\" class=\"wp-image-247578 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-4.png 768w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-4-700x160.png 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-4-300x68.png 300w\" data-sizes=\"(max-width: 768px) 100vw, 768px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 768px; aspect-ratio: 768\/175;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">with<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"192\" height=\"68\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-5.png\" alt=\"\" class=\"wp-image-247595 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 192px; aspect-ratio: 192\/68;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So k=0 to d\/2-1, that is from 0 to 64\/2-1. (Recall d=64 is the embedding dimension.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What\u2019s the intuition behind this formula? In general, if we have a time series Y(t) sampled at discrete intervals, we can always perform a Fourier decomposition:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img decoding=\"async\" width=\"768\" height=\"114\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-6.png\" alt=\"\" class=\"wp-image-247613 lazyload\" style=\"--smush-placeholder-width: 768px; aspect-ratio: 768\/114;width:768px;height:auto\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-6.png 768w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-6-700x104.png 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-6-300x45.png 300w\" data-sizes=\"(max-width: 768px) 100vw, 768px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">PE(i, j) looks just like each of these cosine or sine basis function, with 1\/10000^(2k\/64) playing the role of the frequency (2 \u03c0 j\/N). So by adding PE, we are adding each of these cosine and sine basis functions to the original X<sub>embed<\/sub>(t), and hope that the transformer will treat X<sub>input<\/sub>=X<sub>embed<\/sub>+PE as a time series. After all, as discussed in the previous blog post, the transformer is going to add the different basis functions up with some coefficients via matrix multiplications and make them into Q, K, V matrices:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"768\" height=\"61\" data-src=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-7.png\" alt=\"\" class=\"wp-image-247624 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-7.png 768w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-7-700x56.png 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2026\/06\/Transformers-Financial-Time-Series-7-300x24.png 300w\" data-sizes=\"(max-width: 768px) 100vw, 768px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 768px; aspect-ratio: 768\/61;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">So Q, K, V are just different time series that are transformed versions of X<sub>input<\/sub>, each a projection to spaces with different dimensions. We find this not particularly mathematically rigorous. But hey, this is engineering, not science, and the final judge is whether it works. Also, there are alternatives to sinusoidal positional encoding. Just ask ChatGPT!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once we have these Q, K, and V, the rest are standard transformer stuff, whether this is a time series or a sequence of words, and the output is a context matrix Z of dimension 12 \u00d7 64 in our case (the same dimension as X<sub>input<\/sub>). Each row of Z still represents a different lagged set of mixed features.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For ease of downstream processing, AlphaPortfolio flatten the Z matrix into a feature vector with dimension 768 \u00d7 1, which they simply call r (not to be confused with the raw returns R(t)).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As usual, you can use these transformed features downstream for supervised or reinforcement learning as you like. In the next blog post, we will talk about what happens when we have more than 1 stock we want to use as input.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, we will discuss how traders can incorporate different feature series from this stock while adding a sense of time.<\/p>\n","protected":false},"author":591,"featured_media":231564,"comment_status":"open","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[339,338,341],"tags":[2105,21159,9839,21813,4921,21812],"contributors-categories":[13719],"class_list":["post-246995","post","type-post","status-publish","format-standard","has-post-thumbnail","category-data-science","category-ibkr-quant-news","category-quant-development","tag-deep-learning","tag-feature-engineering","tag-financial-time-series","tag-positional-encoding","tag-quantitative-finance","tag-transformers","contributors-categories-predictnow-ai"],"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 v28.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Applying Transformers to Financial Time Series | IBKR Quant<\/title>\n<meta name=\"description\" content=\"In this post, we will discuss how traders can incorporate different feature series from this stock while adding a sense of time.\" \/>\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\/246995\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Applying Transformers to Financial Time Series\" \/>\n<meta property=\"og:description\" content=\"In this post, we will discuss how traders can incorporate different feature series from this stock while adding a sense of time.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/applying-transformers-to-financial-time-series\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2026-06-25T15:40:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-25T15:43:06+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/10\/abstract-network-random-programming-code-web.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=\"Dr. Ernest P. Chan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/chanep\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr. Ernest P. Chan\" \/>\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:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/applying-transformers-to-financial-time-series\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/applying-transformers-to-financial-time-series\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Dr. Ernest P. Chan\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/083811702bfaecd417618d515f0e6463\"\n\t            },\n\t            \"headline\": \"Applying Transformers to Financial Time Series\",\n\t            \"datePublished\": \"2026-06-25T15:40:41+00:00\",\n\t            \"dateModified\": \"2026-06-25T15:43:06+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/applying-transformers-to-financial-time-series\\\/\"\n\t            },\n\t            \"wordCount\": 900,\n\t            \"commentCount\": 0,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/applying-transformers-to-financial-time-series\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2025\\\/10\\\/abstract-network-random-programming-code-web.jpg\",\n\t            \"keywords\": [\n\t                \"Deep Learning\",\n\t                \"Feature engineering\",\n\t                \"Financial Time Series\",\n\t                \"positional encoding\",\n\t                \"Quantitative Finance\",\n\t                \"transformers\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"Data Science\",\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:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/applying-transformers-to-financial-time-series\\\/#respond\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/applying-transformers-to-financial-time-series\\\/\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/applying-transformers-to-financial-time-series\\\/\",\n\t            \"name\": \"Applying Transformers to Financial Time Series | IBKR Campus US\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/applying-transformers-to-financial-time-series\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/applying-transformers-to-financial-time-series\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2025\\\/10\\\/abstract-network-random-programming-code-web.jpg\",\n\t            \"datePublished\": \"2026-06-25T15:40:41+00:00\",\n\t            \"dateModified\": \"2026-06-25T15:43:06+00:00\",\n\t            \"description\": \"In this post, we will discuss how traders can incorporate different feature series from this stock while adding a sense of time.\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/applying-transformers-to-financial-time-series\\\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/ibkr-quant-news\\\/applying-transformers-to-financial-time-series\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2025\\\/10\\\/abstract-network-random-programming-code-web.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2025\\\/10\\\/abstract-network-random-programming-code-web.jpg\",\n\t            \"width\": 1000,\n\t            \"height\": 563,\n\t            \"caption\": \"Quant programming code\"\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\\\/083811702bfaecd417618d515f0e6463\",\n\t            \"name\": \"Dr. Ernest P. Chan\",\n\t            \"description\": \"Ernie is a noted quantitative hedge fund manager and quant finance author. Previously he has applied his expertise in machine learning at IBM T.J. Watson Research Center\u2019s Human Language Technologies group, at Morgan Stanley\u2019s Data Mining and Artificial Intelligence Group, and at Credit Suisse\u2019s Horizon Trading Group. His papers and talks can be found at www.predictnow.ai\\\/financial-machine-learning\\\/.\",\n\t            \"sameAs\": [\n\t                \"https:\\\/\\\/www.predictnow.ai\\\/about-us\\\/\",\n\t                \"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/chanep\"\n\t            ],\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/ernestchan\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Applying Transformers to Financial Time Series | IBKR Quant","description":"In this post, we will discuss how traders can incorporate different feature series from this stock while adding a sense of time.","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\/246995\/","og_locale":"en_US","og_type":"article","og_title":"Applying Transformers to Financial Time Series","og_description":"In this post, we will discuss how traders can incorporate different feature series from this stock while adding a sense of time.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/applying-transformers-to-financial-time-series\/","og_site_name":"IBKR Campus US","article_published_time":"2026-06-25T15:40:41+00:00","article_modified_time":"2026-06-25T15:43:06+00:00","og_image":[{"width":1000,"height":563,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/10\/abstract-network-random-programming-code-web.jpg","type":"image\/jpeg"}],"author":"Dr. Ernest P. Chan","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/chanep","twitter_misc":{"Written by":"Dr. Ernest P. Chan","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/applying-transformers-to-financial-time-series\/#article","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/applying-transformers-to-financial-time-series\/"},"author":{"name":"Dr. Ernest P. Chan","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/083811702bfaecd417618d515f0e6463"},"headline":"Applying Transformers to Financial Time Series","datePublished":"2026-06-25T15:40:41+00:00","dateModified":"2026-06-25T15:43:06+00:00","mainEntityOfPage":{"@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/applying-transformers-to-financial-time-series\/"},"wordCount":900,"commentCount":0,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/applying-transformers-to-financial-time-series\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/10\/abstract-network-random-programming-code-web.jpg","keywords":["Deep Learning","Feature engineering","Financial Time Series","positional encoding","Quantitative Finance","transformers"],"articleSection":["Data Science","Quant","Quant Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/applying-transformers-to-financial-time-series\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/applying-transformers-to-financial-time-series\/","url":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/applying-transformers-to-financial-time-series\/","name":"Applying Transformers to Financial Time Series | IBKR Campus US","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/applying-transformers-to-financial-time-series\/#primaryimage"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/applying-transformers-to-financial-time-series\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/10\/abstract-network-random-programming-code-web.jpg","datePublished":"2026-06-25T15:40:41+00:00","dateModified":"2026-06-25T15:43:06+00:00","description":"In this post, we will discuss how traders can incorporate different feature series from this stock while adding a sense of time.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/applying-transformers-to-financial-time-series\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/ibkr-quant-news\/applying-transformers-to-financial-time-series\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/10\/abstract-network-random-programming-code-web.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/10\/abstract-network-random-programming-code-web.jpg","width":1000,"height":563,"caption":"Quant programming code"},{"@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\/083811702bfaecd417618d515f0e6463","name":"Dr. Ernest P. Chan","description":"Ernie is a noted quantitative hedge fund manager and quant finance author. Previously he has applied his expertise in machine learning at IBM T.J. Watson Research Center\u2019s Human Language Technologies group, at Morgan Stanley\u2019s Data Mining and Artificial Intelligence Group, and at Credit Suisse\u2019s Horizon Trading Group. His papers and talks can be found at www.predictnow.ai\/financial-machine-learning\/.","sameAs":["https:\/\/www.predictnow.ai\/about-us\/","https:\/\/x.com\/https:\/\/twitter.com\/chanep"],"url":"https:\/\/www.interactivebrokers.com\/campus\/author\/ernestchan\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2025\/10\/abstract-network-random-programming-code-web.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/246995","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\/591"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=246995"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/246995\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/231564"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=246995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=246995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=246995"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=246995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}