Turn Daily Market Movers into Actionable Watchlists Using FMP’s API and GPT Intelligence

Photo by Anna Nekrashevich

Every trader has one key goal: identify market movers early. Whether it’s a breakout stock surging by double digits or a falling knife catching attention — gainers and losers often lead the narrative. But manually scanning these daily? Not efficient.

That’s where Financial Modeling Prep’s Gainers & Losers API steps in. It delivers real-time data on stocks with the biggest intraday moves — straight to your code. And when paired with a GPT prompt, this data turns into intelligent watchlists within seconds.

In this article, we’ll show how to:

• Fetch market movers using FMP’s API,

• Process the data using Python,

• And prompt GPT to generate a smart, prioritized watchlist.

No guesswork. Just actionable insight — automated.

Understanding FMP’s Gainers & Losers API

Before we automate watchlist generation, let’s understand the two powerful FMP endpoints we’ll be working with:

1. Top Gainers API

Endpoint:

https://financialmodelingprep.com/api/v3/stock_market/gainers

Purpose:

Fetches stocks with the highest positive price change during the trading day.

Key Data Points Returned:

• Ticker symbol (e.g., AAPL)
• Company name
• Current price
• Price change
• Percentage change

2. Top Losers API

Endpoint:

https://financialmodelingprep.com/api/v3/stock_market/losers

Purpose:

Fetches stocks showing the largest negative price movement.

Key Data Points Returned:

Same structure as the Top Gainers API.

You’ll need a valid FMP API key to access this data. Simply append ?apikey=YOUR_API_KEY to the endpoint URL.

Why These APIs Matter

Instead of relying on noisy news articles or slow manual tracking, these APIs offer:

Real-time insights into fast movers,Structured, machine-readable data,Easy integration into Python workflows.

Fetching and Processing Data with Python

Now that we know what the FMP APIs provide, let’s fetch the data and get it ready for GPT.

Step 1: Install Required Libraries

First, ensure you have these libraries installed:

pip install requests pandas

Step 2: Fetch Gainers and Losers Data

We’ll use Python’s requests library to hit the API and pandas to handle the response.

import requests
import pandas as pd

# Replace with your actual FMP API Key
API_KEY = ‘your_api_key_here’
# API URLs
GAINERS_URL = f”https://financialmodelingprep.com/api/v3/stock_market/gainers?apikey={API_KEY}”
LOSERS_URL = f”https://financialmodelingprep.com/api/v3/stock_market/losers?apikey={API_KEY}”
# Fetch data
gainers_response = requests.get(GAINERS_URL)
losers_response = requests.get(LOSERS_URL)
# Convert to DataFrame
gainers_df = pd.DataFrame(gainers_response.json())
losers_df = pd.DataFrame(losers_response.json())

Step 3: Quick Look at the Data

Let’s check what we received:

print(“Top Gainers:”)
print(gainers_df.head())

print(“nTop Losers:”)
print(losers_df.head())

You’ll see fields like:

• symbol
• name
• price
• changesPercentage
• change

Step 4: Merge and Clean the Data (Optional)

If you want a combined view for GPT input, you can label the stocks and merge them:

gainers_df[‘movement’] = ‘Gainer’
losers_df[‘movement’] = ‘Loser’

# Combine
market_movers_df = pd.concat([gainers_df, losers_df], ignore_index=True)
# Optional: Select only the important columns
market_movers_df = market_movers_df[[‘symbol’, ‘name’, ‘price’, ‘changesPercentage’, ‘movement’]]

Now you have a clean dataset ready for GPT to understand!

Crafting a GPT Prompt for Watchlist Generation

Once we have a clean list of gainers and losers, the next step is to guide GPT to turn this raw data into a smart, curated watchlist.

The key here?

A good prompt = better results.

Step 1: Format the Data for the Prompt

Let’s create a simple text format that GPT can easily understand.

def format_for_prompt(df):
prompt_text = “”
for _, row in df.iterrows():
prompt_text += f”{row[‘symbol’]} ({row[‘name’]}): {row[‘movement’]} with {row[‘changesPercentage’]} changen”
return prompt_text

formatted_data = format_for_prompt(market_movers_df)
print(formatted_data)

This would produce something like:

AAPL (Apple Inc.): Gainer with +3.5% change
TSLA (Tesla Inc.): Loser with -2.1% change

Short, clean, human-readable.

Step 2: Craft the GPT Prompt

Now, embed this formatted data into a clear instruction for GPT:

prompt = f”””
Based on the following stock movements, generate a watchlist of 5 stocks that seem promising for further research.
Consider factors like large gains, recovery potential after losses, or big moves worth monitoring.Stock Movements:
{formatted_data}
Provide the output in a list format, with a one-line reason for each stock selection.
“””

This prompt will nudge GPT to:

Analyze both gainers and losers,Pick 5 candidates intelligently,Give a reason why each stock was selected.

Step 3: Example of GPT Output

Here’s what GPT might return:

1. AAPL (Apple Inc.) – Strong intraday gain indicating potential momentum.
2. AMZN (Amazon.com Inc.) – Sharp recovery after recent losses, worth monitoring.
3. TSLA (Tesla Inc.) – Significant dip, could be a rebound opportunity.
4. NVDA (NVIDIA Corporation) – Continues strong uptrend with consistent gains.
5. MSFT (Microsoft Corp.) – Minor loss despite overall market weakness, shows resilience.

Exactly what you want from a smart watchlist — actionable and concise!

Automating the Workflow

Now that we have all the pieces — data fetching, formatting, and GPT prompt creation — why not automate the entire flow?

Here’s how you can build a simple daily watchlist generator.

Step 1: Full Workflow Script

Here’s a Python script that puts everything together:

import requests
import pandas as pd

# Function to fetch market movers
def fetch_market_movers(api_key):
gainers_url = f”https://financialmodelingprep.com/api/v3/stock_market/gainers?apikey={api_key}”
losers_url = f”https://financialmodelingprep.com/api/v3/stock_market/losers?apikey={api_key}”

gainers = pd.DataFrame(requests.get(gainers_url).json())
losers = pd.DataFrame(requests.get(losers_url).json())

gainers[‘movement’] = ‘Gainer’
losers[‘movement’] = ‘Loser’

combined = pd.concat([gainers, losers], ignore_index=True)
return combined[[‘symbol’, ‘name’, ‘price’, ‘changesPercentage’, ‘movement’]]

# Function to format data for GPT prompt
def format_for_gpt(df):
prompt_text = “”
for _, row in df.iterrows():
prompt_text += f”{row[‘symbol’]} ({row[‘name’]}): {row[‘movement’]} with {row[‘changesPercentage’]} changen”
return prompt_text

# Function to generate final prompt
def create_watchlist_prompt(formatted_data):
return f”””
Based on the following stock movements, generate a watchlist of 5 stocks that seem promising for further research.
Consider factors like large gains, recovery potential after losses, or big moves worth monitoring.
Stock Movements:
{formatted_data}
Provide the output in a list format, with a one-line reason for each stock selection.
“””

# Main
if __name__ == “__main__”:
API_KEY = “your_api_key_here”

market_data = fetch_market_movers(API_KEY)
formatted_text = format_for_gpt(market_data)
final_prompt = create_watchlist_prompt(formatted_text)

print(final_prompt)

This script will:

Pull fresh gainers and losers,Format the data,Generate a ready-to-use prompt for GPT.

Step 2: Optional — Fully Automate It Daily

You can automate this script to run every morning using:

Task Scheduler on Windows,Cron Jobs on Mac/Linux,Cloud functions if you prefer serverless (AWS Lambda, Google Cloud Functions).

You can even extend it to:

Send the prompt to GPT automatically,Email the generated watchlist to yourself,Or save it into a Notion page or a Google Sheet!

In just a few lines of code, you create a personalized, intelligent watchlist generator — without lifting a finger every day.

Free Stock Market API and Financial Statements API…

Conclusion

Building a smart stock watchlist doesn’t have to be manual or time-consuming.

By combining FMP’s Gainers & Losers API with a simple GPT prompt, you can automate watchlist generation based on real-time market movements.

This approach not only saves time but also ensures you’re always aligned with market trends — with just a few lines of code.

Generate a Watchlist from FMP’s Gainers & Losers API Using a GPT Prompt was originally published in Coinmonks on Medium, where people are continuing the conversation by highlighting and responding to this story.

By

Leave a Reply

Your email address will not be published. Required fields are marked *