Context. Extremely large telescopes are overwhelmingly equipped with pyramid wavefront sensors (PyWFS) over the more widely used Shack-Hartmann wavefront sensor (SHWFS) to perform their single-conjugate adaptive optics (SCAO) mode. The PyWFS, a sensor based on Fourier filtering, has proven to be highly successful in many astronomy applications. However, this sensor exhibits non-linear behaviours that lead to a reduction of the sensitivity of the instrument when working with non-zero residual wavefronts. This so-called optical gains (OG) effect, degrades the closed-loop performance of SCAO systems and prevents accurate correction of non-common path aberrations (NCPA). Aims. In this paper, we aim to compute the OG using a fast and agile strategy to control PyWFS measurements in adaptive optics closed-loop systems. Methods. Using a novel theoretical description of PyWFS, which is based on a convolutional model, we are able to analytically predict the behaviour of the PyWFS in closed-loop operation. This model enables us to explore the impact of residual wavefront errors on particular aspects such as sensitivity and associated OG. The proposed method relies on the knowledge of the residual wavefront statistics and enables automatic estimation of the current OG. End-to-end numerical simulations are used to validate our predictions and test the relevance of our approach. Results. We demonstrate, using on non-invasive strategy, that our method provides an accurate estimation of the OG. The model itself only requires adaptive optics telemetry data to derive statistical information on atmospheric turbulence. Furthermore, we show that by only using an estimation of the current Fried parameter r 0 and the basic system-level characteristics, OGs can be estimated with an accuracy of less than 10%. Finally, we highlight the importance of OG estimation in the case of NCPA compensation. The proposed method is applied to the PyWFS. However, it remains valid for any wavefront sensor based on Fourier filtering subject from OG variations.