This paper applies sign restrictions to identify oil structural shocks by imposing nonzero restrictions on the short-term price elasticity of oil supply. With the help of oil inventory data, flow supply, flow demand and speculative demand shocks in the global oil market are identified. Then, the impact of different kinds of oil price shocks on fluctuations of the U.S. and Chinese stock markets is examined and some insights from the perspective of frequency domain are provided. We observe that the U.S. and Chinese stock markets are extensively influenced by the three types of oil structural shocks. In particular, oil price shocks induced by speculation can significantly affect the performance of stock markets in both countries. Under the frequency domain, we notice that the flow demand shock is the most important driver of the variance in U.S. and Chinese stock returns and volatility, particularly at low and business cycle frequencies. Meanwhile, we note that short-term fluctuations in Chinese stock market returns and volatility are more vulnerable to speculative demand shocks. These analysis results are not only useful for policymakers to take targeted measures to deal with the impact of oil price shocks on the stock market, but also useful for investors to adjust their stock portfolios to achieve excess returns.