This doesn’t explain everything in detail (particularly the rolling average part) but it’s good place to start.
Mike