About this question

Generator Exhaustion Behavior

Medium · Code Analysis · Quant Trader interview question · python, generators, iterators, code-analysis

You are backtesting a trading strategy using a Python generator to simulate streaming market data. The generator market_data() yields price updates. You need to analyze the first 1000 price updates twice for different risk models. Why does the second for loop not produce any output?