First of all you should know that sawm of Ramadan or fast in Ramadan or generally in Islam means abstaining, usually from food, drink, and sexual activity during the day one intends to fast.
So you can have sexual activity between maghreb and fajr. And of course you can eat and drink during this time.
Secondly according to the majority view masturbation is regarded as haram (I've shared the major evidence for that in: Is hands free masturbation worse or the same as with hands?). However it is also regarded as rather makruh by prominent scholars like ibn Hazm (who quoted some mostly weak evidences on the topic), ibn Taymiyyah and imam Ahmad and therefore it can be permitted under certain conditions because masturbation at least is better than committing adultery. Therefore some hanafi and hanbali scholars permitted it in case of fear of committing zina.
Thirdly if you didn't ejaculate while masturbating directly or soon afterwards you are not required to perform ghusl and therefore your fast wouldn't be broken.
As you are aware that you are not able to afford the kaffarah for invalidating your fast intentionally, you should avoid such bad habits. And you must repent for what you've done especially if you've done this by day time!
The following is an advice and as such it is not the standard for stackexchange since we avoid giving advice! Start by today to avoid masturbating during the day time totally, if possible since the last 10 days of Ramadan started avoid it also on the nights or reduce the frequency to the maximum possible. And for the future try step by step to increase the time intervals between the individual acts of masturbation till you get married then you should be able to avoid it totally. Of course it might be necessary to find the reasons and triggers for your addiction and try to eliminate them one by one.
Else see also:
What does someone have to do if he/she masturbate while in fast state during Ramadan?