Amid the wreckage of Japan's stock market in 2016 lies a surprise: Smaller companies are posting their best relative performance on record.

The Topix Small Index, overlooked by foreign investors and full of companies that make most of their sales within Japan, is near the highest level versus the Topix Core 30 Index of heavyweights in records going back to 1989. While the small-cap gauge is down 8.4 percent this year as a selloff emanating from China ripples through markets around the world, that is less than the broadest Topix index's 9 percent drop. In the U.S., the opposite is happening: The Russell 2000 Index just entered a bear market and is trading at the lowest relative to the Standard & Poor's 500 Index in six years.

Japanese investors have reasons to favor smaller companies. China is the nation's largest trading partner and the yuan fell more against the yen than any other major currency last week, weighing on Tokyo's giant exporters and leaving stock traders looking for alternatives.