I'm so incredibly sorry for your loss. My heart aches just at the thought of a loss so late, never mind actually going through it. I'm sure the pain must be unimaginable.
Please, give yourself a break. It's ok to grieve, it doesn't make you a terrible person to feel resentment at your cousin's good luck. Our dream gender is just that, our dreams....and coming close and losing it must be so incredibly hard to deal with.
I echo that I hope you can continue to get therapy/counselling to deal with your loss and have some closure. Time and distance will help eventually.
I hope your family is understanding. You are NOT a terrible person, you are an injured and grieving one and that's perfectly okay. Remember that you can think anything you want, you can't control your thoughts, but you can control your actions. As long as you refrain from saying anything resentful or nasty to your cousin, you're doing fine. Is this celebratory stuff on FB? If so, it's probably better for you to just back off FB or block your cousin/family's pages for awhile. Try to remind yourself that your cousin doesn't mean ill-will towards you nor does she intend to rub your face in it, I'm sure, it's just natural for her to celebrate her own good news. Which hurts like hell for you I know. :(
I'm reminded of a Sex and the City episode, the episode where Charlotte finally gets pregnant, but tragically miscarries right on the eve of Miranda's baby's first birthday party. That episode always makes me cry.
Hugs to you, and I hope you'll feel better soon and excited about your own new baby! Hormones are some crazy sh!t too, don't discount the effect they can have on your emotions.