# Keras Custom loss Penalize more when actual and prediction are on opposite sides of Zero

I'm training a model to predict percentage change in prices. Both MSE and RMSE are giving me up to 99% accuracy but when I check how often both actual and prediction are pointing in the same direction ((actual >0 and pred > 0) or (actual < 0 and pred < 0)), I get about 49%.

Please how do I define a custom loss that penalizes opposite directions very heavily. I'd also like to add a slight penalty for when the predictions exceeds the actual in a given direction.

So

• actual = 0.1 and pred = -0.05 should be penalized a lot more than actual = 0.1 and pred = 0.05,
• and actual = 0.1 and pred = 0.15 slightly more penalty than actual = 0.1 and pred = 0.05

Thank you guys!