Skip to content

Add Google Financial News Prompt Generator Script#47

Open
ewdlop wants to merge 1 commit intomainfrom
generate-news-prompt-8982088012019191763
Open

Add Google Financial News Prompt Generator Script#47
ewdlop wants to merge 1 commit intomainfrom
generate-news-prompt-8982088012019191763

Conversation

@ewdlop
Copy link
Owner

@ewdlop ewdlop commented Feb 4, 2026

Implemented a Python script Finance/generate_news_prompt.py that generates a structured prompt for Google Financial News analysis. The script accepts command-line arguments for keyword, time range, region, and focus area.
Added a corresponding unit test file Finance/test_generate_news_prompt.py to ensure the correct generation of the prompt.
Cleaned up __pycache__ to ensure a clean commit.


PR created automatically by Jules for task 8982088012019191763 started by @ewdlop

This script generates a standardized 'Google Financial News Analysis' prompt based on user inputs (keyword, time range, region, focus). It is self-contained and includes the prompt template.
Also added Finance/test_generate_news_prompt.py to verify the script's functionality.

Co-authored-by: ewdlop <25368970+ewdlop@users.noreply.github.com>
@google-labs-jules
Copy link
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings February 4, 2026 04:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a small CLI-driven Python utility to generate a structured “Google Financial News” analysis prompt, along with a basic unit test module to validate prompt generation.

Changes:

  • Added Finance/generate_news_prompt.py to generate and print a parameterized financial-news analysis prompt via argparse.
  • Added Finance/test_generate_news_prompt.py with unittest coverage for key prompt sections and parameter interpolation.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
Finance/generate_news_prompt.py New prompt generator script with CLI args for keyword/time range/region/focus.
Finance/test_generate_news_prompt.py New unit tests validating generated prompt content and parameter substitution.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,111 @@
import argparse
import sys
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sys is imported but never used in this module. Please remove the unused import to avoid lint/test failures in stricter environments.

Suggested change
import sys

Copilot uses AI. Check for mistakes.
Comment on lines +3 to +50

def generate_prompt(keyword, time_range, region, focus):
template = """以下是一個**可直接使用的「Google 財經新聞(Google Financial News)Prompt」**,專門用於要求 AI **彙整、摘要、分析與風險判讀**近期財經新聞。整體風格偏向**專業、可審計、偏事實導向**,避免情緒與投資承諾。

---

## 📌 Google 財經新聞分析 Prompt(專業版)

**角色設定(Role)**
你是一名**中立的財經新聞分析師(Financial News Analyst)**,專門彙整並解析來自

* Google News(財經相關新聞)
* 主要國際媒體(Reuters、Bloomberg、WSJ、FT 等)

你的任務不是預測市場,而是**萃取資訊、辨識風險、區分事實與觀點**。

---

**任務(Task)**
請根據近期的 Google 財經新聞,針對指定主題進行**結構化摘要與風險解讀**。

> 📥【輸入參數】
>
> * 查詢關鍵字:`{keyword}`
> * 時間範圍:`{time_range}`
> * 地區(可選):`{region}`
> * 關注面向:`{focus}`

---

## 📊 輸出結構(必須遵守)

### 1️⃣ 新聞總覽(News Overview)

* 主要新聞事件(不超過 5 則)
* 每則以 **一句話摘要**
* 標註新聞性質:

* 事實報導(Fact)
* 市場解讀(Market Interpretation)
* 意見 / 評論(Opinion)

---

### 2️⃣ 關鍵資訊整理(Key Facts)

* 發生了什麼事
* 影響對象(公司 / 產業 / 市場)
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prompt template content here appears to be a near-verbatim duplicate of Finance/financial_news_prompt.md (e.g., that file lines 1–90). Keeping two sources of truth makes future edits error-prone. Consider loading the template from the existing markdown file (and only substituting the 4 parameters), or otherwise consolidating so the prompt text is defined in exactly one place.

Suggested change
def generate_prompt(keyword, time_range, region, focus):
template = """以下是一個**可直接使用的Google 財經新聞Google Financial NewsPrompt**專門用於要求 AI **彙整摘要分析與風險判讀**近期財經新聞整體風格偏向**專業可審計偏事實導向**避免情緒與投資承諾
---
## 📌 Google 財經新聞分析 Prompt(專業版)
**角色設定Role**
你是一名**中立的財經新聞分析師Financial News Analyst**專門彙整並解析來自
* Google News財經相關新聞
* 主要國際媒體ReutersBloombergWSJFT
你的任務不是預測市場而是**萃取資訊辨識風險區分事實與觀點**
---
**任務Task**
請根據近期的 Google 財經新聞針對指定主題進行**結構化摘要與風險解讀**
> 📥【輸入參數
>
> * 查詢關鍵字`{keyword}`
> * 時間範圍`{time_range}`
> * 地區可選):`{region}`
> * 關注面向`{focus}`
---
## 📊 輸出結構(必須遵守)
### 1️⃣ 新聞總覽(News Overview)
* 主要新聞事件不超過 5
* 每則以 **一句話摘要**
* 標註新聞性質
* 事實報導Fact
* 市場解讀Market Interpretation
* 意見 / 評論Opinion
---
### 2️⃣ 關鍵資訊整理(Key Facts)
* 發生了什麼事
* 影響對象公司 / 產業 / 市場
from pathlib import Path
def generate_prompt(keyword, time_range, region, focus):
"""
Generate a financial news analysis prompt by loading the template from
'financial_news_prompt.md' and substituting the provided parameters.
"""
template_path = Path(__file__).with_name("financial_news_prompt.md")
template = template_path.read_text(encoding="utf-8")
return template.format(
keyword=keyword,
time_range=time_range,
region=region,
focus=focus,
)

Copilot uses AI. Check for mistakes.
Comment on lines +2 to +9
import sys
import os

# Add the directory containing the script to sys.path
sys.path.append(os.path.dirname(os.path.abspath(__file__)))

from generate_news_prompt import generate_prompt

Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test mutates sys.path at import time to make generate_news_prompt importable. This can cause test-order dependent behavior and accidental imports if another module with the same name exists on the path. Prefer making Finance/ a proper package (add __init__.py) and importing via from Finance.generate_news_prompt import generate_prompt, or use a local relative import strategy that doesn't modify global sys.path.

Suggested change
import sys
import os
# Add the directory containing the script to sys.path
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from generate_news_prompt import generate_prompt
import os
import importlib.util
import pathlib
# Load generate_news_prompt from the same directory without modifying sys.path
_module_name = "generate_news_prompt"
_module_path = pathlib.Path(os.path.abspath(__file__)).with_name(f"{_module_name}.py")
_spec = importlib.util.spec_from_file_location(_module_name, _module_path)
_module = importlib.util.module_from_spec(_spec)
assert _spec is not None and _spec.loader is not None
_spec.loader.exec_module(_module)
generate_prompt = _module.generate_prompt

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +12
def test_generate_prompt_defaults(self):
# Test with just the keyword, mimicking default args for others
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_generate_prompt_defaults (and its inline comment) says it tests defaults / "just the keyword", but it currently passes all four arguments explicitly. Either rename/update the comment to match what’s being tested, or adjust generate_prompt to provide defaults and call it with only the keyword to actually exercise default behavior.

Suggested change
def test_generate_prompt_defaults(self):
# Test with just the keyword, mimicking default args for others
def test_generate_prompt_basic(self):
# Test with a standard set of arguments

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants