<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Amir M. Janjan on Medium]]></title>
        <description><![CDATA[Stories by Amir M. Janjan on Medium]]></description>
        <link>https://medium.com/@a.m.x.janjan?source=rss-34311d6971f5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2IXH8B3AdhjgTvyuz3Zo8g.jpeg</url>
            <title>Stories by Amir M. Janjan on Medium</title>
            <link>https://medium.com/@a.m.x.janjan?source=rss-34311d6971f5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 21:58:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@a.m.x.janjan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What Actually Predicts Stock Returns? A Quantamental Guide to Fundamental Factors]]></title>
            <link>https://medium.com/@a.m.x.janjan/what-actually-predicts-stock-returns-a-quantamental-guide-to-fundamental-factors-0a26e52163c2?source=rss-34311d6971f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/0a26e52163c2</guid>
            <category><![CDATA[quantitative-finance]]></category>
            <category><![CDATA[quantamental]]></category>
            <category><![CDATA[fundamental-analysis]]></category>
            <category><![CDATA[finance]]></category>
            <dc:creator><![CDATA[Amir M. Janjan]]></dc:creator>
            <pubDate>Sun, 24 May 2026 21:45:48 GMT</pubDate>
            <atom:updated>2026-05-24T21:47:08.808Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How classic financial analysis meets modern data science — and what the evidence says.</em></p><p>If you’ve spent any time in finance, you’ve heard the usual wisdom: buy cheap stocks, buy quality companies, buy dividend payers. But how strong is the actual evidence behind these ideas? And how do you go from a gut feeling about “value” to a systematic, testable investment process?</p><p>That’s the promise of <strong>quantamental investing</strong> — blending the rigor of quant models with the insight of fundamental analysis. This piece covers two interconnected ideas: the empirical track record of fundamental factors, and the newer research pushing the field forward.</p><h3>Part 1: The Four Pillars of Fundamental Factor Investing</h3><p>MSCI, one of the major investment research firms, classifies factors into six broad categories. Four of them are tightly linked to fundamental data:</p><p>Category What It Measures Key Variables <strong>Value</strong> Cheapness relative to fundamentals Book-to-price, earnings-to-price, cash flow <strong>Size</strong> Market capitalization Full market cap, free-float cap <strong>High Yield</strong> Dividend income Dividend yield <strong>Quality</strong> Financial health ROE, ROA, leverage, earnings consistency</p><p>One important nuance on <strong>Value</strong>: it’s not a single thing. “Cheap” can mean cheap relative to book value, earnings, sales, or cash flow — and each gives a slightly different picture. A stock that looks cheap on one metric can look expensive on another.</p><h3>The Empirical Track Record</h3><p>Below is a summary of academic findings on US stocks, measured by t-statistic — a gauge of statistical reliability. A t-stat above 2.0 is considered significant; above 3.0 is very strong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*FVXI26w47MeCm8OwOWg9-g.png" /></figure><p>These aren’t cherry-picked results — they span decades of data across multiple researchers. The <strong>Enterprise Multiple</strong> (value) and <strong>Return on Assets</strong> (quality) stand out with the highest t-stats, suggesting the most reliable excess returns historically.</p><h3>A Word of Caution</h3><p>Past factors don’t always survive. The well-documented <strong>factor zoo</strong> problem — hundreds of published factors, many of which disappear after publication — is real. But fundamental factors tend to be more durable because they’re rooted in economic logic, not just statistical patterns. There’s a reason why “buy profitable companies at reasonable prices” has never gone out of style.</p><p>For those who want to dig deeper, <a href="https://www.openassetpricing.com/">Open Asset Pricing</a> (Chen &amp; Zimmermann, 2022) is an excellent open-source repository that replicates thousands of factors across datasets and time periods. Before betting on any factor, it’s worth checking whether it holds up there.</p><h3>Part 2: Recent Advances — What’s at the Frontier?</h3><p>The foundational factors above are well-established. But research hasn’t stood still. Here are six more recent developments that a quantamental investor should know.</p><h3>1. Measuring Mispricing Directly</h3><p>The whole point of fundamental analysis is to find stocks where price has deviated from fair value. Recent research has made this more systematic.</p><p><strong>Composite Mispricing Score</strong> (Stambaugh, Yu &amp; Yuan, 2015): Combine 11 well-known return anomalies — financial distress, accruals, momentum, gross profitability, asset growth, and others — into a single rank. Average the ranks across all anomalies. Stocks with the highest composite rank are the most overpriced. This simple average has been shown to predict future returns.</p><p><strong>Altman Z-Score</strong> (1968): A bankruptcy predictor that doubles as a value signal:</p><blockquote><em>Z = 1.2(Working Capital/Assets) + 1.4(Retained Earnings/Assets) + 3.3(EBIT/Assets) + 0.6(Equity/Liabilities) + 1.0(Sales/Assets)</em></blockquote><ul><li>Z &gt; 2.99: Safe zone</li><li>1.81–2.99: Gray area</li><li>Z &lt; 1.81: Distress zone</li></ul><p><strong>Piotroski F-Score</strong> (2000): Nine binary criteria (0 or 1 point each) across profitability, leverage, and operating efficiency. High scorers (8–9) outperformed low scorers (0–2) by over <strong>23% annually</strong> (t-stat: 5.59).</p><p><strong>Agnostic Fundamental Analysis</strong> (Bartram &amp; Grinblatt, 2018): Rather than using predetermined rules, run monthly cross-sectional regressions of market cap on <em>all</em> accounting items. The residual tells you if a stock is under- or overpriced relative to what fundamentals would predict. The spread between the most and least underpriced quintiles earned <strong>0.42% per month</strong> (~5% annualized, t-stat: 2.38).</p><p>The quantamental takeaway: mispricing isn’t a single number. Test multiple approaches and combine the strongest signals.</p><h3>2. Earnings Announcements as a Signal</h3><p>Stocks tend to rise around scheduled earnings announcement dates — not just because of the news, but because announcements reveal aggregate cash-flow information that the whole market processes.</p><p><strong>Savor &amp; Wilson (2016)</strong> showed this creates an <em>announcement risk premium</em>: stocks with high past announcement returns continue to earn high returns on future announcement dates.</p><p><strong>Akbas (2016)</strong> added a twist: unusually <em>low</em> trading volume in the week before an earnings announcement predicts more negative earnings surprises. The effect is stronger when short-selling is constrained.</p><p>Practical use: track earnings calendars and pre-announcement volume patterns as leading signals.</p><h3>3. Speculative Sentiment as a Timing Tool</h3><p><strong>Baker &amp; Wurgler (2006)</strong> built a sentiment index by combining six market proxies — closed-end fund discounts, NYSE turnover, IPO counts, first-day IPO returns, equity issuance share, and dividend premium — using principal component analysis.</p><p>The key finding from <strong>Stambaugh, Yu &amp; Yuan (2012)</strong>: sentiment mostly affects the <em>short leg</em> of anomaly strategies. When sentiment is high, overpriced stocks become even more overpriced before eventually crashing. The long leg (underpriced stocks) is relatively stable.</p><p>This means sentiment isn’t a factor on its own — it’s a <em>timing</em> tool. When sentiment is elevated, increase short exposure. When it’s depressed, pull back.</p><h3>4. Short Interest as an Informed Signal</h3><p>Short sellers aren’t just speculators — they’re often the most informed traders in the market.</p><p><strong>Engelberg, Reed &amp; Ringgenberg (2018)</strong> found that short-selling <em>risk</em> (the cost and difficulty of shorting) predicts future returns. A long/short portfolio based on this earns <strong>9.6% annual alpha</strong> against the Fama-French 5-factor model. Why? When shorting is expensive, mispricing persists longer — meaning the eventual correction is larger.</p><p><strong>Rapach, Ringgenberg &amp; Zhou (2016)</strong> showed short interest also predicts <em>aggregate</em> market returns, not just individual stocks.</p><p>Short interest data is public but not fully priced in. Combined with fundamental overvaluation signals, it can be a powerful factor.</p><h3>5. Economic Links Between Firms — Lead-Lag Effects</h3><p>When one company’s stock moves, economically connected companies tend to follow — but with a lag. This is exploitable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*yp1WaWyjoomVavry.jpe" /></figure><p>Five types of links have been documented, all with t-statistics above 4.5:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*Pli8dVx95KILBXuTpdtohQ.png" /></figure><p>The signal: if economically linked firms have done well recently, the focal firm tends to follow. This is a form of <em>fundamental momentum</em> — driven by information diffusion, not just price chasing.</p><h3>6. Cash Is King — Literally</h3><p>Traditional profitability measures like ROE and ROA mix cash earnings with accruals. Accruals are accounting adjustments — they don’t represent actual cash in hand, and they can be manipulated.</p><p><strong>Ball et al. (2016)</strong> showed that <em>cash-based</em> operating profitability outperforms accrual-based measures. The formula strips out non-cash items:</p><blockquote><em>Cash-based Profitability = Revenue − COGS − SG&amp;A − ΔReceivables − ΔInventory − ΔPrepaid Expenses</em></blockquote><ul><li>ΔDeferred Revenue + ΔPayables + ΔAccrued Expenses</li></ul><p>The logic: if a company books a sale but hasn’t collected the cash yet, that’s receivables — subtract it. If a supplier is owed money but hasn’t been paid, the company kept the cash — add it back.</p><p>A long/short portfolio based on this measure earned <strong>4.88% annualized</strong> (t-stat: 6.29) from 1963–2014. That’s a remarkably clean signal.</p><h3>A Note on Fund Flows (Proceed with Caution)</h3><p>One research area worth flagging: <strong>mutual fund flow measures</strong> as a factor.</p><p>The popular MFFlow measure (Edmans, Goldstein &amp; Jiang, 2012) was designed to capture forced selling by funds experiencing large outflows. But <strong>Wardlaw (2020)</strong> found a critical flaw: the measure is mechanically related to stock returns in the same quarter, making it appear predictive when it isn’t.</p><p>This is a useful reminder. Even peer-reviewed, published factors can have hidden flaws. Replication and out-of-sample testing aren’t optional — they’re essential.</p><h3>Putting It Together</h3><p>A sophisticated quantamental investor doesn’t pick one factor and stop there. The playbook looks more like:</p><ol><li><strong>Screen for mispricing</strong> using composite signals (F-score, Z-score, residuals)</li><li><strong>Filter by quality</strong> using cash-based profitability instead of raw ROE/ROA</li><li><strong>Add timing signals</strong> — sentiment for factor timing, volume for earnings plays</li><li><strong>Incorporate network effects</strong> — what are linked firms’ prices telling you?</li><li><strong>Use short interest</strong> as a confirmation signal on the short side</li><li><strong>Test everything out of sample</strong> before trusting it</li></ol><p>The factors covered here aren’t just academic curiosities. They have decades of empirical support, economic rationale, and increasingly accessible data behind them. The edge isn’t in knowing they exist — it’s in the rigor of how you combine and implement them.</p><p><em>This piece is based on academic research in quantitative finance, covering foundational and recent advances in fundamental factor investing.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0a26e52163c2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Actually Value a Company (And Why Quants Need to Know This Too)]]></title>
            <link>https://medium.com/@a.m.x.janjan/how-to-actually-value-a-company-and-why-quants-need-to-know-this-too-0358f2fe25fb?source=rss-34311d6971f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/0358f2fe25fb</guid>
            <category><![CDATA[quantitative-finance]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[fundamental-analysis]]></category>
            <dc:creator><![CDATA[Amir M. Janjan]]></dc:creator>
            <pubDate>Fri, 22 May 2026 20:32:54 GMT</pubDate>
            <atom:updated>2026-05-22T20:32:54.519Z</atom:updated>
            <content:encoded><![CDATA[<h3><em>A practical guide to fundamental valuation and the empirical factors that actually predict returns</em></h3><p>There’s a temptation in quantitative investing to skip the fundamentals. Why bother understanding DCF models when you can just feed earnings data into a gradient boosting model and let it figure things out?</p><p>The answer is that your model is only as good as your features. And if you don’t understand where those features come from — what they measure, why they matter, how they interact — you’re flying blind. You’ll overfit to noise and miss the economic signal hiding in plain sight.</p><p>So let’s build the foundation properly.</p><h3>The Two Pillars of Fundamental Valuation</h3><p>Traditional analysts use two main models to determine what a company is <em>actually</em> worth, as opposed to what the market says it’s worth today.</p><p><strong>Discounted Cash Flow (DCF)</strong> projects a company’s future cash flows and discounts them back to present value. The logic is straightforward: a dollar of earnings five years from now is worth less than a dollar today, and we need to account for that.</p><p><strong>The Residual Income Model</strong> works similarly but focuses on earnings <em>above</em> a required return on equity — the idea being that only returns exceeding the cost of capital actually create value for shareholders.</p><p>Both models require you to forecast a company’s performance, typically across a 15-year horizon. Which immediately raises a question: how do you forecast 15 years into the future without fooling yourself?</p><h3>The Three-Phase Growth Framework</h3><p>Analysts don’t try to predict 15 years uniformly. Instead, they break the forecast into phases, each with different assumptions about growth.</p><p><strong>Phase 1 (Years 1–5):</strong> Use the company’s actual recent growth rate. This phase reflects genuine confidence — you have data, the business is reasonably predictable, and near-term momentum tends to persist.</p><p><strong>Phase 2 (Years 6–15):</strong> Gradually dial back the growth assumptions. Competition increases. Markets mature. The advantages that drove early growth start to erode. This is where the model stress-tests the company’s <em>moat</em> — its ability to defend profit margins when the wolves start circling.</p><p><strong>Terminal Phase (Year 15+):</strong> Growth converges to GDP growth. This isn’t pessimism; it’s arithmetic. No company, no matter how exceptional, can permanently grow faster than the overall economy. At some point, everything reverts.</p><p>Where analysts disagree — and where most valuation debates actually happen — is in Phase 2. How quickly do margins erode? How durable is the competitive advantage? Get this right, and the valuation follows.</p><h3>The Key Drivers: What You’re Actually Forecasting</h3><p>Once you accept the three-phase framework, you need to know what to forecast. Four variables dominate:</p><p><strong>Sales Growth</strong> is the engine of everything. Without revenue growth, no amount of margin expansion or balance sheet optimization saves a company. It’s the starting point.</p><p><strong>Profit Margins</strong> come in layers, and each tells a different story:</p><ul><li><em>Gross margin</em> (revenue minus cost of goods sold) shows the basic economics of the product</li><li><em>Operating margin</em> captures R&amp;D and overhead — crucial because a company investing heavily in R&amp;D may look less profitable today but is building tomorrow’s revenue</li><li><em>Net margin</em> is the bottom line after interest and taxes</li></ul><p>The critical insight here is that margins aren’t static inputs — they’re trajectories. In years 1–5, you anchor them to recent actuals. In years 6–15, you model their decline as competition erodes the firm’s pricing power.</p><p><strong>Turnover Ratios</strong> (asset efficiency — how much revenue a dollar of assets generates) and <strong>Leverage Ratios</strong> (debt relative to equity or assets) round out the picture. Unlike margins, these tend to be treated as more stable, reflecting the structural characteristics of a business rather than its competitive position.</p><p>One crucial nuance on leverage: optimal debt levels vary enormously by industry. A bank or real estate firm with high leverage is often just doing its job. The same ratio at a tech startup might signal existential risk. Context is everything.</p><h3>The Economic Moat, Quantified</h3><p>Here’s where valuation gets philosophically interesting.</p><p>If a company’s profit margins decline slowly from year 6 to year 15, the DCF model assigns it a significantly higher value than if margins collapse quickly. This isn’t just a modeling artifact — it’s the formal representation of what Warren Buffett calls the economic moat.</p><p>Companies with genuine competitive advantages (patents, brand equity, network effects, regulatory barriers) can sustain margins for longer. Companies in commodity businesses with no pricing power see margins evaporate the moment a competitor shows up.</p><p>In a DCF model, “moat” isn’t a soft qualitative judgment — it’s literally a parameter that determines intrinsic value per share.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pMR2vCI4k38V-hGjq5lA9g.png" /></figure><h3>From Fundamental Inputs to Quantitative Factors</h3><p>Here’s where the bridge to quant investing gets interesting.</p><p>Every variable in a fundamental model — growth rates, margins, turnover, leverage — can be transformed into a quantitative factor. And researchers have spent decades testing whether these factors actually predict future returns.</p><p>MSCI, one of the major investment research firms, classifies equity factors into six categories. The four most grounded in fundamental data are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*oHSFszGugXmtqxTfRtaM-Q.png" /></figure><p>Each of these has been subjected to rigorous empirical testing. The results are striking.</p><h3>The Empirical Evidence: What Actually Works</h3><p>Academic researchers have spent decades testing whether fundamental factors predict returns. The statistical benchmark is a t-statistic: anything above 2.0 is considered significant, above 3.0 is considered strong evidence.</p><p>Here’s what the literature found:</p><p><strong>Value factors</strong> have some of the strongest empirical support in finance. The book-to-market ratio, studied by Fama and French across 1963–1990, produced a t-statistic of 5.71. The enterprise multiple — arguably a more complete measure of cheapness — hit 6.54 across a nearly 50-year sample (Loughran &amp; Wellman, 1963–2009). That’s not noise; that’s a structural phenomenon.</p><p><strong>Quality factors</strong> are equally compelling. Return on Assets, across a 30-year sample, produced a t-statistic of 6.45. Return on Equity came in at 4.50. Book leverage — essentially the balance sheet risk factor — hit 5.34.</p><p><strong>Size</strong> (smaller companies tend to outperform) and <strong>dividend yield</strong> both clear the 3.0 threshold convincingly.</p><p>The weakest factor in this group is earnings consistency, at 2.67 — still significant, but more fragile than the others.</p><p>What’s remarkable is that these aren’t cherry-picked results from short windows. Most of these studies span 30–50 years across multiple market cycles. The economic logic is also intuitive: cheap stocks are underpriced, high-quality companies generate durable returns, smaller firms have more room to grow. These aren’t data-mining artifacts; they’re grounded in how businesses actually work.</p><h3>The Caveat That Matters</h3><p>Before you start building a pure value-plus-quality portfolio, there’s an important warning: the “factor zoo.”</p><p>Researchers have published hundreds of factors. Many lose their predictive power once they’re widely known — because investors arbitrage them away, or because they were never real to begin with. The chapter I’m drawing from is explicit about this risk.</p><p>Fundamental factors are more resilient than most because they’re anchored in economic logic. But they’re not immune. The enterprise multiple is well-known. ROA is widely tracked. You can’t expect 1963-era alpha from factors that every quant fund is already using.</p><p>The intelligent approach is threefold:</p><ol><li><strong>Combine factors</strong> rather than relying on any single signal. A composite of value + quality tends to be more stable than either alone.</li><li><strong>Test out-of-sample</strong> — rigorously, not just on the same data that generated the t-statistics above.</li><li><strong>Look for interactions.</strong> High ROE is generally good. High ROE with high leverage might be dangerous. Machine learning can identify these non-linear relationships that linear factor models miss.</li></ol><h3>A Resource Worth Bookmarking</h3><p>One of the most useful things the source material points to is the Open Asset Pricing Project at <a href="https://www.openassetpricing.com/">openassetpricing.com</a>, initiated by Chen &amp; Zimmermann in 2022. It’s an open-source repository that replicates thousands of published factors and lets you see which ones hold up across different datasets and time periods.</p><p>If you’re building a quantamental strategy, this is where you start — not with a single study, but with a systematic view of what survives replication.</p><h3>The Bottom Line</h3><p>Fundamental valuation and quantitative factor investing aren’t in conflict. They’re two lenses on the same underlying reality: what makes a business valuable, and can that value be measured systematically?</p><p>The DCF framework tells you <em>how</em> to think about value — in terms of growth, margins, moat, and duration of competitive advantage. The empirical factor literature tells you <em>which</em> of those dimensions have historically predicted returns with statistical confidence.</p><p>A quantamental investor combines both. They understand the economic logic well enough to build sensible features, and they have the empirical rigor to test whether those features actually work — and to know when they’ve stopped working.</p><p>That combination is rarer than it should be. Which is probably why it still works.</p><p><em>This piece draws from academic research in fundamental analysis and empirical asset pricing, including work by Fama &amp; French, Basu, Loughran &amp; Wellman, and others cited throughout.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0358f2fe25fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When Wall Street’s Two Tribes Finally Made Peace: The Rise of Quantamental Investing]]></title>
            <link>https://medium.com/@a.m.x.janjan/when-wall-streets-two-tribes-finally-made-peace-the-rise-of-quantamental-investing-cb2d419a2908?source=rss-34311d6971f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb2d419a2908</guid>
            <category><![CDATA[quantitative-finance]]></category>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[fundamental-analysis]]></category>
            <category><![CDATA[quantamental]]></category>
            <dc:creator><![CDATA[Amir M. Janjan]]></dc:creator>
            <pubDate>Thu, 21 May 2026 09:59:37 GMT</pubDate>
            <atom:updated>2026-05-21T09:59:37.494Z</atom:updated>
            <content:encoded><![CDATA[<p>For decades, two distinct tribes ruled the investment world — and they didn’t much like each other.</p><p>On one side: the <strong>fundamentalists</strong>. Old-school disciples of Benjamin Graham and David Dodd, poring over balance sheets, studying management teams, and searching for companies whose true worth the market had yet to recognize. Patient, conviction-driven, deeply human in their reasoning.</p><p>On the other: the <strong>quants</strong>. Children of the computer age, wielding mathematical models and statistical algorithms to find patterns invisible to the naked eye. Systematic, scalable, and deliberately indifferent to the stories behind the numbers.</p><p>Then 2008 happened — and both tribes got humbled.</p><h3>The Crisis That Changed Everything</h3><p>The 2008 financial crisis didn’t just destroy wealth. It exposed the blind spots baked into each approach.</p><p>Fundamentalists, relying on quarterly reports and long-term theses, were too slow. By the time their analysis caught up to what was happening in credit markets, the damage was done. Quants fared no better: their models, trained on historical data, had never seen a crisis of this magnitude. When the past stops predicting the future, a purely rules-based system has nowhere to turn.</p><p>The lesson was hard and clear: neither approach, alone, was enough.</p><p>Out of that wreckage came a new idea — one that the industry would eventually call <strong>quantamental investing</strong>.</p><h3>The Best of Both Worlds</h3><p>The logic is deceptively simple:</p><blockquote><strong><em>Quantamental Investing = the depth and insight of fundamental analysis + the precision and scale of quantitative methods.</em></strong></blockquote><p>Rather than choosing between the two, quantamental managers combine them. Quantitative tools — machine learning, big data, natural language processing — process vast amounts of fundamental data faster and at greater scale than any human analyst could. Meanwhile, fundamental insight shapes <em>which</em> questions the models are designed to answer, and catches the qualitative risks that no algorithm will ever fully capture.</p><p>The result is an investment process that is simultaneously more rigorous and more adaptive. Better timing. Better risk management. And, in theory, better returns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jGSQuMPEOu0kw4Rl.jpg" /></figure><h3>How It Actually Works</h3><p>In practice, a quantamental portfolio is built through a layered process:</p><p><strong>1. Start with fundamentals.</strong> Traditional valuation metrics — price-to-earnings ratios, cash flow analysis, balance sheet strength — form the foundation. A thesis is built around a company’s actual value.</p><p><strong>2. Test it with data.</strong> Advanced analytics and machine learning then validate (or challenge) that thesis. Can satellite imagery of store parking lots confirm that foot traffic is recovering? Does social media sentiment suggest the market is overreacting to bad news? The quant layer stress-tests the fundamental story.</p><p><strong>3. Manage dynamically.</strong> Unlike a static buy-and-hold portfolio, quantamental strategies adjust in real time. Quantitative signals continuously refine the risk-return balance, while the fundamental thesis acts as a guardrail against chasing noise.</p><p>The outcome: a portfolio that thinks like an analyst but reacts like a machine.</p><h3>Four Ways It Plays Out in the Real World</h3><p><strong>Enhancing value investing.</strong> A classic value manager buys stocks with low P/E ratios. A quantamental manager does the same — but also runs sentiment analysis on news and social media. If a fundamentally sound company is being hammered by temporary negative press, that’s not a warning sign. It’s a buying opportunity. Better timing, same conviction.</p><p><strong>Risk management during crises.</strong> In 2008, a quantamental approach combining fundamental analysis with real-time signals — credit default swap spreads, market liquidity measures — could have flagged the deterioration in financial stocks weeks earlier. The result: smaller losses, more resilient portfolios.</p><p><strong>Smarter ESG investing.</strong> Traditional ESG funds simply exclude “bad” companies. A quantamental ESG strategy uses natural language processing to score companies dynamically, reading thousands of reports and news articles in real time. It finds ESG leaders that are both principled <em>and</em> financially strong — not just the ones that make an easy exclusion list.</p><p><strong>Sector rotation.</strong> Moving money between sectors based on economic cycles is nothing new. But feeding machine learning models with consumer sentiment data, inventory levels, and logistics signals takes it further. Early in the COVID-19 pandemic, such an approach might have identified the tech sector’s resilience — and the shift to remote work and e-commerce — before the broader market caught on.</p><h3>The Firms That Proved It Works</h3><h3>Bridgewater Associates</h3><p>Ray Dalio built Bridgewater on what he calls “principled decision-making” — a deep, almost philosophical understanding of how the economic machine works. Monetary policy, macroeconomic cycles, long-term market relationships: all of it distilled into a set of timeless principles.</p><p>But Bridgewater doesn’t stop at theory. Sophisticated statistical tools and algorithms process vast data sets, test ideas against history, and systematically manage risk. The <strong>Pure Alpha Fund</strong> goes long and short across 150+ markets — debt, equities, currencies, commodities — guided by macroeconomic insight. The <strong>All Weather Fund</strong> takes a “risk parity” approach, balancing the portfolio by volatility rather than dollar allocation — a concept that requires both fundamental understanding and quantitative precision to execute.</p><p>Deep economic theory, systematically applied. That’s Bridgewater in a sentence.</p><h3>D.E. Shaw</h3><p>D.E. Shaw started life as a pure quant shop: mathematical models, computational algorithms, statistical arbitrage. But over time it evolved into something more interesting.</p><p>Today, D.E. Shaw runs fundamental analysts alongside its quant teams — people who examine company financials, assess management quality, and evaluate industry dynamics. The two sides don’t just coexist; they collaborate. A quantitative forecast might miss an anomalous event that an analyst has flagged. A fundamental thesis might need quantitative validation before capital is deployed. Risk models optimize across measurable factors; human judgment handles the geopolitical and regulatory risks no model can price.</p><p>The result is a firm that runs everything from algorithmic trading to global macro — all informed by the same hybrid philosophy.</p><h3>The Bigger Picture</h3><p>What Bridgewater and D.E. Shaw reveal is that the quant-versus-fundamental debate was always a false choice. The most sophisticated investors stopped choosing sides a long time ago.</p><p>The quantamental approach doesn’t mean trusting algorithms blindly, nor does it mean ignoring what the data is saying. It means building teams — financial analysts, data scientists, programmers, risk managers — who work together toward a single goal: understanding markets better than anyone else.</p><p>Each person’s expertise informs a whole that is greater than the sum of its parts.</p><p>In a world drowning in data, the edge no longer belongs to those who have the most information. It belongs to those who know how to think about it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb2d419a2908" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Reading the Balance Sheet Like a Quant]]></title>
            <link>https://medium.com/@a.m.x.janjan/reading-the-balance-sheet-like-a-quant-edfeca70eb45?source=rss-34311d6971f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/edfeca70eb45</guid>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[quantitative-finance]]></category>
            <dc:creator><![CDATA[Amir M. Janjan]]></dc:creator>
            <pubDate>Wed, 20 May 2026 18:51:00 GMT</pubDate>
            <atom:updated>2026-05-20T18:51:00.201Z</atom:updated>
            <content:encoded><![CDATA[<p>Most people think of quantitative trading as pure price analysis — algorithms scanning charts, detecting patterns in milliseconds. That’s one world.</p><p>There’s another world, slower and less glamorous, where the signals come from a company’s financial statements. Where the edge isn’t in order flow or price momentum, but in understanding what a balance sheet is actually saying — and whether the market has figured it out yet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DqYfGQInH_TkOMCI.jpg" /></figure><p>This is <strong>fundamental alpha</strong>. And it’s where some of the most durable signals in quant finance live.</p><h3>The core idea</h3><p>Every public company must publish three financial documents quarterly:</p><ul><li>The <strong>balance sheet</strong> — a snapshot of what the company owns and owes</li><li>The <strong>income statement</strong> — revenue, costs, and profit over a period</li><li>The <strong>cash flow statement</strong> — actual cash moving in and out</li></ul><p>The fundamental alpha hypothesis is simple: <em>markets are slow to correctly price the information in these documents.</em></p><p>That delay is the opportunity.</p><h3>What quants actually look for</h3><p>Fundamental researchers aren’t reading these documents like analysts. They’re engineering features — extracting variables that can be ranked across thousands of stocks.</p><p>A few examples:</p><p><strong>From the balance sheet:</strong></p><ul><li>Debt-to-equity ratio (is the company over-leveraged?)</li><li>Current ratio (can they pay short-term obligations?)</li><li>Inventory growth (are goods piling up unsold?)</li><li>Accounts receivable growth (are customers not paying?)</li></ul><p><strong>From the income statement:</strong></p><ul><li>Operating profitability (how efficient is the core business?)</li><li>R&amp;D expense trends (are they investing in future growth or cutting?)</li></ul><p><strong>From the cash flow statement:</strong></p><ul><li>Cash from operations (is the business generating real cash?)</li><li>Cash from investing (are they spending on growth or liquidating assets?)</li></ul><p>None of these numbers means much in isolation. What matters is how they <em>change</em>, and how they <em>compare</em> across similar companies at the same point in time.</p><p>A rising debt ratio at one company is noise. A rising debt ratio that ranks in the top 10% of all companies in the sector — while earnings appear healthy — is a signal worth investigating.</p><h3>The most important concept: cash vs. accruals</h3><p>This is where it gets interesting.</p><p>Company earnings are not the same as company cash. Accounting rules allow companies to recognize revenue before cash is received and defer expenses to later periods. The gap between reported earnings and actual cash flow is called <strong>accruals</strong>.</p><p>A landmark academic paper by Richard Sloan proved something remarkable: companies with high accruals — meaning their earnings are inflated by accounting entries rather than real cash — have significantly worse future returns than companies whose earnings are backed by actual cash flow.</p><p>In other words: the market is systematically fooled by accounting earnings.</p><p>It takes time for the truth to surface. But it does surface.</p><p>This creates a classic alpha:</p><ul><li>High accruals, low cash-flow backing → <strong>short</strong> (overpriced, disappointment coming)</li><li>Low accruals, high cash-flow backing → <strong>long</strong> (underpriced, reality will catch up)</li></ul><p>This is called the accrual anomaly, and versions of it are used in real quantitative funds today.</p><h3>Valuation ratios as features</h3><p>Beyond cash flow analysis, fundamental quants use valuation ratios to classify stocks:</p><ul><li><strong>P/E</strong> (price-to-earnings)</li><li><strong>P/B</strong> (price-to-book)</li><li><strong>P/S</strong> (price-to-sales)</li><li><strong>Dividend yield</strong></li></ul><p>These ratios don’t predict direction by themselves. But they create useful groupings. Value stocks (low P/E, high dividend yield) and growth stocks (high P/E, rapid expansion) behave differently in different market environments. Understanding which group a stock belongs to helps you build better-calibrated models.</p><h3>Where it gets advanced: hidden signals</h3><p>Here’s something most people overlook.</p><p>Companies bury important information in footnotes. A change in accounting methodology. A new lawsuit. Long-term commitments that don’t appear on the main balance sheet. Executive compensation structures.</p><p>When a company’s footnote section suddenly gets longer, or vaguer, or introduces new disclosures that weren’t there last quarter — that’s often a sign that something uncomfortable is being disclosed as quietly as possible.</p><p>Processing footnotes at scale requires natural language processing. This is an active area of alpha research: training models to read the fine print across thousands of quarterly filings and flag anomalies.</p><h3>Earnings calls as alpha</h3><p>Every quarter, the CEO and CFO of every public company get on a call with analysts and discuss results. These calls are recorded and transcribed.</p><p>Research has shown that the <em>tone</em> of these calls predicts earnings surprises for the next 60 days. Not just what is said — but how it’s said. Hesitation in the Q&amp;A. Vague answers to specific questions. A CFO who sounds stressed when asked about margins.</p><p>This is text alpha. The signal isn’t in the numbers — it’s in the language.</p><h3>The slow alpha trade-off</h3><p>Fundamental alphas have a different profile than price-based signals:</p><ul><li><strong>Lower turnover.</strong> You’re not rebalancing every day. Positions hold for weeks or months.</li><li><strong>Returns cluster around earnings announcements.</strong> The market reprices fundamentals when new information is released.</li><li><strong>Signals decay over about a year.</strong> After roughly four quarters, the information is well-absorbed into prices.</li></ul><p>This means lower transaction costs, but also slower feedback. You don’t know immediately whether your signal is working.</p><h3>Putting it together</h3><p>The full pipeline looks like this:</p><pre>Financial statements<br>    ↓<br>Extract ratios, growth rates, red flags<br>    ↓<br>Separate real cash earnings from accounting accruals<br>    ↓<br>Rank stocks relative to peers<br>    ↓<br>Build long/short portfolio<br>    ↓<br>Hold until next earnings cycle</pre><p>This is how systematic fundamental funds work. Not stock-picking — systematic ranking across hundreds or thousands of names, rebalancing on a schedule, with clear rules about what constitutes a signal and what constitutes noise.</p><h3>Why this still works</h3><p>The accrual anomaly has been known since the 1990s. If it’s published, why hasn’t it been arbitraged away?</p><p>A few reasons. First, exploiting it requires shorting stocks — expensive, sometimes impossible at scale. Second, the signal is noisy enough that single-stock risk is high; you need a large, diversified portfolio to express it reliably. Third, markets keep generating new accrual distortions — it’s not a static pattern but an ongoing feature of how companies are incentivized to report.</p><p>The signal persists because the underlying cause persists: humans managing public companies have incentives to make their numbers look good in the short term. Accounting allows them to do this, within limits. Quants are on the other side of that trade.</p><h3>The bigger picture</h3><p>Across all three parts of this series, a consistent theme emerges.</p><p>Alpha research is not about finding a magic formula and printing money forever. It’s a disciplined, continuous process of:</p><ol><li>Forming hypotheses grounded in real market behavior</li><li>Testing them rigorously against data — while defending against overfitting</li><li>Deploying signals that survive scrutiny</li><li>Watching them decay as conditions change</li><li>Replacing them with new ideas</li></ol><p>The quants who succeed aren’t the ones who find the best signal. They’re the ones who maintain the best research process.</p><p>That’s the real edge.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=edfeca70eb45" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Backtest Trap: Why Great Historical Performance Means Almost Nothing]]></title>
            <link>https://medium.com/@a.m.x.janjan/the-backtest-trap-why-great-historical-performance-means-almost-nothing-889a6f6c086f?source=rss-34311d6971f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/889a6f6c086f</guid>
            <category><![CDATA[quantitative-finance]]></category>
            <category><![CDATA[finance]]></category>
            <dc:creator><![CDATA[Amir M. Janjan]]></dc:creator>
            <pubDate>Tue, 19 May 2026 16:35:02 GMT</pubDate>
            <atom:updated>2026-05-19T16:35:02.323Z</atom:updated>
            <content:encoded><![CDATA[<p>Here’s a story every quant researcher knows.</p><p>You spend a week building a model. You run it against five years of historical data. The returns look incredible — a Sharpe ratio above 2, minimal drawdowns, consistent profits across sectors. You’re excited.</p><p>Then you deploy it. And it bleeds money from day one.</p><p>This is the most common failure mode in quantitative finance. And it has a name: <strong>overfitting</strong>.</p><h3>What backtesting actually is</h3><p>A backtest simulates how your model would have performed if you’d run it in the past. You take historical price data, apply your formula, and measure the results.</p><p>The underlying assumption is seductive: <em>if it worked before, it should work again.</em></p><p>That assumption is often wrong. Here’s why.</p><h3>The four traps</h3><p><strong>Trap 1: The market changes.</strong> The rules of the game shift. Regulations evolve. New participants enter. Technology transforms execution. A pattern that exploited the behavior of 1990s retail investors may be meaningless in a market dominated by algorithmic traders.</p><p><strong>Trap 2: Your simulation isn’t realistic.</strong> Real trading costs money. Every time you buy or sell, you pay a spread, sometimes a commission, and you move the market slightly against yourself. A strategy with a 0.1% edge per trade can be wiped out by a 0.15% transaction cost. Backtests that ignore this are fantasy.</p><p><strong>Trap 3: Forward-looking bias.</strong> Did you use information that wasn’t available at the time? This is easier to do than you think. Survivorship bias — testing only on companies that still exist today — is a classic example. Companies that went bankrupt in 2005 are conveniently absent from a dataset you pulled in 2024.</p><p><strong>Trap 4: Overfitting.</strong> This is the big one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZEWl9qALpKu9sM8d.png" /></figure><h3>Overfitting, explained simply</h3><p>Imagine you flip a coin 20 times and get heads 13 times. You test the hypothesis: “This coin lands heads 65% of the time.” In your sample, the rule fits perfectly.</p><p>Now flip it another 20 times.</p><p>The underlying reality — 50/50 — hasn’t changed. You were fitting noise.</p><p>Financial markets are an extreme version of this problem. They’re noisy, non-stationary, and full of spurious correlations. If you test enough rules on historical data, you <em>will</em> find ones that look brilliant — purely by chance.</p><p>A researcher who tries seven different strategy configurations on a two-year dataset is statistically likely to find at least one with a Sharpe ratio above 1 — even if every single strategy is random noise.</p><p>The more configurations you try, the more likely you are to mistake luck for skill.</p><h3>Correlation can fool you too</h3><p>Here’s a subtler version of the same problem.</p><p>Suppose you have 1,000 random data series — pure noise, no signal. You build a new random series and ask: “What’s the maximum correlation between my new series and any of the 1,000?”</p><p>The answer is surprisingly high. Maybe 0.2, maybe more. By chance alone.</p><p>Now imagine testing your alpha against 1,000 past market patterns. Finding a 0.2 correlation sounds like discovery. It isn’t.</p><h3>How to defend against overfitting</h3><p><strong>Out-of-sample testing — done properly.</strong> This means you develop your model using one block of data, then test it on a completely separate block you’ve never touched. Not a random split. A <em>temporal</em> split — train on older data, test on newer data that wasn’t visible during development.</p><p>Why does the split direction matter? Because financial data has memory. Patterns in recent history influenced patterns in older history. If you train on 2020–2024 and test on 2015–2019, your test isn’t truly out-of-sample.</p><p><strong>Increase the bar.</strong> Require a longer backtest history. Require performance across multiple geographies. Require the signal to survive in different stock universes. Each additional requirement filters out more flukes.</p><p><strong>Count your trials.</strong> If you tested 50 variations before settling on the one that looked good, that changes the statistical interpretation entirely. A Sharpe of 1.5 from one clean idea is very different from a Sharpe of 1.5 found after 50 attempts. The latter is almost certainly noise.</p><p><strong>Keep the model simple.</strong> Every parameter you add is another degree of freedom — another dial you can turn to make historical performance look better. More parameters = more fitting = less generalization. The model with three parameters that explains the data reasonably well is more trustworthy than the model with fifteen parameters that explains it perfectly.</p><h3>The elegance test</h3><p>There’s a practical heuristic that experienced quant researchers use: <em>can you tell the story?</em></p><p>A real alpha has a mechanism. Someone has to be on the other side of your trade, and there has to be a reason they’re making a mistake. Maybe they’re slow to process public information. Maybe they’re forced to sell due to index rebalancing. Maybe they’re responding to short-term noise rather than long-term value.</p><p>If you can’t explain why your alpha should work — if the only evidence is that it did work historically — that’s a red flag.</p><p>Compare:</p><ul><li>“I go long stocks that fell more than 5% on no news because institutional investors systematically overreact to volatility.” ← has a story</li><li>“I go long when the 13-day moving average crosses the 47-day moving average on a Tuesday.” ← no story</li></ul><p>The second one might have great backtested performance. It almost certainly won’t survive out-of-sample.</p><h3>The uncomfortable truth</h3><p>Even with all these safeguards, you will still sometimes be wrong. Markets are complex enough that no testing framework eliminates false discoveries entirely.</p><p>What good backtesting discipline gives you is a better signal-to-noise ratio in your research pipeline. Fewer fake alphas make it through. More real ones get deployed.</p><p>That’s not a guarantee. It’s a process.</p><p>And in quant finance, process is everything.</p><p><em>Next: Reading the Balance Sheet Like a Quant: Where Fundamental Data Meets Systematic Trading</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=889a6f6c086f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Is an Alpha? The Secret Language of Quantitative Trading]]></title>
            <link>https://medium.com/@a.m.x.janjan/what-is-an-alpha-the-secret-language-of-quantitative-trading-20f82921f9c7?source=rss-34311d6971f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/20f82921f9c7</guid>
            <category><![CDATA[alpha]]></category>
            <category><![CDATA[quantitative-finance]]></category>
            <category><![CDATA[stocks]]></category>
            <category><![CDATA[finance]]></category>
            <dc:creator><![CDATA[Amir M. Janjan]]></dc:creator>
            <pubDate>Tue, 19 May 2026 16:32:00 GMT</pubDate>
            <atom:updated>2026-05-19T16:32:00.376Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*EmZAGuK6jkhHC_OB.jpeg" /></figure><p>Every day, billions of dollars move through financial markets based not on gut feelings or hot tips — but on mathematical signals called <strong>alphas</strong>. If you’ve ever wondered how hedge funds like Two Sigma or WorldQuant actually work, this is where it starts.</p><p>Let’s break it down.</p><h3>The word “alpha” means three things at once</h3><p>In quant finance, an alpha is simultaneously:</p><ol><li>A <strong>mathematical model</strong> — a formula or piece of code</li><li>A <strong>return forecast</strong> — a prediction of how much a stock will move</li><li>An <strong>opinion</strong> — a structured hypothesis about market behavior</li></ol><p>These three definitions are actually the same thing expressed differently. The formula encodes the opinion, and the opinion produces the forecast.</p><p>A simple example: suppose you believe that stocks which fell sharply yesterday tend to bounce back today. That belief, turned into a formula, is an alpha.</p><h3>What an alpha actually looks like</h3><p>At its core, an alpha is a table. Rows are stocks. Columns are days. Each cell contains a number — a position size. Positive means you’re betting the stock goes up (long). Negative means you’re betting it goes down (short). Zero means you stay out.</p><p>That table updates every day. The changes in position are what get traded.</p><p>The quality of an alpha is measured by the <strong>information ratio</strong> — the ratio of average return to the variability of that return. The higher and more consistent the returns, the better the alpha.</p><h3>Where alphas come from</h3><p>Markets move because the world changes. A drug approval. An earnings miss. A new regulation. Each event leaves a footprint in the data.</p><p>The quant researcher’s job is to find those footprints before they disappear.</p><p>The raw material is <em>change</em>. Not price itself — but price changing. Not revenue — but revenue growing faster than expected. Three common ways to express a change:</p><ul><li><strong>Difference:</strong> today’s price minus yesterday’s price</li><li><strong>Ratio:</strong> today’s price divided by yesterday’s price</li><li><strong>Relative expression:</strong> 1 / price (invest more when price is low)</li></ul><p>Every alpha starts as a hypothesis:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*MwOLzTHTaASpnOGdDgulLA.png" /></figure><p>Notice the logic always comes before the math. You’re not curve-fitting numbers — you’re translating an idea about human behavior into a formula.</p><h3>The alpha pipeline</h3><p>Here’s the full journey from idea to trade:</p><pre>Observation → Hypothesis → Formula → Backtest → Refine → Deploy</pre><p><strong>Step 1 — Collect information.</strong> Say you’re watching two tech stocks. You notice they’ve both trended up for a week.</p><p><strong>Step 2 — Form a hypothesis.</strong> When prices rise, investors book profits, pushing prices back down. This is mean reversion.</p><p><strong>Step 3 — Write the formula.</strong> Alpha = −(1-week return). The minus sign says: short what went up, go long what went down.</p><p><strong>Step 4 — Make it robust.</strong> What if a sector-wide event tanks both stocks while you’re holding them? You neutralize this by making your strategy <em>sector-neutral</em> — equal dollar amounts long and short within the same sector. The individual bets remain, but the sector-level exposure cancels out.</p><p><strong>Step 5 — Convert to positions.</strong> Final position = (alpha value / sum of all alpha values) × total capital. If you have $10M and your signals say Apple is twice as strong as Google, Apple gets $6.7M and Google gets $3.3M.</p><h3>What makes a good alpha?</h3><p>A strong alpha has these qualities:</p><ul><li><strong>Simple idea, elegant expression.</strong> If you can’t explain the logic in one sentence, it’s probably overfit.</li><li><strong>Works in multiple markets and regions.</strong> A signal that only works in U.S. tech stocks in 2019 is suspicious.</li><li><strong>Stable under small changes.</strong> Tweak the lookback window by one day — does performance collapse? Then it’s fragile.</li><li><strong>Its profits keep hitting new highs.</strong> Not just historically good, but still working today.</li></ul><p>There’s a deeper reason simplicity matters: markets are efficient enough that most free lunches get eaten quickly. The signals that survive are the ones connected to something real — a structural behavior pattern, a persistent human bias, a liquidity dynamic. Complex formulas tend to be fitting the past rather than predicting the future.</p><h3>Why alphas exist at all</h3><p>If markets were perfectly efficient, no alpha would work. Every piece of information would already be priced in.</p><p>But markets are made of humans — or systems built by humans — with different time horizons, different information, different goals. That friction is where alphas live.</p><p>And here’s the irony: the act of trading alphas is what <em>makes</em> markets more efficient. Quant funds are, in a weird sense, the mechanism by which information gets absorbed into prices. They find inefficiencies, trade them, and in doing so, reduce them.</p><p>Which means alphas have a natural lifecycle. They’re discovered, traded, crowded, and eventually decay. The edge shrinks as more capital chases it. That’s why quant research is a continuous process — not a one-time discovery.</p><p><em>Next: The Backtest Trap: Why Great Historical Performance Means Almost Nothing</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20f82921f9c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Ethereum Actually Works: Accounts, Transactions, Gas, and Blocks Explained]]></title>
            <link>https://medium.com/@a.m.x.janjan/how-ethereum-actually-works-accounts-transactions-gas-and-blocks-explained-6ccb7a807d89?source=rss-34311d6971f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ccb7a807d89</guid>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[ethereum]]></category>
            <dc:creator><![CDATA[Amir M. Janjan]]></dc:creator>
            <pubDate>Mon, 18 May 2026 10:28:03 GMT</pubDate>
            <atom:updated>2026-05-18T10:28:03.202Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A mental model for developers who want to understand Ethereum from the ground up — not just how to use it, but why it works the way it does.</em></p><p>At its core, Ethereum is a <strong>state machine</strong>. Not a buzzword — a literal one. There’s a giant global database of accounts and balances and data, and every transaction you send is an instruction to change that database. That’s it. That’s Ethereum.</p><p>Let’s build the full picture, piece by piece.</p><h3>Part 1: Accounts</h3><p>Everything in Ethereum starts with an account. There are exactly two kinds.</p><h3>Externally Owned Accounts (EOAs)</h3><p>This is your wallet. Your MetaMask. The thing you control with a private key.</p><p>An EOA stores:</p><ul><li>An ETH balance</li><li>A <strong>nonce</strong> (a counter — more on that later)</li></ul><p>That’s genuinely it. No code. No logic. Just a balance and a counter, protected by a private key.</p><p><strong>Mental model: a human-controlled account.</strong></p><h3>Contract Accounts</h3><p>This is where things get interesting. A contract account is code — actual executable logic — living permanently on the Ethereum blockchain.</p><p>A contract account stores:</p><ul><li>An ETH balance</li><li>The smart contract code (compiled EVM bytecode)</li><li>Persistent storage (variables that survive between calls)</li></ul><p>Here’s the key insight most people miss: <strong>a contract account has no private key.</strong> Nobody “owns” it the way you own your wallet. It’s controlled entirely by its own logic. When something calls it, it executes. Otherwise, it just sits there, waiting.</p><p><strong>Mental model: a robot that follows code rules, not a human’s instructions.</strong></p><h3>Part 2: Transactions</h3><p>Accounts are static. Transactions are what actually <em>move things</em>.</p><p>A transaction is a signed instruction from an EOA to change Ethereum’s state. It always comes from a human-controlled wallet, and it does one of three things:</p><ol><li>Sends ETH to another account</li><li>Calls a function on a smart contract</li><li>Deploys a new smart contract</li></ol><p>Notice that “send money” is just one option — and not even the most interesting one. A transaction is better thought of as a <strong>signed request to execute computation on Ethereum</strong>.</p><h3>What’s inside a transaction?</h3><p>Every transaction contains:</p><ul><li>from — the sender (an EOA)</li><li>to — the recipient (an EOA or contract address)</li><li>value — ETH to send (can be zero)</li><li>data — the function call and inputs (crucial for contract interactions)</li><li>nonce — a counter that prevents the same transaction from being replayed</li><li>signature — cryptographic proof that you authorized this</li></ul><h3>What happens when you send one?</h3><ol><li><strong>You create the transaction</strong> — your wallet builds the fields above</li><li><strong>You sign it</strong> — your private key proves you authorized it, without revealing the key itself</li><li><strong>It hits the network</strong> — nodes validate the signature, nonce, and your balance</li><li><strong>It executes</strong> — if calling a contract, the contract code runs; balances and storage update</li><li><strong>It gets included in a block</strong> — only then is it “finalized”</li></ol><p>Think of a transaction as a <strong>signed API request to Ethereum</strong>.</p><h3>Part 3: Gas</h3><p>Here’s a problem: Ethereum is a global computer that anyone can use. What stops someone from deploying a smart contract with an infinite loop and grinding the whole network to a halt?</p><p>Gas.</p><p><strong>Gas is a unit of computation</strong>, not a currency. ETH is money. Gas is a measure of “how much work did this transaction require?”</p><p>Every operation the Ethereum Virtual Machine (EVM) executes has a fixed gas cost. Adding two numbers costs gas. Reading from storage costs gas. Writing to storage costs more gas.</p><h3>The fee formula</h3><pre>Transaction Fee = Gas Used × Gas Price</pre><ul><li><strong>Gas Used</strong>: how many units of computation your transaction consumed (e.g., a simple ETH transfer costs exactly 21,000 gas)</li><li><strong>Gas Price</strong>: how much you’re willing to pay per gas unit, denominated in <strong>gwei</strong> (one gwei = 0.000000001 ETH)</li></ul><p><strong>Example</strong>: A contract call using 50,000 gas at 20 gwei costs:</p><pre>50,000 × 20 gwei = 1,000,000 gwei = 0.001 ETH</pre><h3>Why gas is one of Ethereum’s best ideas</h3><p>Gas solves three problems simultaneously:</p><ol><li><strong>No infinite loops</strong> — you pay per computational step, so infinite loops just drain your funds and revert</li><li><strong>Fair resource pricing</strong> — complex operations cost more than simple ones</li><li><strong>Spam resistance</strong> — flooding the network with junk transactions becomes expensive fast</li></ol><p>One more thing: <strong>only EOAs pay gas</strong>. Contracts execute logic, but the user who triggered the transaction foots the bill in ETH.</p><h3>Part 4: Blocks</h3><p>You now understand who exists (accounts), what they do (transactions), and what it costs (gas). The last piece: where do transactions actually <em>go</em>?</p><p>Blocks.</p><p>A block is a <strong>batch of transactions plus the resulting state update</strong>. Each block contains:</p><ul><li>A list of transactions</li><li>A reference to the previous block (the “chain” in blockchain)</li><li>The new global state after executing those transactions</li><li>Metadata: timestamp, validator, gas limit, etc.</li></ul><h3>Why batch transactions into blocks?</h3><p>Three reasons:</p><ol><li><strong>Ordering matters.</strong> If Alice sends ETH to Bob and Bob sends ETH to Carol, the order of those transactions changes whether Bob’s second transaction succeeds. Blocks establish a canonical order everyone agrees on.</li><li><strong>Consistency.</strong> Every node on the network must apply the exact same transactions in the exact same order. Blocks make this possible.</li><li><strong>Efficiency.</strong> Processing transactions in batches is faster than handling them one at a time globally.</li></ol><h3>The mempool</h3><p>Before a transaction makes it into a block, it waits in the <strong>mempool</strong> — a holding area for unconfirmed transactions that every node sees.</p><p>Validators (the people creating blocks) pick transactions from the mempool, usually prioritizing those with higher gas prices. If the network is congested, your transaction might wait for several blocks before it gets included.</p><h3>Block gas limits</h3><p>Each block has a maximum amount of total computation it can contain. This cap prevents any single block from becoming so heavy that it slows down the network. It’s also why not every transaction fits in every block — and why gas prices spike when demand is high.</p><h3>Putting It All Together</h3><p>Here’s the full lifecycle of a transaction, end to end:</p><pre>You (EOA) decide to call a smart contract<br>         ↓<br>Your wallet builds the transaction<br>         ↓<br>You sign it with your private key<br>         ↓<br>Transaction broadcasts to the network → enters mempool<br>         ↓<br>A validator picks it up and includes it in a block<br>         ↓<br>The block executes: contract code runs, gas is consumed<br>         ↓<br>State updates: balances change, storage changes<br>         ↓<br>Block is added to the chain — transaction is final</pre><p>Every node on the network replays this execution and arrives at the same result. No central server decides what happened. The math decides.</p><h3>The one thing to remember</h3><blockquote><strong><em>Ethereum is a shared computer where every transaction is re-executed by all nodes in the same order.</em></strong></blockquote><p>That’s why it works without a central authority. Deterministic execution + ordered blocks + economic incentives via gas = trustless global consensus.</p><h3>Bonus: Wallet Address vs. Contract Address</h3><p>Both look identical — a 0x... string of 42 characters. But they&#39;re completely different under the hood.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*BT1czwNNZOcprQonwHH4bw.png" /></figure><p><strong>Wallet = actor.</strong> It initiates things. You decide.</p><p><strong>Contract = reactor.</strong> It executes rules when triggered by a transaction. It can call other contracts mid-execution, but only within a transaction chain that was started by an EOA somewhere up the call stack.</p><p>Example — swapping tokens on Uniswap:</p><ol><li>Your wallet sends a transaction</li><li>The transaction calls the Uniswap contract</li><li>Uniswap’s contract executes the swap logic (possibly calling other contracts)</li><li>Tokens move, state updates</li><li>Done</li></ol><p>You (the EOA) are always the one who kicks things off.</p><h3>Final Mental Model</h3><p>Think of Ethereum as a <strong>global shared spreadsheet</strong>:</p><ul><li><strong>Accounts</strong> = users and formulas with permission to make edits</li><li><strong>Transactions</strong> = edit requests</li><li><strong>Gas</strong> = cost per edit, based on complexity</li><li><strong>Blocks</strong> = batches of approved edits applied together</li><li><strong>Validators</strong> = the committee that approves each batch</li><li><strong>State</strong> = the final spreadsheet after all edits</li></ul><p>Understanding this model makes everything else in Ethereum — DeFi protocols, NFTs, Layer 2s, MEV — click into place. It’s all just transactions, gas, and state transitions, all the way down.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ccb7a807d89" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inside the Black Box: Decoding the Math Behind Quantitative Trading Alphas]]></title>
            <link>https://medium.com/@a.m.x.janjan/inside-the-black-box-decoding-the-math-behind-quantitative-trading-alphas-d7e41ba84884?source=rss-34311d6971f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7e41ba84884</guid>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[stock-market]]></category>
            <category><![CDATA[financial-markets]]></category>
            <category><![CDATA[quantitative-finance]]></category>
            <dc:creator><![CDATA[Amir M. Janjan]]></dc:creator>
            <pubDate>Sun, 17 May 2026 20:18:04 GMT</pubDate>
            <atom:updated>2026-05-17T20:18:04.599Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How Wall Street’s quant funds turn price and volume data into trading signals — and what they actually mean</em></p><p>Every day, quantitative hedge funds execute billions of dollars in trades based on signals most investors have never heard of. These signals — called <strong>alphas</strong> — are mathematical formulas that attempt to predict short-term stock price movements. They look cryptic. Some of them <em>are</em> cryptic. But underneath the notation lies a surprisingly intuitive logic.</p><p>Let’s pull back the curtain.</p><h3>What Goes Into an Alpha?</h3><p>At their most basic, alphas feed on price and volume data. The typical inputs are:</p><ul><li><strong>open, high, low, close</strong> — the standard daily price bars</li><li><strong>volume</strong> — number of shares traded</li><li><strong>vwap</strong> — volume-weighted average price (where most trading actually happened)</li><li><strong>returns</strong> — daily close-to-close percentage changes</li><li><strong>adv(d)</strong> — average daily <em>dollar</em> volume over the past <em>d</em> days</li><li><strong>cap</strong> — market capitalization</li><li><strong>IndClass</strong> — industry classification (GICS, BICS, etc.) for neutralizing sector effects</li></ul><p>Simple inputs. But the formulas built on top of them can get… elaborate.</p><h3>The Simple Ones First</h3><h3>Alpha #6: Betting Against Enthusiastic Opens</h3><pre>(-1 * correlation(open, volume, 10))</pre><p>This computes the 10-day rolling correlation between a stock’s open price and its trading volume — then flips the sign.</p><p>The logic: if a stock consistently opens higher <em>when</em> volume is elevated, that’s suspicious. Overly enthusiastic opens on heavy volume tend to reverse. Short them.</p><h3>Alpha #12: Volume-Confirmed Reversal</h3><pre>sign(delta(volume, 1)) * (-1 * delta(close, 1))</pre><p>Break this down:</p><ul><li>delta(volume, 1) = today&#39;s volume minus yesterday&#39;s (positive if volume increased)</li><li>sign(...) = +1 or -1 depending on direction</li><li>delta(close, 1) = today&#39;s price change, then negated</li></ul><p><strong>The result:</strong> If volume rose <em>and</em> price rose → short signal. If volume fell <em>and</em> price rose → long signal.</p><p>This is a classic contrarian bet: price moves on expanding volume are viewed skeptically; price moves on shrinking volume might have legs (or are worth fading on a reversal).</p><h3>Alpha #33: Fade the Intraday Winner</h3><pre>rank((-1 * ((1 - (open / close))^1)))</pre><ul><li>open/close is less than 1 when the stock closed higher than it opened</li><li>1 - (open/close) is positive for stocks that <em>rose</em> during the day</li><li>Multiply by -1, then rank cross-sectionally</li></ul><p><strong>Translation:</strong> This ranks stocks by how much they <em>fell</em> intraday, and goes long the worst performers. Pure mean-reversion — betting that what goes down during a session tends to bounce back.</p><h3>Slightly More Sophisticated</h3><h3>Alpha #4: Mean Reversion in Relative Strength</h3><pre>(-1 * Ts_Rank(rank(low), 9))</pre><ul><li>rank(low) = where today&#39;s low sits relative to other stocks (cross-sectional)</li><li>Ts_Rank(..., 9) = where that cross-sectional rank sits over the past 9 days (time-series)</li><li>Multiply by -1</li></ul><p>If a stock’s <em>low</em> has been consistently ranked high relative to peers for 9 days running, the signal turns negative. A stock that has maintained a high intraday floor for over a week is due to revert.</p><h3>Alpha #43: High Volume + Recent Drop = Opportunity?</h3><pre>ts_rank((volume / adv20), 20) * ts_rank((-1 * delta(close, 7)), 8)</pre><p>Two components multiplied together:</p><ol><li>How unusual is today’s volume relative to the 20-day average? (Ranked over 20 days)</li><li>How negative is the 7-day price change? (More negative = higher rank)</li></ol><p><strong>Signal is highest when:</strong> volume is spiking <em>and</em> the stock has dropped significantly over the past week. Classic capitulation/reversal setup.</p><h3>Alpha #101: Intraday Momentum</h3><pre>(close - open) / ((high - low) + 0.001)</pre><p>A clean ratio: how much of today’s intraday range did the stock capture in the direction of the move? A stock that opens at the low and closes near the high scores well. The 0.001 prevents division by zero on days with almost no range.</p><h3>Alpha #42: VWAP Mean Reversion</h3><pre>rank((vwap - close)) / rank((vwap + close))</pre><p>If the close is <em>above</em> VWAP, it means buying pressure intensified in the second half of the day — and this alpha fades that move. The intuition: a close above VWAP suggests late-session enthusiasm that may not persist overnight.</p><h3>The Conditional Alpha</h3><h3>Alpha #24: Market Regime Switching</h3><pre>IF: (change in 100-day MA over 100 days) &lt; 5%<br>THEN: -1 * (close - ts_min(close, 100))    ← mean reversion<br>ELSE: -1 * delta(close, 3)                 ← short the 3-day trend</pre><p>This is an alpha with <em>two personalities</em>:</p><ul><li><strong>In calm markets</strong> (flat 100-day moving average): buy stocks near their 100-day lows — mean reversion</li><li><strong>In trending markets</strong>: fade 3-day price increases — momentum is less reliable, reversals more common</li></ul><p>The insight is that strategies that work in trending markets often fail in ranging ones, and vice versa. This alpha tries to detect which regime you’re in.</p><h3>When Machines Write the Formulas</h3><h3>Alpha #78: The Optimized Beast</h3><pre>rank(correlation(sum(((low * 0.352233) + (vwap * 0.647767)), 19.7428), <br>     sum(adv40, 19.7428), 6.83313)) ^ <br>rank(correlation(rank(vwap), rank(volume), 5.77492))</pre><p>Those decimal numbers — 0.352233, 19.7428, 6.83313 — are not human choices. They were <strong>fitted to historical data</strong> by an optimization algorithm. A human might have written &quot;use a 20-day window.&quot; The machine found that 19.7428 was marginally better in backtest.</p><p>Whether that precision survives out-of-sample is another question entirely.</p><h3>How You Measure an Alpha</h3><p>Once you have a formula, you need to know if it actually works. The key metrics:</p><p>Metric Formula Meaning <strong>Annualized Sharpe</strong> √252 · (avg daily P&amp;L / daily volatility) Risk-adjusted return <strong>Daily Turnover</strong> Dollar volume traded / total investment How actively it trades <strong>Cents-per-share</strong> 100 · (avg daily P&amp;L / avg daily shares traded) Average edge per share</p><p>From these you can derive:</p><ul><li><strong>Average holding period</strong> = 1 / daily turnover (in days)</li><li><strong>Daily return</strong> = avg daily P&amp;L / total investment</li></ul><p>An alpha with a Sharpe of 1.5 and low turnover that holds positions for a week is very different from one with a Sharpe of 2.0 but 100% daily turnover (where transaction costs will eat you alive).</p><h3>The Most Complex: Alpha #100</h3><pre>(0 - (1 * ((1.5 * scale(indneutralize(indneutralize(<br>  rank(((close - low) - (high - close)) / (high - low)) * volume), <br>  IndClass.subindustry), IndClass.subindustry))) - <br>  scale(indneutralize((correlation(close, rank(adv20), 5) - <br>  rank(ts_argmin(close, 30))), IndClass.subindustry))) * (volume / adv20)))</pre><p>This is a production alpha, not a textbook example. Let’s untangle it:</p><p><strong>Component 1:</strong></p><ul><li>((close - low) - (high - close)) / (high - low) is a &quot;where did the stock close within its range?&quot; measure. Positive = closed near high. Negative = closed near low.</li><li>Multiply by volume, rank it, then <strong>neutralize by subindustry <em>twice</em></strong></li><li>Scale it</li></ul><p><strong>Component 2:</strong></p><ul><li>Correlate close prices with ranked average volume over 5 days</li><li>Subtract the rank of the <em>day</em> the 30-day minimum occurred (ts_argmin)</li><li>Neutralize by subindustry, scale</li></ul><p><strong>Then:</strong> Subtract component 2 from 1.5× component 1, multiply by relative volume (volume / adv20), flip sign.</p><p><strong>The purpose:</strong> Strip out every industry-level effect. What’s left should be purely stock-specific signal, weighted by how much the stock is trading relative to its own history.</p><h3>What This All Means</h3><p>A few takeaways for anyone trying to understand this world:</p><p><strong>1. Most alphas are contrarian.</strong> The majority of the formulas above bet against recent moves — fading price increases, buying recent losers. The market tends to overreact in the short term.</p><p><strong>2. Volume is a signal amplifier.</strong> Volume alone doesn’t predict direction, but combined with price action, it helps distinguish genuine moves from noise.</p><p><strong>3. Neutralization matters.</strong> Sophisticated alphas remove industry and market effects. You don’t want your “alpha” to just be “short tech in a tech sell-off.”</p><p><strong>4. Parameters are fitted, not derived.</strong> Many of these numbers come from optimization. That means overfitting risk is real. The decimal-precise window lengths are artifacts of backtesting, not fundamental truths.</p><p><strong>5. Simple alphas still work.</strong> Alpha #12 is four operations. Alpha #101 is a ratio. Complexity doesn’t guarantee edge — and sometimes destroys it.</p><p><em>The formulas in this post are drawn from the “101 Formulaic Alphas” research paper by Zura Kakushadze and the WorldQuant research corpus. They are real production signals, not pedagogical inventions.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7e41ba84884" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using LLMs in Trading]]></title>
            <link>https://medium.com/@a.m.x.janjan/using-llms-in-trading-372a16607ff8?source=rss-34311d6971f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/372a16607ff8</guid>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[fintech]]></category>
            <category><![CDATA[trade]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Amir M. Janjan]]></dc:creator>
            <pubDate>Sat, 27 Sep 2025 19:31:14 GMT</pubDate>
            <atom:updated>2025-09-27T19:31:14.961Z</atom:updated>
            <content:encoded><![CDATA[<p>we can use LLM in trading; but why to add this computational complexity? and how?</p><p>we can do many things with LLMs, but for trading, there are two main applications of LLMs:</p><ul><li>LLM as Trader</li><li>LLM as an Alpha Miner</li></ul><p>I think it is good to define the second one. In alpha miner, LLM generates alpha factors instead of directly making trading decisions. so what is alpha factor in this context? → The LLM isn’t telling you <strong>“buy BTC now”</strong> or <strong>“short ETH”</strong>. instead, it produces <strong>candidate predictive signals</strong> (features) like:</p><ul><li>Sentiment score from news/social media</li><li>Topic frequency (e.g., AI, regulation, Fed policy mentions)</li><li>Unusual word co-occurrence patterns from earnings reports</li><li>A rule like “if retail sentiment &gt; institutional sentiment, expect positive returns in 1 day”</li></ul><p>example: QuantAgent → <a href="https://arxiv.org/abs/2402.03755">https://arxiv.org/abs/2402.03755</a></p><p>QuantAgent leverages the LLM’s capability to produce alpha factors through an innerloop-outerloop architecture. In the inner loop, the writer agent takes in a general idea from human trader and generates a script as its implementation. The judge agent provides feedback to refine the script. In the outer loop, the committed code are tested in real world market and the trading results are used to enhance the judge agent. It has been proved that that this approach enables the agent to progressively approximate optimal behavior with reasonable efficiency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9kP_YAHB3sqLt-wYuhsNpA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*kWngN1fU_Xad7OoFFAnY4g.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k8PH_91m-TUXXGA4aPh9dw.png" /></figure><p>I want to explain it with example (these may have some differences with QuantAgent):</p><ul><li>Human idea: “News sentiment might predict short-term stock returns.”</li><li>Writer agent: Writes Python code to scrape news headlines, run sentiment analysis, and compute a <strong>sentiment score</strong> per stock.</li><li>Judge agent: Notices the code didn’t handle missing data, suggests fixes, and optimizes the factor’s normalization.</li><li>Outer loop: Factor is tested in backtest → if profitable, system marks it as promising; if not, feedback is used to refine future scripts.</li></ul><p>you should consider that:</p><ul><li>The <strong>LLM generates the alpha factor code</strong> (e.g., “compute sentiment score from headlines”).</li><li>That factor is plugged into a <strong>template trading algorithm</strong> (pre-written by humans)</li></ul><p>the other one was <strong>LLM as Trader</strong>. in this application, LLM should make decision: {BUY, HOLD, SELL}</p><h3>FinMEM</h3><p>there are some architecture for these type of agents, one of them is <strong>FinMem</strong> which is i think has good ideas about making LLM-based trader agent. it has 3 core modules:</p><ul><li><strong>Profiling</strong>, to customize the agent’s characteristics</li><li><strong>Memory</strong>, with layered message processing, to aid the agent in assimilating hierarchical financial data</li><li><strong>Decision-making</strong>, to convert insights gained from memories into investment decisions {BUY, SELL, HOLD}</li></ul><h4>Profiling Module</h4><p>The profiling module empowers FINMEM to develop a <strong>dynamic agent character</strong>. The dynamic character of FINMEM comprises two principal components:</p><ol><li>A foundational professional knowledge base akin to a trading expert</li><li>An agent with three distinct investment risk inclinations</li></ol><p>The <strong>first component</strong> includes two types of information:</p><ol><li>An introduction to the primary trading sectors relevant to the company stock FINMEM will trade in</li><li>A concise overview of the historical financial performance of the specified ticker, spanning from the beginning to the end of the training period.</li></ol><p>The <strong>second component</strong> of FINMEM’s design encompasses three distinct risk inclination options:</p><ol><li><strong>risk-seeking</strong>: aggressive, high-reward approach</li><li><strong>risk-averse</strong>: conservative, lower-risk strategy</li><li><strong>self-adaptive</strong> → example: it shifts risk preferences when the Cumulative Return falls to below zero within a brief period, such as three days, and reversely</li></ol><p>note: The system maintains a catalog of all risk inclinations and their detailed explanations in a backlog, enabling seamless adaptation to different stocks by switching among these risk profiles as needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UrdQzEc8O063fg-qV5c6Rg.png" /></figure><h3>Memory Module</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MIcHfLmAiXR0ppCWoB5OhQ.png" /></figure><p>The memory module of FINMEM emulates a human trader’s cognitive system so that it can efficiently process hierarchical financial information and prioritize the critical messages for high-quality investment decisions.</p><p>it consists of :</p><ol><li>working memory</li><li>layered long term memory</li></ol><h4>working memory</h4><p>Working memory refers to the human cognitive system’s functions for temporary storage and diverse operations[a central workspace for informed decision-making]. → unlike human brain, it can handle more than 10 memory event.</p><p>for converting data to trading action, FINMEM’s working memory encompasses three key operations:</p><ol><li>summarization</li><li>observation</li><li>reflection</li></ol><p><strong>summarization: </strong>the system condenses the original text into a compact yet informative paragraph[for enhancing processing efficieny]. FINMEM directs these insights to an appropriate layer within its long-term memory architecture, selecting the layer based on the time sensitivity of the information.</p><p><strong>observation:</strong> gathering market facts. during training, the model can look at all historical prices for a stock in the time period you provide (e.g., last 5 years).When someone asks FINMEM what to do, they provide:</p><ol><li>A <strong>stock ticker</strong> (like AAPL or TSLA)</li><li>A <strong>specific date</strong></li></ol><p>The model looks at the <strong>adjusted closing price</strong> for the given day and the <strong>next day</strong>. then calculates:</p><p>Price difference=Next day’s adjusted closing price−Current day’s adjusted closing price</p><p>the label is derived from the price change:</p><ul><li><strong>If the price goes down → label = “Sell”</strong></li><li><strong>If the price goes up or stays the same → label = “Buy”</strong></li></ul><p>So FINMEM is learning to <strong>predict the action (Buy/Sell) based on historical price changes</strong>.</p><p>During the testing phase, at a specific time point, FINMEM loses the ability to access future price data. It tests whether the system has adequately established logical connections between stock price trends and various financial information sources, such as news, reports, and indicators.</p><p><strong>Reflection:</strong> Two types of reflections exist:</p><ul><li>immediate reflection</li><li>extended reflection</li></ul><p><strong>Immediate reflection</strong> is activated upon receiving a daily trading inquiry for a specific ticker. Using LLM and specific prompts, the agent merges market indications[from observation section] and top-K-ranked events from each long-term memory layer.</p><p>During testing, this process yields three types of outputs:</p><ul><li>the trading direction (“Buy”, “Sell”, or “Hold”)</li><li>the underlying rationale for this decision</li><li>the most influential memory events[along with their IDs]</li></ul><p>In the training phase, specifying the trading direction is unnecessary, as FINMEM is already informed of future stock movement directions.</p><p><strong>Extended reflection</strong> reevaluates immediate reflection outcomes for a ticker over a specified M -day trace period.</p><p>It encompasses data like stock price trends, trading returns, and action rationales from multiple immediate reflections. While immediate reflection enables direct trading execution and records current feedback, extended reflection summarizes market trends and reassesses recent Cumulative Return on investment. Extended reflection is eventually transmitted and stored in the deep processing layer to emphasize its criticality of long-term memory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H56I43a_piJ41QKQK2jdIQ.png" /></figure><h4>Layered long-term memory</h4><p>FINMEM’s long-term memory organizes hierarchical financial data insights in a stratified structure. Drawing inspiration from the varying decay speeds in the human cognitive system’s information processing layers , FINMEM employs a layered structure to accommodate the diverse time sensitivities inherent to different types of financial data. This structure categorizes summarized insights by their timeliness and decay rates.</p><p>This structure categorizes summarized insights by their timeliness and decay rates. Insights are derived by the working memory’s summarization operation. Those directed to deeper layers receive smaller decay rates, indicating longer retention, while those in shallower layers are assigned larger decay rates for shorter retention.</p><p>Upon receiving an investment inquiry, FINMEM retrieves the top-K pivotal memory events from each layer and channels them to the immediate reflection component of the working memory. These events are chosen according to the descending order of their information retrieval score:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*joB0R6LE1rNEUgTXY__q8A.png" /></figure><p>Individual metric scores exceeding 1.0 are scaled to the [0,1] range before being summed. (l(L) belongs to the set(shallow, immediate, deep)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/464/1*n-L_HeKU1ZUhwQIF0UZSPg.png" /></figure><p>The relevancy score quantifies the cosine similarity between the embedding vectors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*Tk5LrCpkVq-nsT9AkTNTYA.png" /></figure><p>and for importance score we have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*fllKhPUdxw6XuMOq8GAdzQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/1*3V4A_a2APBDEe7GY4CjNLw.png" /></figure><p>for further information read <a href="https://arxiv.org/abs/2311.13743">the paper</a>.</p><p>Furthermore, an access counter function oversees the transfer of memory events among layers, ensuring that significant events influencing trading decisions ascend from shallower to deeper layers for extended retention and recurrent access by FINMEM. By implementing this access counter, FINMEM effectively identifies and prioritizes key events, taking into account their nature and frequency of retrieval.</p><h3>Decision-making Module</h3><p>The <strong>decision-making module of FINMEM</strong> integrates results from profiling and memory modules to support trading decisions, choosing among <strong>Buy, Sell, or Hold</strong> actions.</p><ul><li><strong>Training phase:</strong><br>FINMEM has access to complete historical data and multi-source information. When given a stock ticker, date, and trader-related text, it observes market ground labels (daily price differences → Buy/Sell), retrieves and ranks top-K relevant memories, and generates reflections linking price trends with memory. This builds its long-term memory but <strong>does not execute trades</strong>, instead focusing on learning from data and accumulating knowledge for future use.</li><li><strong>Testing phase:</strong><br>FINMEM no longer has access to future prices. Instead, it uses cumulative returns over the past M days, extended reflections, and retrieved top-K memories to anticipate trends. Reflections from past experiences act as supplementary references. Only in this phase does FINMEM generate <strong>executable trading actions</strong> (Buy/Sell/Hold).</li></ul><p>Overall, FINMEM learns during training by comparing past trends with financial messages, builds a memory-rich knowledge base, and then applies this knowledge during testing to make <strong>well-informed investment decisions</strong>.</p><h4>in short:</h4><p><strong>Prompt + profile defines the query → System ranks memories → Top-K retrieved → Reflection compares them with label → Guardrails rewards pivotal ones → Warehouse updated (importance boosted or memory promoted).</strong></p><h3>Conculsion:</h3><p>LLMs in trading add complexity, but they open new doors. Instead of only crunching numbers, they can understand unstructured data — news, filings, social media — and turn it into actionable signals.</p><p>There are two main ways to use them:</p><ul><li><strong>LLM as Alpha Miner</strong> → it generates <em>alpha factors</em> (predictive signals like sentiment, topic trends, or linguistic anomalies) that plug into existing quant strategies. Think of it as a smart research assistant.</li><li><strong>LLM as Trader</strong> → it directly decides <strong>Buy, Sell, Hold</strong>. Architectures like <strong>FINMEM</strong> show how memory, profiling, and reflection can make an LLM act like a human trader.</li></ul><p>In short: <strong>Alpha Miner augments research, Trader automates execution.</strong> The choice depends on whether you want insights <em>for humans</em> or an agent that trades <em>for you</em>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=372a16607ff8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Logistic Regression Interview Questions]]></title>
            <link>https://medium.com/@a.m.x.janjan/logistic-regression-questions-24694c0e9b54?source=rss-34311d6971f5------2</link>
            <guid isPermaLink="false">https://medium.com/p/24694c0e9b54</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[logistic-regression]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[data]]></category>
            <dc:creator><![CDATA[Amir M. Janjan]]></dc:creator>
            <pubDate>Sun, 20 Jul 2025 19:21:19 GMT</pubDate>
            <atom:updated>2025-07-27T10:31:29.986Z</atom:updated>
            <content:encoded><![CDATA[<p>we will analyze some problems in Logistic Regression, that would be useful for AI jobs interviews.</p><h3>Recap:</h3><p><strong>Logistic Regression</strong> is a statistical and machine learning method used to <strong>predict the probability</strong> that a given input belongs to a particular class, usually <strong>binary classification</strong> (e.g., yes/no, spam/not spam, 0/1).</p><ul><li><strong>Input:</strong> One or more features (like age, income, etc.)</li><li><strong>Output:</strong> A probability between 0 and 1</li><li><strong>Goal:</strong> Classify whether something belongs to <strong>class 1</strong> (e.g., “positive”) or <strong>class 0</strong> (e.g., “negative”)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*rpMRLDym-Go_3kxb9f5e2Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/193/1*l935WUlgUIo8v7xjzXt6Ng.png" /></figure><h4>Problem 1</h4><p>Define the term “<strong>odds of success</strong>” both qualitatively and formally.</p><p><strong>Solution:</strong> The odds of success are deﬁned as the ratio between the probability of success p ∈ [0, 1] and the probability of failure 1 − p.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*lKQQ7PSubXbjkjRpCkDQ_Q.png" /></figure><h4>Problem 2</h4><p>Define what is meant by the term “interaction”, in the context of a logistic regression predictor variable. What statistical tests can be used to attest the significance of an interaction term?</p><p><strong>Solution: </strong>An interaction is the product of two single predictor variables implying a non-additive effect. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/358/1*aM2-Q9IzKOVyPY4LTxKKig.png" /></figure><p>as we see, XZ is an interaction.</p><p>For testing the contribution of an interaction, two principal methods are commonly employed:</p><ul><li>Wald chi-squared test</li><li>likelihood ratio test</li></ul><p><strong>HOW?</strong></p><p><strong>two models</strong>:</p><ul><li>One <strong>with</strong> the interaction term (full model)</li><li>One <strong>without</strong> the interaction term (reduced model)</li></ul><h4><strong>Likelihood Ratio Test (LRT)</strong></h4><p><strong>idea:</strong> Compare the <strong>log-likelihoods</strong> of the two models.</p><h4>Steps:</h4><ol><li>Fit the <strong>reduced model</strong> (without interaction)</li><li>Fit the <strong>full model</strong> (with interaction)</li><li>Calculate:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/274/1*tbbyOW9Y66tROo5LjSvTvA.png" /></figure><p>4. This statistic follows a <strong>chi-squared distribution</strong> with degrees of freedom equal to the <strong>number of added parameters</strong> (usually 1 for a single interaction).</p><p>If the p-value is small (e.g., &lt; 0.05), the interaction term <strong>significantly improves</strong> the model.</p><h4>Wald Chi-Squared Test</h4><p>Test whether the <strong>coefficient of the interaction term</strong> is significantly different from 0.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/153/1*e2vvnd8ceQvkRBVF1PHawA.png" /></figure><p>Where beta_hat is the coefficient of the interaction term and SE(beta_hat) is its standard error.</p><p>This follows a chi-squared distribution with 1 degree of freedom.</p><p>If the p-value is small, the coefficient is <strong>significantly non-zero(e.g. more that 0.05)</strong>, so the interaction contributes to the model.</p><h4>problem 3</h4><p>The logistic regression model is a subset of a broader range of machine learning models known as <strong>generalized linear models (GLMs)</strong>, which also include <strong>analysis of variance (ANOVA)</strong>, <strong>vanilla linear regression</strong>, etc. There are<strong> three components to a GLM</strong>; identify these three components for binary logistic regression.</p><h4>solution:</h4><p>A binary logistic regression GLM consists of there components:</p><p>1.<strong> Random component</strong>: refers to the probability distribution of the response variable (Y ) [e.g. <strong>binomial distribution</strong> for Y in the binary logistic regression, which takes on the values Y = 0 or Y = 1]</p><p>2. <strong>Systematic component</strong>: describes the explanatory variables:<br>(X1 , X2 , …) as a <strong>combination of linear predictors</strong>. The binary case does not constrain these variables to any degree.</p><p>3. <strong>Link function</strong>: speciﬁes the <strong>link between random and systematic components</strong>. It says how the expected value of the response relates to the linear predictor of explanatory variables.</p><h4>Problem 4</h4><p>Let us consider the logit transformation, i.e., log-odds. Assume a scenario in which the logit forms the linear decision boundary:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*MdKBNMjMdi5HfqfLeVbpOw.png" /></figure><p>for a given vector of systematic components X and predictor variables θ. Write the mathematical expression for the hyperplane that describes the decision boundary.</p><h4>solution:</h4><p>The hyperplane is simply deﬁned by:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*qe4xXEBdeE-D3fy_AeRW3w.png" /></figure><h4>Problem 5</h4><p><strong>Explain the use of relative risk and odds ratio.</strong></p><h4>Solution:</h4><p>Relative risk (RR) is the ratio of risk of an event in one group (e.g., exposed group) versus the risk of the event in the other group (e.g., non-exposed group). The odds ratio (OR) is the ratio of odds of an event in one group versus the odds of the event in the other group.</p><h4>Problem 6</h4><p>The entropy of a single binary outcome with probability p to receive 1 is defined as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*WXpIuRrXzEMp3ykbzF42Zg.png" /></figure><ol><li>At what p does H(p) attain its maximum value?</li><li>What is the relationship between the entropy H(p) and the logit function, given p?</li></ol><p><strong>Solution:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*N63Dk-k0I1GoT8qXMDgC7Q.png" /></figure><ol><li>The entropy has a maximum value of log2 for probability p = 1/2, which is the most chaotic distribution. A lower entropy is a more predictable outcome, with zero providing full certainty.</li><li>The derivative of the entropy with respect to p yields the negative of the logit function: (prove it by yourself)</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*YoEdrcDSxG0QuQh83VSh8w.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24694c0e9b54" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>