Believe it or not, this is a tricky answer. I've admitted on more than one occasion that I'm all about being a working writer. For that to be a reality, I have to think not just about the story I want to tell but also if there happens to be a market for my choice. Writing for your editor, IMHO, is a given. They are the gate keepers between you and the manuscript becoming a book.
I'm also a 'run it past them' kinda person. I always stick my toe in the surf before I actually put fingertips to keyboard. Why? I believe in synchronicity. Two people working independently can come up with the same/similar idea. Early in my career I submitted a proposal and the response was - "Love it! But we just bought books about three men who meet in a bar and . . .." No sale for me even thought there wasn't a thing wrong with the proposal - hence the reason I send up a test balloon.
I've written things specifically for editors (continuity series/novellas) and I personally find them harder to write that anything else. Why? You aren't given a plot, you're given a few elements to toss into your story. Well, some plot points are easier to incorporate than others. Plus, you're writing blind. I was books 4 and 8 in a 12 book series for Harlequin and by the time I turned in book 8, I was informed one of the earlier authors had killed off one of the predominant characters in my story (whoops, no one thought to tell me) so I had to do a rewrite. Did I do them - you betcha. Why? . . .
What's the only difference between an author and an aspiring author? An author gets paid. I rewrote the story for the check. This isn't a hobby folks, this is how I earn my living.
Let me also touch on the whole 'muse' thing. First, could we not take ourselves so seriously? We're writing books to entertain, not finding a cure for AIDS. If you can't write until you hear 'the muse,' then chances are you won't be able to write to deadline. Trust me, there's no contract clause that reads, . . . "Author agrees to turn book in on August 31st so long as she's following her muse."
Having said all that - NEVER write to the market. You'll only end up being the caboose - you don't want to be the south end of a northern facing train. Remember, what you see on the shelves now was written and purchased 18-24 months ago. In that time, the publisher has gotten enough ware-rabbit stories to fill inventory. (Yes, that was a joke).
So, whenever possible, love your project. If you can't love your project, love the process. If you can't love the project or the process, then love the paycheck.