การตั้งค่า TradingAgents API

Updated 2026-09-06

เชื่อม model client ตามเอกสาร แล้ว validate research graph แยกกัน คู่มือนี้ผ่านการรีวิวจาก source และครอบคลุม provider configuration, financial-data dependency และการทดลองแรกที่มีขอบเขต

เริ่มจาก research question ที่มี version

ตั้ง compatible provider, custom backend URL และ model role 2 แบบ แล้วทดสอบบริษัทเดียวในวันที่วิจัยที่กำหนด TradingAgents จัด analyst, argument ฝั่งตรงข้าม และ risk review ดังนั้น task แรกที่มีประโยชน์คือดูว่า role เหล่านี้อธิบาย source packet เดียวกันอย่างไร เลือกบริษัทและ information cutoff ก่อนเปลี่ยน model เก็บ fact ต้นทางและรายการที่ยังไม่คลี่คลายจาก run แรก เพื่อให้การเปรียบเทียบ model ภายหลังใช้คำถามเดิม field ด้านล่างอิง service revision 9dee508c

ตั้งค่า compatible provider และ model role ทั้งสอง

default_config.py ที่รีวิวเปิดเผย llm_provider, backend_url, deep_think_llm และ quick_think_llm client ที่เข้ากันได้ใช้ endpoint ที่ส่งให้ authentication เป็น environment setting แยกกัน role slot ทั้งสองต้องใช้ model identifier ที่ endpoint ที่เลือกและ project client ยอมรับแบบ exact ตัวอย่างนี้ปรับจาก source field และสร้างเพียง configuration ตั้ง RESEARCH_MODEL_ID และ SUMMARY_MODEL_ID จาก catalog ปัจจุบันหลังตรวจ capability ที่ต้องใช้ ชื่อเหล่านี้เป็น local environment slot ไม่ใช่ model ID หรือ TradingAgents default เก็บ credential ใน process environment ไม่ใช่ใน script

import os
from copy import deepcopy
from tradingagents.default_config import DEFAULT_CONFIG

config = deepcopy(DEFAULT_CONFIG)
config.update({
    "llm_provider": "openai_compatible",
    "backend_url": "https://api.apisrouter.com/v1",
    "deep_think_llm": os.environ["RESEARCH_MODEL_ID"],
    "quick_think_llm": os.environ["SUMMARY_MODEL_ID"],
    "max_debate_rounds": 1,
    "max_risk_discuss_rounds": 1,
})
assert os.environ["OPENAI_COMPATIBLE_API_KEY"]
# Configuration only. This does not start a research run.

แยก model route ออกจาก financial data

ตั้งค่า financial-data vendor แยกจาก model endpoint สำหรับ equity ต่างประเทศ ให้ resolve issuer และ symbol เฉพาะตลาดก่อนเก็บข้อมูล รักษา trading currency, reporting currency, market timezone และ benchmark choice US-listed depositary receipt กับ ordinary share ต้นทางต้องมีกฎ conversion ที่ชัดก่อนเปรียบเทียบ price series diagram แสดงการเชื่อมของ model setting ส่วน financial-data tool มี credential, coverage และ source timestamp ของตัวเอง ตรวจ tool เหล่านั้นก่อนวินิจฉัย research input ที่หายว่าเป็น LLM failure

TradingAgents model configuration route ผ่าน compatible provider ไปยัง model slot ของ research และ summaryTradingAgents routes through openai_compatible + backend_url to the APIsRouter gateway (api.apisrouter.com/v1), which fans out to: Research model slot, Summary model slot.TradingAgentsviaopenai_compatible +backend_urlAPIsRouterapi.apisrouter.com/v1Research model slotSummary model slot
Model-client route ตามเอกสาร ส่วน market-data configuration ยังคงแยกกัน

เลือก role จาก task contract

ทดสอบ capability ที่ role แต่ละตัวใช้จริง text reply ไม่ได้พิสูจน์ tool-call parsing, long-context handling หรือ structured-output behavior การเปลี่ยน model family อาจเปลี่ยน provider adapter behavior แม้ endpoint รับ identifier ได้ เริ่มจาก role ชุดเล็กที่มีประโยชน์ เพิ่ม debate เมื่อช่วยพบ claim ที่ไม่มีหลักฐานหรือ counterevidence ที่ใช้ได้ ประเมิน final artifact กับ source packet เดิม แทนการถือว่ารายงานที่ยาวกว่าคือ research ที่ดีกว่า

RoleEvidence ที่ต้องมีFailure ที่ต้องตรวจ
AnalystTool result และ source locatorสร้าง fact หลัง data error
Research debateArgument ที่เชื่อมกับ analyst evidenceนำ claim ซ้ำมาแสดงเป็น corroboration
Risk reviewAssumption และรายการที่ยังไม่คลี่คลายอย่างชัดเจนPosition ที่มั่นใจโดยไม่มี input ที่ตรวจแล้ว

ใช้ staged first-run acceptance test

เริ่มจากตรวจ resolved configuration โดยไม่พิมพ์ key จากนั้นใน execution environment ที่ได้รับอนุญาต ให้รัน project client ด้วย model ที่เลือกและเก็บ redacted request record แล้วทดสอบ tool interaction ที่จำเป็นกับ error path ของมัน สุดท้ายรัน TradingAgentsGraph ด้วย source set ที่มีขอบเขต และตรวจ state ที่ได้ fact ที่อ้าง และ research output สุดท้าย เก็บ repository revision, dependency version, input hash และ role setting factory response ที่ผ่านพิสูจน์เฉพาะ client stage รายงานที่สมบูรณ์ยังต้อง source และ numerical review ก่อนนับเป็น research artifact ที่ใช้ได้

import os
from research_config import config
from tradingagents.graph.trading_graph import TradingAgentsGraph

graph = TradingAgentsGraph(debug=False, config=config)
state, decision = graph.propagate(
    os.environ["RESEARCH_TICKER"],
    os.environ["RESEARCH_DATE"],
)
# Inspect state and decision against the source packet.
# Running this template makes model and data requests.

ปกป้อง historical research จากข้อมูลภายหลัง

วันที่วิเคราะห์ที่ขอไม่ได้พิสูจน์ว่า provider ทุกตัวคืนข้อมูล point-in-time ตรวจว่า fundamental มีให้ใช้ก่อน cutoff จริงหรือไม่ article ถูกแก้ในภายหลังหรือไม่ และ cache data มาจาก experiment อื่นหรือไม่ เก็บ publication time กับ ingestion time แยกกัน เก็บ training หรือ reflection feedback นอก held-out evaluation period รายชื่อ ticker ย้อนหลังต้องรวม delisting และ symbol change ที่เกี่ยวข้อง บันทึก corporate-action handling และ comparison benchmark ไว้กับ experiment แต่ละตัว เพื่อไม่ให้ model change ถูกสับสนกับ data change

กำหนด budget สำหรับ debate, retry และ context ที่ส่งซ้ำ

financial-agent spend มาจากทุก request ใน graph รวม summary, context ที่ส่งซ้ำ และ retry ที่คิดเงิน ใช้ pricing contract ปัจจุบันวางแผนและกระทบยอด request usage จริงภายหลัง จำกัด debate round, source volume, parallel job และ automatic retry ก่อน sweep cache source extraction ด้วย document version แยก application reuse ออกจาก provider billing discount ติดตาม data subscription และ local compute แยกจาก LLM charge และเปรียบเทียบต้นทุนต่อ accepted research artifact เริ่มจาก run ที่มีขอบเขตด้านบนก่อนขยาย universe ของ ticker กับ date

วินิจฉัย stage ที่ล้มเหลว

สำหรับ authentication failure ตรวจว่า compatible-provider key ไปถึง process เดียวกับที่สร้าง client สำหรับ model ที่หาย ให้เทียบ identifier แบบ exact และ account access กับ catalog ปัจจุบัน สำหรับ tool output ที่ malformed ให้เก็บ tool schema และ sanitized response ไม่ใช่เฉพาะ exception สุดท้าย อาการค้างอาจมาจาก data-vendor request, tool loop ที่เกิดซ้ำ หรือ model timeout ตรวจ timestamp ของ stage ก่อนเพิ่ม limit หยุดเมื่อ mandatory data หาย การ retry จนมี prose อาจซ่อน failure เดิมและใช้ research budget หมด

หลักฐานและข้อจำกัด

Configuration ผ่านการรีวิวจาก source เมื่อ September 5, 2026 ที่ revision 9dee508c ตัวอย่างเป็น walkthrough template ไม่มี APIsRouter client request, complete graph หรือ task-cost case ที่วัดแล้วสำหรับคู่มือนี้ ตรวจ model และ data tool ที่เลือกใน bounded run ของคุณก่อนขยาย workflow

คำถามที่พบบ่อย

openai_compatible อ่าน key ใด?

provider ที่รีวิว map ไปที่ OPENAI_COMPATIBLE_API_KEY ตั้งค่าใน execution environment และตรวจ resolved provider โดยไม่พิมพ์ secret

สอง role ใช้ model ต่างกันได้หรือไม่?

ได้ configuration มี field deep_think_llm และ quick_think_llm แยกกัน ตรวจ exact ID และ capability ที่จำเป็นของแต่ละตัว endpoint เดียวกันไม่ได้พิสูจน์ compatibility

endpoint มี stock price ให้หรือไม่?

ไม่ market data มาจาก vendor tool ที่ตั้งค่าแยก มี coverage, credential, license และ availability ของตัวเอง

ควรส่ง date ใดให้ propagate?

ใช้ research date ที่ตั้งใจและตรวจ data tool แต่ละตัวแยกว่ารักษา information cutoff หรือไม่ การส่ง date argument อย่างเดียวไม่ทำให้ current data เป็น point-in-time

เลือก model role ทั้งสองอย่างไร?

ใช้ current catalog ID ทดสอบ tool และ output format ที่จำเป็น แล้วเปรียบเทียบ report ที่ยอมรับจาก source packet เดียวกันก่อนเปลี่ยน role ใด

graph ที่สำเร็จพิสูจน์ trading strategy หรือไม่?

ไม่ มันยืนยันผลลัพธ์ของ workflow ภายใต้ input ที่ทดสอบ การประเมินกลยุทธ์ต้องมี point-in-time data, independent evaluation และ execution assumption ที่สมจริง