今日已更新 80 条资讯 | 累计 20052 条内容
关于我们

标签:#stocks

找到 4 篇相关文章

AI 资讯

How to Backtest a Trading Strategy with Python and EODHD API

Most backtests lie to you. Not intentionally. But they lie. You design a strategy, run it on historical data, and watch the returns look incredible. Then you run it live — and it underperforms a simple buy-and-hold from day one. The math wasn't wrong. The data was. If you're: testing momentum or mean-reversion strategies in Python, building quant tools for personal or professional use, or tired of backtests that collapse the moment real execution begins, This changes how you work. TL;DR What this covers: Backtesting trading strategies in Python using EODHD's historical OHLCV data API Stack: requests , pandas , numpy — no heavy frameworks (no backtrader, no vectorbt) Scripts included: Script 1 — Fetch adjusted historical price data from EODHD Script 2 — SMA crossover strategy (20/50-day) Script 3 — RSI mean-reversion strategy Script 4 — Performance metrics: Sharpe ratio, max drawdown, win rate EODHD pricing: Free tier available; full access from $19.99/month Best for: Developers and analysts who need reliable, split/dividend-adjusted data without scraping The Problem with Free Data Most developers start with Yahoo Finance or a scraped CSV. That works fine for a quick prototype. It stops working the moment your strategy includes anything that happened around a stock split, dividend payment, or ticker change. Non-adjusted price data creates ghost signals. A stock "drops 50%" when it actually split 2:1. Your moving average calculates a crossover that never happened in real life. Your strategy looks profitable because it's trading on a data artifact. The free path costs you accuracy. And in backtesting, accuracy is the whole point. The Fix Is Simpler Than You Think The real bottleneck isn't the strategy logic. It's the data source. Use split- and dividend-adjusted closing prices from a reliable provider, and half your backtest reliability problems disappear before you write a single signal. EODHD APIs provides exactly this. Their historical data endpoint returns adjusted

2026-07-07 原文 →
AI 资讯

The Botfather: Building Your First Crypto Trading Bot

The Quest Begins (The "Why") Honestly, I was tired of staring at charts at 2 a.m., trying to catch that perfect entry while my coffee went cold. I’d set a manual alert, jump onto the exchange, click “buy”, and then second‑guess myself as the price slipped away. It felt like I was playing a never‑ending game of Whac‑A‑Mole, and I kept losing the mole. One night, after yet another missed opportunity, I thought: What if I could offload the repetitive bits to a script? Not a fancy AI that predicts the future—just a simple bot that watches the market, checks a condition, and places an order when the condition is met. If I could automate the boring part, I could focus on strategy, learning, and maybe even get some sleep. That was the dragon I wanted to slay: the exhaustion of manual trading. The Revelation (The Insight) The big “aha!” moment came when I realized I didn’t need to build a high‑frequency trading engine from scratch. There are solid, well‑tested libraries that handle the messy bits—authentication, rate limits, WebSocket connections—so I could concentrate on the logic. Using CCXT (a unified crypto exchange library) and a touch of asyncio , I could write a bot that: Connects to an exchange (I used Binance’s testnet so I wouldn’t lose real money). Polls the ticker for a symbol at a reasonable interval. Checks a simple condition—like “price > 20 % above the 20‑period moving average”. Places a market order if the condition holds, then waits for the next cycle. It felt like Neo dodging bullets in The Matrix when the bot finally executed a trade without crashing or getting rate‑limited. The relief was genuine: I could now let the code do the watching while I worked on the next idea. Wielding the Power (Code & Examples) The Struggle – A Naïve Loop My first attempt was a blocking while True loop with time.sleep . It looked harmless, but it had two nasty traps: Trap #1 – No error handling. A network hiccup would raise an exception and kill the whole script. Trap #2 – I

2026-06-21 原文 →
AI 资讯

📈 The Jedi’s Guide to Building a Python Stock‑Market Trading Bot

(or: How I Turned My Laptop Into a Lightsaber for the Market) The Quest Begins (The “Why”) Ever stared at a blinking cursor at 2 a.m., wishing you could make your laptop do the heavy lifting while you chased dreams (or just caught up on sleep)? I was there, scrolling through Reddit’s r/investing, watching folks brag about “algo‑trading gains” while I was still manually refreshing Yahoo Finance like a peasant in a medieval market. One night, after yet another failed attempt to predict a stock’s move with gut feeling (spoiler: my gut is terrible at math), I remembered a line from The Matrix : “There is no spoon.” Turns out, there is no magic either—just code, data, and a healthy dose of stubbornness. I decided to slay the dragon of emotion‑driven trading and build a bot that could execute a simple strategy while I binge‑watched Stranger Things . Spoiler alert: the first version was a hot mess, but the journey taught me more about Python, APIs, and risk management than any textbook ever could. Let’s walk through that adventure together—code, pitfalls, and all the triumphant “I‑did‑it!” moments. The Revelation (The Insight) The big “aha!” moment came when I realized a trading bot isn’t some omniscient AI that predicts the future; it’s just a disciplined executor of rules you define. Think of it as Indiana Jones whip‑cracking through a booby‑trapped temple: you set the traps (your strategy), the bot avoids them (risk checks), and grabs the idol (profit) when the conditions are right. For my first bot I chose a mean‑reversion idea: if a stock’s price deviates too far from its 20‑day moving average, I bet it’ll snap back. It’s not flashy, but it’s easy to understand, back‑test, and implement. The magic happens in three simple steps: Fetch data – pull recent price bars from a free API (I used Alpha Vantage; you can swap for Polygon, IEX Cloud, etc.). Calculate the signal – compare the latest close to the moving average and compute a z‑score. Execute – if the z‑score crosses

2026-06-19 原文 →