JA

Checking the difference between the Nikkei 225 and TOPIX with Python

Here is what this post covers:

Introduction

In my previous post, I briefly covered how TOPIX differs from the Nikkei 225. The Nikkei 225 is a price-weighted index, while TOPIX is weighted by free-float market cap. I explained that the Nikkei 225 moves a lot when a stock with a high share price moves just a few percent.

Still, it’s hard to get a feel for how big that difference is from words alone. So this time I wrote a Python script that calculates both kinds of index from five made-up stocks, and checked with actual numbers how much each index changes when share prices move. At the end, I use the results to think about when to use each index.

Note: This post does not recommend buying or selling any particular stock or fund.

Five made-up stocks

To make the difference easy to see, I made up five stocks whose share prices and company sizes are all over the place.

StockShare priceSharesMarket cap
A¥40,000100 million¥4 trillion
B¥10,000200 million¥2 trillion
C¥3,0001 billion¥3 trillion
D¥2,0005 billion¥10 trillion
E¥1,0001 billion¥1 trillion

Market cap is the value of the whole company, calculated as share price × number of shares.

Look at A and D. A has by far the highest share price at ¥40,000, yet its market cap of ¥4 trillion is less than half of D’s. D’s share price is only ¥2,000, but it has so many shares that its market cap of ¥10 trillion is the largest of the five.

A share price is the value of the whole company divided by the number of shares. Two companies of the same size can have very different share prices if one of them has fewer shares. A high share price and a large company are two separate things.

Calculating the price-weighted and market-cap-weighted indexes

Using these five stocks, I calculate one index built the same way as the Nikkei 225 and one built the same way as TOPIX. From here on, I’ll call the price-weighted one the “Nikkei-style” index and the free-float market-cap-weighted one the “TOPIX-style” index. Here is the code.

# Five made-up stocks. name: (share price [yen], shares [100 million])
stocks = {"A": (40000, 1), "B": (10000, 2), "C": (3000, 10), "D": (2000, 50), "E": (1000, 10)}

def nikkei(s):  # Nikkei-style: add up the share prices and divide by the number of stocks
    return sum(price for price, count in s.values()) / len(s)

def topix(s):  # TOPIX-style: add up price x shares (= market cap)
    return sum(price * count for price, count in s.values())

def check(label, changes):  # change some share prices and print how much each index changed
    moved = dict(stocks)  # copy the original table
    for name, rate in changes.items():
        price, count = stocks[name]
        moved[name] = (price * rate, count)  # multiply the price by rate (1.1 = up 10%)
    n = nikkei(moved) / nikkei(stocks) - 1  # change in the Nikkei-style index
    t = topix(moved) / topix(stocks) - 1  # change in the TOPIX-style index
    print(f"{label}: Nikkei-style {n:+.2%} / TOPIX-style {t:+.2%}")

check("A up 10%", {"A": 1.1})
check("D up 10%", {"D": 1.1})
check("A up 10%, D down 10%", {"A": 1.1, "D": 0.9})

I’ll go through it from the top.

The stock data

stocks is a dictionary that maps each stock’s name to a pair of share price and share count. A Python dictionary is a container where you store values under a name. Writing stocks["A"] gives you A’s (40000, 1).

The share count is in units of 100 million shares. That way, price × shares comes out in units of ¥100 million. For example, A is 40,000 × 1 = 40,000 units of ¥100 million, which is ¥4 trillion.

The two index functions: nikkei and topix

The first one, nikkei, calculates the Nikkei-style index. s.values() takes out each stock’s price-and-count pair one by one, adds up only the prices, and divides by the number of stocks, which is 5. The share count isn’t used at all. The prices add up to ¥56,000, so the index comes out at ¥11,200.

The second one, topix, calculates the TOPIX-style index. It works out each stock’s market cap as price × shares and adds them all up. The five market caps add up to ¥20 trillion.

What I want to know is not the index value itself but how many percent it changed. The real indexes’ divisor and base value don’t change when share prices move, so they have no effect on the rate of change.

Both functions are much simpler than the real thing. The real Nikkei 225 divides by a number called the “divisor” rather than by the number of stocks. It also applies a “price adjustment factor” to even out share price levels, which I left out here and just added the prices as they are. The real TOPIX calculates market cap using only the free-float shares, the ones actually traded on the market, and expresses it in points with the market cap on January 4, 1968 set to 100.

The function that changes prices and compares

check changes the share prices of the stocks you specify (1.1 means up 10%) and prints how many percent each index changed. It copies the original table, rewrites only the share prices, and compares the indexes with the ones before the change.

The last three lines try these three cases:

  1. Only A, the stock with the high share price, goes up 10%
  2. Only D, the large company, goes up 10%
  3. A goes up 10% while D goes down 10%

Results

Running it prints the following.

A up 10%: Nikkei-style +7.14% / TOPIX-style +2.00%
D up 10%: Nikkei-style +0.36% / TOPIX-style +5.00%
A up 10%, D down 10%: Nikkei-style +6.79% / TOPIX-style -3.00%

The same 10% rise moves the two indexes in completely different ways.

When A goes up 10%

The Nikkei-style index rose 7.14%, while the TOPIX-style index rose only 2.00%.

The gap comes from how much of each index A makes up. The Nikkei-style index is built by adding up prices, so each stock’s share of it is “price ÷ total of prices”. The TOPIX-style index is built by adding up market caps, so each stock’s share is “market cap ÷ total market cap”.

StockShare of the Nikkei-style indexShare of the TOPIX-style index
A71.4%20.0%
B17.9%10.0%
C5.4%15.0%
D3.6%50.0%
E1.8%5.0%

In the Nikkei-style index, A accounts for ¥40,000 of the ¥56,000 total, so its share is 71.4%. In the TOPIX-style index, A is ¥4 trillion out of ¥20 trillion, so its share is 20%.

An index’s rate of change is the stock’s share of the index × the stock’s rate of change. For A, that’s 71.4% × 10% = 7.14% for the Nikkei-style index and 20% × 10% = 2% for the TOPIX-style index. Both match what the script printed.

When D goes up 10%

This time it’s the other way around. The Nikkei-style index rose only 0.36%, while the TOPIX-style index rose 5.00%.

D has the largest market cap of the five, so it makes up half of the TOPIX-style index at 50%. Its share price is a cheap ¥2,000, though, so it is only 3.6% of the Nikkei-style index. Even when the largest company rises 10%, the Nikkei-style index barely moves.

When A goes up and D goes down

The Nikkei-style index rose 6.79%, while the TOPIX-style index fell 3.00%. Both indexes are built from the same five stocks, yet they don’t even agree on the direction.

In the Nikkei-style index, A’s price goes up ¥4,000 and D’s price goes down ¥200. The total of prices grows by ¥3,800, so the index rises 3,800 ÷ 56,000 = 6.79%. In the TOPIX-style index, A’s market cap grows by ¥400 billion and D’s shrinks by ¥1 trillion. The total shrinks by ¥600 billion, so the index falls 600 billion ÷ 20 trillion = 3%.

The three results side by side

Here are the three results in one chart. The darker bars are the Nikkei-style index and the lighter bars are the TOPIX-style index.

Horizontal bar chart comparing how much each index changed in the three cases. A up 10%: Nikkei-style +7.14%, TOPIX-style +2.00%. D up 10%: Nikkei-style +0.36%, TOPIX-style +5.00%. A up 10%, D down 10%: Nikkei-style +6.79%, TOPIX-style −3.00% Change in each index A up 10% Nikkei-style +7.14% TOPIX-style +2.00% D up 10% Nikkei-style +0.36% TOPIX-style +5.00% A up 10%, D down 10% Nikkei-style +6.79% TOPIX-style −3.00% 0%

When A, the stock with the high share price, moves, the Nikkei-style index moves a lot. When D, the large company, moves, the TOPIX-style index moves a lot. When A and D move in opposite directions, the two indexes split in direction too.

Applying this calculation to the real Nikkei 225 and TOPIX

The “share × rate of change” calculation works for the real indexes too.

In the previous post, I mentioned that Advantest makes up 11.1% of the Nikkei 225. That figure is the holding weight of a fund that tracks the Nikkei 225, as of June 30, 2026. If Advantest’s share price goes up 10%, that alone lifts the Nikkei 225 by about 1.1%. Based on the October 7, 2026 close of ¥70,035.71, that’s about ¥780.

Mitsubishi UFJ Financial Group, the largest weight in TOPIX, makes up 3.5%. Even if its share price goes up 10%, TOPIX rises only about 0.35%.

The weights change every time share prices move, so this is only a rough estimate. Still, when the Nikkei 225 makes a big move in the news, it helps you guess which stocks moved it and by how much.

How to use each index

Based on these results, here is how I think about using each index.

If you invest in one

Buying a fund or ETF that tracks the Nikkei 225 means putting a lot of your money into a small number of stocks with high share prices. Each stock’s weight in the Nikkei 225 is decided by how high its share price is, not by how large the company is or how well it is doing. Right now, the top four stocks, centered on semiconductors, make up about 40% of the Nikkei 225. It suits people who want a big piece of those stocks’ gains and don’t mind larger swings.

Buying a fund or ETF that tracks TOPIX means investing broadly across Japanese stocks, in proportion to company size. Even the top four stocks together make up only about 10%, and they’re spread across sectors such as banks and automakers. It suits people who want to invest in Japanese stocks as a whole without leaning toward a particular sector or stock.

If you watch one as a market indicator

The Nikkei 225 strongly reflects stocks with high share prices, which right now means semiconductor stocks. TOPIX reflects Japanese stocks as a whole.

When the news says “the Nikkei 225 jumped,” it’s worth checking TOPIX too. If TOPIX rose by about as much, Japanese stocks as a whole went up. If only the Nikkei 225 rose, the gain may be limited to a few high-priced stocks, and many other stocks may have barely moved or even fallen. That’s the same situation as the third case in the script. If the NT ratio (Nikkei 225 ÷ TOPIX) is rising, you can read it as that gap widening.

Wrapping up

With five made-up stocks, the same 10% rise moved the two indexes very differently. When A, the stock with the high share price, rose 10%, the Nikkei-style index rose 7.14% and the TOPIX-style index 2%. When D, the large company, rose 10%, the numbers were 0.36% and 5%. When A and D moved in opposite directions, the two indexes moved in opposite directions too.

An index’s rate of change is the stock’s share of the index multiplied by the stock’s own rate of change. In the Nikkei 225, that share is set by how high the share price is, and in TOPIX by how large the company is, so the same stock move has a different effect on each index.

The news mostly reports the Nikkei 225, but when you want to know how Japanese stocks are doing as a whole, looking at TOPIX as well gives you a clearer picture.

References