Generally, fiction is based in fantasy.
There are cases in which authors take inspiration from real life, real characters o facts, but these books are mainly a made up story that get real only in book.
Fantasy is a genre of speculative fiction set in a fictional universe, often without any locations, events, or people referencing the real world.