Publishers and producers tend to favor books and scripts that have a happy ending, but that doesn't mean it has to be soppy. Here's what novelist Celia Ahern ("P.S. I Love You") said about that in an interview with The Bookseller (July 2012):
I suppose I start them in such a dark place and I want to bring them to a light, positive place. Even when I write about something sad I want to inject it with humour. I do always want to bring things to a good, honest, positive place realistically without being sweetie and saccharine and all that.
While I want positive endings, I don't want conventional happy endings. I just want the character to wake up and feel hopeful that they can face the day. To me that's a happy ending.
Ultimately, of course, it's the rest of the story that will determine whether or not you have a happy ending, but I think her definition gives us all a lot of leeway.