← All tools · Guides

EODHD APIs: US and global daily bars on the same SQLite pipeline

Hands-on, the overseas sequel. AKShare covers China A-shares. This page puts US and global daily bars in the same SQLite file, and the backtest code stays as it is.

Short answer: send api_token, request AAPL.US, keep adjusted_close for returns and close for the traded price, and append source and exchange on the daily table from the AKShare walkthrough. Run the incremental job in the morning, Beijing time.

How to choose: To put US or global daily bars on the SQLite file you already use for China A-shares, call EODHD and append rows to the daily table from the AKShare walkthrough. After you register, the dashboard gives you an api_token, and every request sends it. The official DEMO token needs no account and only returns AAPL. US symbols take a .US suffix, so Apple is AAPL.US. Hong Kong is .HK. The daily URL is https://eodhd.com/api/eod/AAPL.US with fmt=json, order=d, and from and to. Use adjusted_close for backtest returns and close for the price that traded that day. Add source and exchange to an existing daily table. New rows set source to eodhd and exchange to US. For the next run, set from to the day after MAX(date). The US close is morning in Beijing, so schedule the job for the Beijing morning. China A-shares alone stay on AKShare, which is a different article. Choosing among yfinance, AKShare, OpenBB, and EODHD is a different article. A standalone US pipeline that was run with yfinance or EODHD is also a different article. This page only attaches EODHD daily bars to that existing table.

Who it is for: Someone who writes a little Python, already stores China A-share daily bars in SQLite the way the AKShare walkthrough does, and wants US or global daily bars in the same file without changing the backtest code. The path is the token, the exchange suffix, close versus adjusted_close, the source and exchange columns, and an incremental job in the Beijing morning.

Who it is not for: Someone who only trades China A-shares and does not need a formal API contract. AKShare is free and needs no key, so this page is the wrong one. This page is not the tool-order guide, not the site FAQ, and not the comparison of yfinance, AKShare, OpenBB, and EODHD. If you do not yet have the A-share table, start with the AKShare walkthrough. A from-scratch US pipeline is a different article.

The same walkthrough in Chinese is EODHD APIs for overseas data. It reuses the SQLite skeleton from AKShare into SQLite. The same AKShare walkthrough in Chinese is AKShare into SQLite (Chinese). Choosing among yfinance, AKShare, OpenBB, and EODHD is how to choose a data source. That comparison is not this article. A US pipeline that was actually run, as its own script, is the daily price pipeline. The next part of this series, a first strategy on the bars, is the first backtrader strategy.

Facts below follow the Chinese walkthrough. The commands were not re-run for this English page. The Chinese page says the site checked the first request in August 2026 with the DEMO token. This site is an affiliate of EODHD APIs. A registration through the link on this page may earn a commission, at no extra cost to you. This is not investment advice. Prices, quotas, and terms follow the live site.

01 · When you need an overseas source

AKShare is at home on China A-shares. It is free, it needs no registration, and it aggregates public Chinese sources. Two jobs sit outside that. One is a strategy on US or global markets. The other is an API with a formal contract. Aggregated scrapers change. A paid third-party source has a contract. EODHD APIs is the second kind: one API for daily and minute bars on the major exchanges, plain REST, and a free tier that can carry a single symbol through the flow. It fits a person who already has an A-share pipeline and wants to extend it overseas.

Pick the market before the source. A-shares only: AKShare is enough. US stocks, Hong Kong, or a global index: then consider a paid source.

02 · Register and take the token

After you register, the dashboard shows api_token. Every request sends it. EODHD also publishes a DEMO token so you can try a call with no account. It only returns AAPL. Replace it before real use. The free-tier quota is whatever the live site shows. This tutorial updates one symbol a day, and the Chinese page says that is enough to demo the whole flow on the free tier.

Registration, with this site's affiliate tag. The price you pay does not change:

EODHD APIs · register and take a token →

This tutorial is not investment advice. Paid prices and quotas follow the live site.

03 · The first request: Apple daily bars

A US symbol needs the .US suffix. AAPL becomes AAPL.US. Other exchanges have their own suffixes. A wrong one comes back empty. The Chinese page says the site ran the following in August 2026 with the DEMO token:

import requests
import pandas as pd

TOKEN = "your-token"  # the DEMO token only returns AAPL

url = "https://eodhd.com/api/eod/AAPL.US"
params = {
    "api_token": TOKEN,
    "fmt": "json",
    "order": "d",            # newest date first (checked on the Chinese page)
    "from": "2026-01-01",    # from/to is the incremental filter
    "to": "2026-08-28",
}
data = requests.get(url, params=params, timeout=30).json()

df = pd.DataFrame(data)
df["date"] = pd.to_datetime(df["date"])
df = df.set_index("date").sort_index()   # oldest to newest before the write
print(df[["open", "high", "low", "close", "volume"]].tail())

The payload has two price columns. close is the price that traded that day. adjusted_close is rewritten for splits and dividends. Backtest returns use the second. A historical price level uses the first. That is the AKShare qfq question under another name.

04 · Append it to the SQLite pipeline you already have

Add two columns to the daily table from the AKShare walkthrough. Overseas rows then share the file with A-share rows, and the backtest that reads the table does not change:

import sqlite3

conn = sqlite3.connect("a_daily.db")
# Existing file: add source and exchange. A new table should include both from the start.
cols = [r[1] for r in conn.execute("PRAGMA table_info(daily)")]
if "source" not in cols:
    conn.execute("ALTER TABLE daily ADD COLUMN source TEXT DEFAULT 'akshare'")
    conn.execute("ALTER TABLE daily ADD COLUMN exchange TEXT DEFAULT 'SSE/SZSE'")

out = df.reset_index()[["date", "open", "high", "low", "close", "volume"]].copy()
out["code"] = "AAPL"
out["source"] = "eodhd"
out["exchange"] = "US"
out.to_sql("daily", conn, if_exists="append", index=False)
conn.close()

The incremental rule is copied from the AKShare page. Read MAX(date) and set from to the start of the missing stretch. The difference is the clock. The US close is morning in Beijing, so the job runs in the Beijing morning, once yesterday's bar has settled. That is the counterpart of the A-share job at 18:30, after the close.

05 · Pitfalls, continuing the series

Once the table updates itself, the next job is one strategy on the real bars:

Next: a first backtrader strategy →

Still choosing a source? See yfinance, AKShare, OpenBB, and EODHD APIs. That comparison is not this article.

This tutorial is not investment advice. EODHD terms and quotas follow the live site. The link on this page includes this site's affiliate tag.

Frequently asked questions

How to choose EODHD for the same SQLite pipeline?

To put US or global daily bars on the SQLite file you already use for China A-shares, call EODHD and append rows to the daily table from the AKShare walkthrough. After you register, the dashboard gives you an api_token, and every request sends it. The official DEMO token needs no account and only returns AAPL. US symbols take a .US suffix, so Apple is AAPL.US. Hong Kong is .HK. The daily URL is https://eodhd.com/api/eod/AAPL.US with fmt=json, order=d, and from and to. Use adjusted_close for backtest returns and close for the price that traded that day. Add source and exchange to an existing daily table. New rows set source to eodhd and exchange to US. For the next run, set from to the day after MAX(date). The US close is morning in Beijing, so schedule the job for the Beijing morning. China A-shares alone stay on AKShare, which is a different article. Choosing among yfinance, AKShare, OpenBB, and EODHD is a different article. A standalone US pipeline that was run with yfinance or EODHD is also a different article. This page only attaches EODHD daily bars to that existing table.

Who it is for?

Someone who writes a little Python, already stores China A-share daily bars in SQLite the way the AKShare walkthrough does, and wants US or global daily bars in the same file without changing the backtest code. The path is the token, the exchange suffix, close versus adjusted_close, the source and exchange columns, and an incremental job in the Beijing morning.

Who it is not for?

Someone who only trades China A-shares and does not need a formal API contract. AKShare is free and needs no key, so this page is the wrong one. This page is not the tool-order guide, not the site FAQ, and not the comparison of yfinance, AKShare, OpenBB, and EODHD. If you do not yet have the A-share table, start with the AKShare walkthrough. A from-scratch US pipeline is a different article.

When do you need an overseas data source?

AKShare is for China A-shares: free, no registration, and it aggregates public Chinese sources. It does not cover a strategy on US or global markets, and it is not a formal API contract. Aggregated scrapers change. EODHD is a paid source with a REST API for daily and minute bars on major exchanges, plus a free tier you can use to get one symbol through the pipeline. Decide the market first. A-shares only: AKShare is enough. US stocks, Hong Kong, or global indexes: then look at a paid source.

How do the API token and the DEMO token differ?

After registration the dashboard shows api_token. Every request sends it. EODHD also publishes a DEMO token so you can try one call with no account. DEMO only returns AAPL. The free-tier quota is whatever the live site shows. The Chinese walkthrough says a daily incremental update of a single symbol is enough to demo the whole flow on the free tier. A DEMO call that works does not prove your own token can see the same range. Replay the same request with your token before a real run. Paid prices and quotas follow the live site.

What does the first AAPL request return, and how do close and adjusted_close differ?

The Chinese page says the site checked this in August 2026 with the DEMO token. GET https://eodhd.com/api/eod/AAPL.US with api_token, fmt=json, order=d, from=2026-01-01, and to=2026-08-28. order=d puts the newest date first. Sort oldest to newest before you store the frame. A wrong suffix can return an empty array instead of an error. close is the price that traded that day. adjusted_close is rewritten for splits and dividends. Backtest returns use adjusted_close. A historical price level uses close. That is the same split as qfq on the AKShare page.

How does this join the SQLite table from the AKShare walkthrough?

The file is a_daily.db and the table is daily. If source is missing, ALTER TABLE adds source with default akshare and exchange with default SSE/SZSE. The Apple rows keep date, open, high, low, close, and volume, then set code to AAPL, source to eodhd, and exchange to US, and append them. The backtest that already reads daily does not change. The incremental rule is the same as the AKShare page: read MAX(date) and set from to the start of the missing stretch. The US session settles in the Beijing morning, so the job runs then, which is the counterpart of the A-share job at 18:30.

What pitfalls does this walkthrough call out?

Five. A wrong suffix, such as forgetting .US or .HK, can return an empty array and look like success, so the script must assert that the frame is not empty. Backtests stay on adjusted_close. Those prices drift after later dividends, so refresh the stored history every few months, the same rule as qfq. The free-tier quota follows the live site. Sleep between calls and back off after a failure. US holidays are not A-share holidays. Thanksgiving and Independence Day are closed in the US while A-shares can be open, so do not use the A-share calendar to decide that a US day is missing. Store whatever from and to return. And a DEMO success is not a token success.