[add] Speak in Korean prompt
This commit is contained in:
parent
7de2592ab2
commit
fa08b2c176
|
|
@ -47,7 +47,7 @@ Volume-Based Indicators:
|
|||
- vwma: VWMA: A moving average weighted by volume. Usage: Confirm trends by integrating price action with volume data. Tips: Watch for skewed results from volume spikes; use in combination with other volume analyses.
|
||||
|
||||
- Select indicators that provide diverse and complementary information. Avoid redundancy (e.g., do not select both rsi and stochrsi). Also briefly explain why they are suitable for the given market context. When you tool call, please use the exact name of the indicators provided above as they are defined parameters, otherwise your call will fail. Please make sure to call get_YFin_data first to retrieve the CSV that is needed to generate indicators. Write a very detailed and nuanced report of the trends you observe. Do not simply state the trends are mixed, provide detailed and finegrained analysis and insights that may help traders make decisions."""
|
||||
+ """ Make sure to append a Markdown table at the end of the report to organize key points in the report, organized and easy to read."""
|
||||
+ """ Make sure to append a Markdown table at the end of the report to organize key points in the report, organized and easy to read. Please write all responses in Korean."""
|
||||
)
|
||||
|
||||
prompt = ChatPromptTemplate.from_messages(
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ def create_news_analyst(llm, toolkit):
|
|||
|
||||
system_message = (
|
||||
"You are a news researcher tasked with analyzing recent news and trends over the past week. Please write a comprehensive report of the current state of the world that is relevant for trading and macroeconomics. Look at news from EODHD, and finnhub to be comprehensive. Do not simply state the trends are mixed, provide detailed and finegrained analysis and insights that may help traders make decisions."
|
||||
+ """ Make sure to append a Makrdown table at the end of the report to organize key points in the report, organized and easy to read."""
|
||||
+ """ Make sure to append a Makrdown table at the end of the report to organize key points in the report, organized and easy to read. Please write all responses in Korean."""
|
||||
)
|
||||
|
||||
prompt = ChatPromptTemplate.from_messages(
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ Here are your past reflections on mistakes:
|
|||
|
||||
Here is the debate:
|
||||
Debate History:
|
||||
{history}"""
|
||||
{history}
|
||||
|
||||
Please write all responses in Korean."""
|
||||
response = llm.invoke(prompt)
|
||||
|
||||
new_investment_debate_state = {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Deliverables:
|
|||
|
||||
---
|
||||
|
||||
Focus on actionable insights and continuous improvement. Build on past lessons, critically evaluate all perspectives, and ensure each decision advances better outcomes."""
|
||||
Focus on actionable insights and continuous improvement. Build on past lessons, critically evaluate all perspectives, and ensure each decision advances better outcomes. Please write all responses in Korean."""
|
||||
|
||||
response = llm.invoke(prompt)
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ Company fundamentals report: {fundamentals_report}
|
|||
Conversation history of the debate: {history}
|
||||
Last bull argument: {current_response}
|
||||
Reflections from similar situations and lessons learned: {past_memory_str}
|
||||
Use this information to deliver a compelling bear argument, refute the bull's claims, and engage in a dynamic debate that demonstrates the risks and weaknesses of investing in the stock. You must also address reflections and learn from lessons and mistakes you made in the past.
|
||||
Use this information to deliver a compelling bear argument, refute the bull's claims, and engage in a dynamic debate that demonstrates the risks and weaknesses of investing in the stock. You must also address reflections and learn from lessons and mistakes you made in the past. Please write all responses in Korean.
|
||||
"""
|
||||
|
||||
response = llm.invoke(prompt)
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Company fundamentals report: {fundamentals_report}
|
|||
Conversation history of the debate: {history}
|
||||
Last bear argument: {current_response}
|
||||
Reflections from similar situations and lessons learned: {past_memory_str}
|
||||
Use this information to deliver a compelling bull argument, refute the bear's concerns, and engage in a dynamic debate that demonstrates the strengths of the bull position. You must also address reflections and learn from lessons and mistakes you made in the past.
|
||||
Use this information to deliver a compelling bull argument, refute the bear's concerns, and engage in a dynamic debate that demonstrates the strengths of the bull position. You must also address reflections and learn from lessons and mistakes you made in the past. Please write all responses in Korean.
|
||||
"""
|
||||
|
||||
response = llm.invoke(prompt)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ Latest World Affairs Report: {news_report}
|
|||
Company Fundamentals Report: {fundamentals_report}
|
||||
Here is the current conversation history: {history} Here are the last arguments from the conservative analyst: {current_safe_response} Here are the last arguments from the neutral analyst: {current_neutral_response}. If there are no responses from the other viewpoints, do not halluncinate and just present your point.
|
||||
|
||||
Engage actively by addressing any specific concerns raised, refuting the weaknesses in their logic, and asserting the benefits of risk-taking to outpace market norms. Maintain a focus on debating and persuading, not just presenting data. Challenge each counterpoint to underscore why a high-risk approach is optimal. Output conversationally as if you are speaking without any special formatting."""
|
||||
Engage actively by addressing any specific concerns raised, refuting the weaknesses in their logic, and asserting the benefits of risk-taking to outpace market norms. Maintain a focus on debating and persuading, not just presenting data. Challenge each counterpoint to underscore why a high-risk approach is optimal. Output conversationally as if you are speaking without any special formatting. Please write all responses in Korean."""
|
||||
|
||||
response = llm.invoke(prompt)
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ Latest World Affairs Report: {news_report}
|
|||
Company Fundamentals Report: {fundamentals_report}
|
||||
Here is the current conversation history: {history} Here is the last response from the risky analyst: {current_risky_response} Here is the last response from the neutral analyst: {current_neutral_response}. If there are no responses from the other viewpoints, do not halluncinate and just present your point.
|
||||
|
||||
Engage by questioning their optimism and emphasizing the potential downsides they may have overlooked. Address each of their counterpoints to showcase why a conservative stance is ultimately the safest path for the firm's assets. Focus on debating and critiquing their arguments to demonstrate the strength of a low-risk strategy over their approaches. Output conversationally as if you are speaking without any special formatting."""
|
||||
Engage by questioning their optimism and emphasizing the potential downsides they may have overlooked. Address each of their counterpoints to showcase why a conservative stance is ultimately the safest path for the firm's assets. Focus on debating and critiquing their arguments to demonstrate the strength of a low-risk strategy over their approaches. Output conversationally as if you are speaking without any special formatting. Please write all responses in Korean."""
|
||||
|
||||
response = llm.invoke(prompt)
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ Latest World Affairs Report: {news_report}
|
|||
Company Fundamentals Report: {fundamentals_report}
|
||||
Here is the current conversation history: {history} Here is the last response from the risky analyst: {current_risky_response} Here is the last response from the safe analyst: {current_safe_response}. If there are no responses from the other viewpoints, do not halluncinate and just present your point.
|
||||
|
||||
Engage actively by analyzing both sides critically, addressing weaknesses in the risky and conservative arguments to advocate for a more balanced approach. Challenge each of their points to illustrate why a moderate risk strategy might offer the best of both worlds, providing growth potential while safeguarding against extreme volatility. Focus on debating rather than simply presenting data, aiming to show that a balanced view can lead to the most reliable outcomes. Output conversationally as if you are speaking without any special formatting."""
|
||||
Engage actively by analyzing both sides critically, addressing weaknesses in the risky and conservative arguments to advocate for a more balanced approach. Challenge each of their points to illustrate why a moderate risk strategy might offer the best of both worlds, providing growth potential while safeguarding against extreme volatility. Focus on debating rather than simply presenting data, aiming to show that a balanced view can lead to the most reliable outcomes. Output conversationally as if you are speaking without any special formatting. Please write all responses in Korean."""
|
||||
|
||||
response = llm.invoke(prompt)
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ def create_trader(llm, memory):
|
|||
messages = [
|
||||
{
|
||||
"role": "system",
|
||||
"content": f"""You are a trading agent analyzing market data to make investment decisions. Based on your analysis, provide a specific recommendation to buy, sell, or hold. End with a firm decision and always conclude your response with 'FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL**' to confirm your recommendation. Do not forget to utilize lessons from past decisions to learn from your mistakes. Here is some reflections from similar situatiosn you traded in and the lessons learned: {past_memory_str}""",
|
||||
"content": f"""You are a trading agent analyzing market data to make investment decisions. Based on your analysis, provide a specific recommendation to buy, sell, or hold. End with a firm decision and always conclude your response with 'FINAL TRANSACTION PROPOSAL: **BUY/HOLD/SELL**' to confirm your recommendation. Do not forget to utilize lessons from past decisions to learn from your mistakes. Here is some reflections from similar situatiosn you traded in and the lessons learned: {past_memory_str}. Please write all responses in Korean.""",
|
||||
},
|
||||
context,
|
||||
]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class FinancialSituationMemory:
|
|||
# self.client = OpenAI()
|
||||
self.embeddings = OpenAIEmbeddings(model="text-embedding-ada-002", api_key=os.getenv("OPENAI_API_KEY"))
|
||||
self.chroma_client = chromadb.Client(Settings(allow_reset=True))
|
||||
self.situation_collection = self.chroma_client.create_collection(name=name)
|
||||
self.situation_collection = self.chroma_client.get_or_create_collection(name=name)
|
||||
|
||||
def get_embedding(self, text):
|
||||
"""Get OpenAI embedding for a text"""
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -74,10 +74,14 @@ def getNewsData(query, start_date, end_date):
|
|||
for el in results_on_page:
|
||||
try:
|
||||
link = el.find("a")["href"]
|
||||
title = el.select_one("div.MBeuO").get_text()
|
||||
snippet = el.select_one(".GI74Re").get_text()
|
||||
date = el.select_one(".LfVVr").get_text()
|
||||
source = el.select_one(".NUnG9d span").get_text()
|
||||
title_el = el.select_one("div.MBeuO")
|
||||
title = title_el.get_text() if title_el else ""
|
||||
snippet_el = el.select_one(".GI74Re")
|
||||
snippet = snippet_el.get_text() if snippet_el else ""
|
||||
date_el = el.select_one(".LfVVr")
|
||||
date = date_el.get_text() if date_el else ""
|
||||
source_el = el.select_one(".NUnG9d span")
|
||||
source = source_el.get_text() if source_el else ""
|
||||
news_results.append(
|
||||
{
|
||||
"link": link,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
# TradingAgents/graph/setup.py
|
||||
|
||||
from typing import Dict, Any, List
|
||||
from typing import Dict, Any
|
||||
from langchain_openai import ChatOpenAI
|
||||
from langgraph.graph import END, StateGraph, START
|
||||
from langgraph.prebuilt import ToolNode
|
||||
|
|
@ -40,7 +40,9 @@ class GraphSetup:
|
|||
self.risk_manager_memory = risk_manager_memory
|
||||
self.conditional_logic = conditional_logic
|
||||
|
||||
def setup_graph(self, selected_analysts: List[str]):
|
||||
def setup_graph(
|
||||
self, selected_analysts=["market", "social", "news", "fundamentals"]
|
||||
):
|
||||
"""Set up and compile the agent workflow graph.
|
||||
|
||||
Args:
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
|
@ -3,21 +3,22 @@
|
|||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^5.2.6",
|
||||
"@testing-library/jest-dom": "^5.16.4",
|
||||
"@testing-library/react": "^13.3.0",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
"antd": "^5.10.0",
|
||||
"axios": "^1.5.0",
|
||||
"dayjs": "^1.11.9",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-scripts": "5.0.1",
|
||||
"react-router-dom": "^6.4.0",
|
||||
"axios": "^1.5.0",
|
||||
"antd": "^5.10.0",
|
||||
"@ant-design/icons": "^5.2.6",
|
||||
"styled-components": "^6.0.8",
|
||||
"dayjs": "^1.11.9",
|
||||
"react-markdown": "^8.0.7",
|
||||
"websocket": "^1.0.34",
|
||||
"recharts": "^2.8.0"
|
||||
"react-router-dom": "^6.4.0",
|
||||
"react-scripts": "5.0.1",
|
||||
"recharts": "^2.8.0",
|
||||
"remark-gfm": "^4.0.1",
|
||||
"styled-components": "^6.0.8",
|
||||
"websocket": "^1.0.34"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
|
|
@ -44,4 +45,4 @@
|
|||
]
|
||||
},
|
||||
"proxy": "http://localhost:8000"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// web/frontend/src/pages/Analysis/Analysis.js
|
||||
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Card, Divider, Spin, Alert, Typography, message } from 'antd';
|
||||
import { Card, Divider, Spin, Alert, Typography } from 'antd';
|
||||
import styled from 'styled-components';
|
||||
import api from '../../services/api';
|
||||
import { useWebSocket } from '../../contexts/WebSocketContext';
|
||||
|
|
@ -78,20 +78,6 @@ const Analysis = () => {
|
|||
clearMessages();
|
||||
};
|
||||
|
||||
// 분석 취소 핸들러
|
||||
const handleCancelAnalysis = async () => {
|
||||
if (!currentSessionId) return;
|
||||
|
||||
try {
|
||||
await api.post(`/api/trading/cancel/${currentSessionId}/`);
|
||||
message.success('분석이 성공적으로 중단되었습니다.');
|
||||
handleNewAnalysis(); // 상태를 초기화하고 폼으로 돌아감
|
||||
} catch (err) {
|
||||
const errorMessage = err.response?.data?.error || '분석 취소에 실패했습니다.';
|
||||
setError(errorMessage);
|
||||
}
|
||||
};
|
||||
|
||||
const renderContent = () => {
|
||||
if (analysisStatus === 'starting') {
|
||||
return <div style={{ textAlign: 'center', padding: '50px' }}><Spin size="large" tip="분석을 시작하고 있습니다..." /></div>;
|
||||
|
|
@ -106,7 +92,6 @@ const Analysis = () => {
|
|||
messages={messages.filter(m => m.sessionId === currentSessionId)}
|
||||
finalReport={finalReport}
|
||||
onNewAnalysis={handleNewAnalysis}
|
||||
onCancelAnalysis={handleCancelAnalysis}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,82 @@
|
|||
import React from 'react';
|
||||
import { Card, Tabs, Typography, Divider, Tag } from 'antd';
|
||||
import { LineChartOutlined, MessageOutlined, ReadOutlined, WalletOutlined, ProjectOutlined, ExperimentOutlined, SolutionOutlined } from '@ant-design/icons';
|
||||
import styled from 'styled-components';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
|
||||
const { Title, Paragraph, Text } = Typography;
|
||||
const { TabPane } = Tabs;
|
||||
|
||||
const ReportContainer = styled(Card)`
|
||||
margin-top: ${props => props.theme.spacing.lg};
|
||||
.ant-card-body {
|
||||
padding: ${props => props.theme.spacing.xl};
|
||||
}
|
||||
`;
|
||||
|
||||
const MarkdownWrapper = styled.div`
|
||||
h1, h2, h3 {
|
||||
margin-top: 24px;
|
||||
margin-bottom: 16px;
|
||||
font-weight: 600;
|
||||
}
|
||||
h1 { font-size: 2em; }
|
||||
h2 { font-size: 1.5em; border-bottom: 1px solid #f0f0f0; padding-bottom: 8px; }
|
||||
h3 { font-size: 1.25em; }
|
||||
p { line-height: 1.8; }
|
||||
ul, ol { padding-left: 24px; }
|
||||
li { margin-bottom: 8px; }
|
||||
strong { color: ${props => props.theme.colors.primary}; }
|
||||
`;
|
||||
|
||||
const reportSections = {
|
||||
"시장 분석가 리포트": { icon: <LineChartOutlined />, key: 'market' },
|
||||
"소셜 미디어 분석가 리포트": { icon: <MessageOutlined />, key: 'social' },
|
||||
"뉴스 분석가 리포트": { icon: <ReadOutlined />, key: 'news' },
|
||||
"재무 분석가 리포트": { icon: <WalletOutlined />, key: 'fundamentals' },
|
||||
"투자 결정 토론 요약": { icon: <ProjectOutlined />, key: 'debate' },
|
||||
"최종 투자 계획": { icon: <ExperimentOutlined />, key: 'plan' },
|
||||
"최종 거래 결정": { icon: <SolutionOutlined />, key: 'decision' },
|
||||
};
|
||||
|
||||
const ReportDisplay = ({ reportContent }) => {
|
||||
if (!reportContent) return null;
|
||||
|
||||
const parsedSections = {};
|
||||
const sections = reportContent.split('## ').slice(1);
|
||||
|
||||
sections.forEach(section => {
|
||||
const lines = section.split('\n');
|
||||
const title = lines[0].trim();
|
||||
const content = lines.slice(1).join('\n').trim();
|
||||
parsedSections[title] = content;
|
||||
});
|
||||
|
||||
const mainTitleMatch = reportContent.match(/^# (.*)/);
|
||||
const mainTitle = mainTitleMatch ? mainTitleMatch[1] : "최종 분석 보고서";
|
||||
|
||||
return (
|
||||
<ReportContainer>
|
||||
<Title level={2} style={{ textAlign: 'center' }}>{mainTitle}</Title>
|
||||
<Divider />
|
||||
<Tabs defaultActiveKey="market">
|
||||
{Object.entries(parsedSections).map(([title, content]) => {
|
||||
const sectionInfo = Object.values(reportSections).find(info => title.includes(Object.keys(reportSections).find(key => reportSections[key] === info))) || {};
|
||||
return (
|
||||
<TabPane
|
||||
tab={<span>{sectionInfo.icon} {title}</span>}
|
||||
key={sectionInfo.key || title}
|
||||
>
|
||||
<MarkdownWrapper>
|
||||
<ReactMarkdown remarkPlugins={[remarkGfm]}>{content}</ReactMarkdown>
|
||||
</MarkdownWrapper>
|
||||
</TabPane>
|
||||
);
|
||||
})}
|
||||
</Tabs>
|
||||
</ReportContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default ReportDisplay;
|
||||
|
|
@ -97,7 +97,7 @@ const Dashboard = () => {
|
|||
});
|
||||
const [recentAnalyses, setRecentAnalyses] = useState([]);
|
||||
const { user } = useAuth();
|
||||
const { connected, messages } = useWebSocket();
|
||||
const { connected, analysisProgress } = useWebSocket();
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue