How automatic handicap is calculated?

My understanding is very limited. But I think the game API data includes the rank at the end of the game (and this is what is displayed in the player cards forever after), before it is adjusted based on the result of the game.