Is There Expiation for Anal Intercourse while Fasting?
Question

I committed the shameful deed of the people of Lut during one of the days of Ramadan. I have repented from this action, praise be to Allah, and I have resolved to offer expiation by fasting for two consecutive months. Please note that I am able to feed the poor, but I prefer to fast rather than feed the poor. I started to fast, and on the fifteenth day, my desire overtook me when I was on my own, and I masturbated, then I broke the fast [by eating] on that day. The following day, I carried on from the days that I had already fasted, with the aim of completing the expiation by fasting for two consecutive months. But for a second time I masturbated whilst I was fasting. But this time I did not break the fast [by eating]. I wanted to push myself to complete the fast of two consecutive months as an act of repentance to Allah for the grave sin that I committed. I hope that you can advise me on the ruling regarding what I have done, and what expiation I should offer.
Praise be to Allah.Is anal sex while permissible?
Anal intercourse is a grave evil, a major sin and a repulsive shameful deed. The fact that you did it in Ramadan makes its sinfulness even more serious. What you must do is repent to Allah, may He be exalted, and make up for that day, as well as offer expiation.
Ibn Qudamah (may Allah have mercy on him) said: 
“The expiation (kaffarah) becomes a binding obligation upon one who has intercourse in the front or back passage in Ramadan deliberately, whether he ejaculates or not, according to the view of the majority of scholars.
Then he said: It makes no difference whether it is in the front or back passage, of a male or female. This was stated by ash-Shafi'i.” (Al-Mughni (3/60) (See also: al-Mawsu‘ah al-Fiqhiyyah, 35/55)
Expiation for anal intercourse while fasting
The expiation for anal intercourse while fasting is to free a slave. If that is not possible, then he must fast for two consecutive months. If he cannot do that, then he must feed sixty poor persons. It is not permissible to choose the option of feeding the poor for one who is able to fast, according to the majority of jurists.
Evidence for the obligation to offer expiation for anal intercourse while fasting
The evidence for that is the report narrated by al-Bukhari (1936) from Abu Hurayrah (may Allah be pleased with him) who said: Whilst we were sitting with the Prophet (peace and blessings of Allah be upon him), a man came to him and said: O Messenger of Allah, I am doomed! He said: “What is the matter with you?” He said: I had intercourse with my wife whilst I was fasting. The Messenger of Allah (peace and blessings of Allah be upon him) asked: “Can you afford to free a slave?” He said: No. He said: “Are you able to fast for two consecutive months?” He said: No. He said: “Can you afford to feed sixty poor persons?” he said: No. The Prophet (blessings and peace of Allah be upon him) paused for a while, and whilst we were like that, a large basket of dates was brought to the Prophet (blessings and peace of Allah be upon him). He said: “Where is the one who was asking?” The man said: I am here. He said: “Take it and give it in charity.” The man said: To someone poorer than me, O Messenger of Allah? By Allah, there is no family between the two lava fields [i.e., in Madinah] who is poorer than my family. The Prophet (blessings and peace of Allah be upon him) smiled so broadly that his eye-teeth became visible, then he said: “Feed your family with it.”
Is masturbation haram?
Masturbation – which is the deliberate emission of maniy – is haram; the prohibition is more emphatic if it is done whilst fasting , because it renders the fast invalid. But the one who does that does not have to offer expiation according to the view of ash-Shafi'i and Ahmad.
Masturbation also interrupts the sequence of fasts being observed consecutively; this also applies to anyone who deliberately breaks the fast without a valid excuse.
Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) said: 
“If he breaks the fast due to a valid excuse which makes it permissible for him to do so, such as sickness or travel, then this does not interrupt the sequence of fasts being observed consecutively. If it so happens that this man who started to fast two consecutive months – whether it is expiation for zihar [a jahili form of divorce in which a man says to his wife, you are to me as my mother’s back], or expiation for having intercourse during the day in Ramadan, or expiation for murder – travels and breaks the fast, that does not interrupt the sequence of his consecutive fasts, because travelling makes it permissible to break the fast. But if he uses travel as a trick or loophole to let him break the fast, we say to him: It is not permissible for you to do that, and you must continue with your fast, because obligatory duties cannot be waived by means of tricks and loopholes, and if you do that [and break your fast] you must start the two-month fast all over again.” (Ash-Sharh al-Mumti‘, 13/273)
With regard to what you said about not breaking the fast the second time, it does not make sense, because masturbation breaks the fast .
Hence you must fast for a further two consecutive months, as well as repent to Allah, may He be exalted, from the shameful deed and from masturbation.
Please understand that the gate of repentance is open , and that Allah, may He be exalted, rejoices over the repentance of His slave and forgives sins, no matter how great they are.
So think positively of Allah, turn to Him, humble yourself before Him, beseech Him in your supplication [du‘a], and ask Him to purify your heart and divert evil and shameful deeds from you, and to make you one of His righteous slaves.
And Allah knows best.