Stock & Skachatok
Hey Stock, have you checked out the latest free Python backtesting libraries—backtrader and zipline? They’re super efficient for quick strategy testing, but the data loading still lags a bit—wonder if there’s a cleaner API for that.
Yeah, I’ve skimmed both backtrader and zipline. Backtrader’s API is clean but the data loader can be a pain when you’re pulling lots of symbols from CSV or a database—there’s no built‑in async support, so it blocks. Zipline’s ingest pipeline is more robust, but it’s geared toward its own “pandas‑based” dataframes and you end up writing a lot of boilerplate to get external feeds in. A cleaner approach would be to wrap the data loading in a generator or use a lightweight library like yfinance or alpaca‑trade‑api to stream tick data and feed it directly into your strategy loop. That way you avoid the blocking reads and can keep the backtester snappy. If you really need an API‑style wrapper, something that abstracts the fetch/parse/queue logic into a single class would make the codebase cleaner and let you swap data sources without touching the strategy code.
Sounds like the bottleneck is the I/O, not the strategy logic. Try using an async CSV reader like pandas‑async or aiofiles to stream the rows, then feed them into a queue that the backtester consumes. For live or tick‑level data, Alpaca’s API or yfinance’s stream functions are already async, so you can pipe those ticks straight into the strategy loop. If you want a drop‑in replacement, look at vectorbt—it’s built on NumPy and lets you pull data via a simple async generator, so the whole pipeline stays non‑blocking. Just wrap the fetch‑parse‑queue logic in a single class and you can swap Yahoo, Alpaca, or a local database without touching the strategy code. That’s the cleanest, most efficient setup.