How are Clash of Code points calculated?

I know CG keeps secret the details of its algorithm for winning/losing points, and I’m fine with that.

What bothers me, though, is that I run several times into situations where I end up 1st in a Clash and still lose points. I mean, even if all opponents have a significantly lower rank than me, I guess I should win 0.01 point or even 0 instead of losing some?

It’s already frustrating to need to be 1st to simply consider winning points (goddammit, if I end up 2nd I always lose a lot of points no matter what, even if the winner had a higher rank than me) so if ending up 1st is not even enough, I don’t know what to do.