forked from TauricResearch/TradingAgents
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
32 lines (27 loc) · 1.31 KB
/
test.py
File metadata and controls
32 lines (27 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 匯入時間模組,用於計算執行時間
import time
# 從 tradingagents.dataflows.y_finance 模組匯入所需的函式
# 這些函式用於從 Yahoo Finance 獲取各種股票數據
from tradingagents.dataflows.y_finance import (
get_YFin_data_online, # 線上獲取 Yahoo Finance 數據
get_stock_stats_indicators_window, # 獲取特定時間窗口內的股票統計指標
get_balance_sheet as get_yfinance_balance_sheet, # 獲取資產負債表
get_cashflow as get_yfinance_cashflow, # 獲取現金流量表
get_income_statement as get_yfinance_income_statement, # 獲取損益表
get_insider_transactions as get_yfinance_insider_transactions, # 獲取內部交易資訊
)
# 測試案例說明
print("測試使用 30 天回溯期的優化實作:")
# 記錄開始時間
start_time = time.time()
# 呼叫函式,獲取蘋果公司(AAPL)在 2024-11-01 前 30 天的 MACD 指標
# 'macd' 是移動平均收斂發散指標,一種常用的技術分析工具
result = get_stock_stats_indicators_window("AAPL", "macd", "2024-11-01", 30)
# 記錄結束時間
end_time = time.time()
# 輸出函式執行的時間
print(f"執行時間:{end_time - start_time:.2f} 秒")
# 輸出結果的長度(字元數)
print(f"結果長度:{len(result)} 字元")
# 輸出獲取的指標結果
print(result)