Linear response theory relates the response of a system to a weak external force with its dynamics in equilibrium, subjected to fluctuations. Here, this framework is applied to financial markets; in particular we study the dynamics of a set of stocks from the NASDAQ during the last 20 years. Because unambiguous identification of external forces is not possible, critical events are identified in the series of stock prices as sudden changes, and the stock dynamics following an event is taken as the response to the external force. Linear response theory is applied with the log-return as the conjugate variable of the force, providing predictions for the average response of the price and return, which agree with observations, but fails to describe the volatility because this is expected to be beyond linear response. The identification of the conjugate variable allows us to define the perturbation energy for a system of stocks, and observe its relaxation after an event.