Initially I was trying to show that if $f(B_t)$ is a martingale where $(B_t)_{t \leq 0}$ is standard Brownian motion then $f$ is an affine transformation
After using Doob's optional stopping theorem with the following stopping time : $$T = \inf \{t \geq 0 \, | \, B_t \in \mathbb{R} -(a,b) \}$$ I ended up with the following equation : $$bf(a) - af(b) = (b - a)f(0)$$
I did check that in fact $ f \text{ is an affine transformation } \implies bf(a) - af(b) = (b - a)f(0) $
but I couldn't do the other direction.
The converse is in fact true.
Define $g(x) = f(x) - f(0)$, so that $g(0) = 0$. Now, showing that $f$ is affine is the same as showing that $g$ is linear. Also, the condition on $f$ can be rewritten as $$b(f(a) - f(0)) - a(f(b) - f(0)) = 0 \iff bg(a) - ag(b) = 0 \qquad \forall \: a \le 0 \le b.$$ Assuming $a, \: b \ne 0$ one can divide by $ab$ and write $$\frac{g(a)}{a} = \frac{g(b)}{b} \qquad \forall \: a < 0 < b,$$ which says that $\frac{g(x)}{x}$ must be constant over $\mathbb{R} \setminus \{0\}$. This, together with $g(0) = 0$, implies that $g(x) = cx$ for some constant $c$.