Sigh, I thinks most writers have been told to write to the market. To train yourself by reading other books, books in your genre and out, books that are loved by reading groups and book clubs, books that win awards!
It's not a bad strategy in many regards. Writers must read. And studying the market is a plus, just as long as you add to that approach, the realization that you need to write to your strengths as well.
Hopefully when you do it will all coalesce and you will be able to write to an audience you love where you can display your writing strengths and really pull a rabbit out of a hat.
But, if that magic combination doesn't happen, then I strongly recommend you reconsider and direct your efforts to writing what you write best - THEN find your market.
It's true, "the market" can be a good thing, but just as true is the fact that markets can dry up, what was popular yesterday could well be defunct today. In other words, "the market" can crash.
So, how to ensure you're not writing to a dying market? First, nothing is a 100% guarantee. Sorry, just doesn't exist.
Next, remember 'the market' is in constant change. Elements come and go. Genres add back corners and subgenres. Yes, you need to be aware of the market, to track it, to constantly evaluate where your work fits in. To be aware of current market favorites and to be able to edit your book to fit current trends. Can a setting be changed, rural to urban, can the hero or heroine's job be transformed from one field to another? Can your narration be shifted from first to third or third to first? Can you add a sidekick, or another character to breathe more life into your plot?
But all the while, and I'll admit this sounds like I'm being contrary here, the most important thing is that the author remain fixed on his or her own voice and vision. Trends come and go. The 'hot' market fades and something else surges to the fore.
Instead of following the crowd wouldn't it be much better to be the writer who's writing what you love, telling your story with the greatest zeal, creating a new path, perhaps a new genre or subgenre?
Success is not guaranteed by that route either. Not every new idea, every new leading edge created out of enthusiasm and passion will sell. But the writer (unless a superstar) is not guaranteed a sale by writing to the market either.
Balance is what is needed. Awareness, familiarity with what's churning through the market, coupled with what you love to write will tip the odds in your favor.