chore: stop tracking tests directory
This commit is contained in:
parent
b9c8f90cbc
commit
62f671bb35
1
.gitignore
vendored
1
.gitignore
vendored
@ -26,3 +26,4 @@ stock_analysis.db
|
||||
data/
|
||||
reports/
|
||||
logs/
|
||||
tests/
|
||||
|
||||
@ -1,94 +0,0 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import requests
|
||||
import time
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Add src to path
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '../src'))
|
||||
|
||||
from fetchers.ifind_client import IFindClient
|
||||
|
||||
def debug_ifind():
|
||||
load_dotenv()
|
||||
token = os.getenv("IFIND_REFRESH_TOKEN")
|
||||
if not token:
|
||||
print("Missing IFIND_REFRESH_TOKEN in .env")
|
||||
return
|
||||
|
||||
client = IFindClient(token)
|
||||
print(f"Loaded token: {token[:20]}... (Length: {len(token)})")
|
||||
|
||||
# Try a simple token refresh check directly
|
||||
print("Testing token refresh...")
|
||||
access_token = client._get_access_token()
|
||||
if access_token:
|
||||
print(f"Success! Access Token: {access_token[:20]}...")
|
||||
else:
|
||||
print("Failed to get access token.")
|
||||
return
|
||||
symbol = "7203.T"
|
||||
|
||||
print(f"--- Testing basic_data_service for {symbol} ---")
|
||||
params = {
|
||||
"codes": symbol,
|
||||
"indipara": [
|
||||
{"indicator": "revenue_oas", "indiparams": ["8", "1", "BB"]},
|
||||
{"indicator": "ths_reporting_period_stock", "indiparams": []}
|
||||
]
|
||||
}
|
||||
res = client.post("basic_data_service", params)
|
||||
print(json.dumps(res, indent=2, ensure_ascii=False))
|
||||
|
||||
print(f"\n--- Testing date_sequence Interval='Y' for {symbol} ---")
|
||||
end_date = time.strftime("%Y%m%d")
|
||||
start_date = "20220101"
|
||||
params_seq = {
|
||||
"codes": symbol,
|
||||
"startdate": start_date,
|
||||
"enddate": end_date,
|
||||
"functionpara": {"Interval": "Y", "Days": "Alldays", "Fill": "Previous"},
|
||||
"indipara": [
|
||||
{"indicator": "revenue_oas", "indiparams": ["8", "", "BB"]}
|
||||
]
|
||||
}
|
||||
res_seq = client.post("date_sequence", params_seq)
|
||||
print(json.dumps(res_seq, indent=2, ensure_ascii=False))
|
||||
|
||||
print(f"\n--- Testing cmd_history_quotation for {symbol} ---")
|
||||
params_hist = {
|
||||
"codes": symbol,
|
||||
"startdate": start_date,
|
||||
"enddate": end_date,
|
||||
"indicators": "close,totalCapital",
|
||||
"functionpara": {"Interval": "D", "Days": "Alldays", "Fill": "Previous"}
|
||||
}
|
||||
res_hist = client.post("cmd_history_quotation", params_hist)
|
||||
print(json.dumps(res_hist, indent=2, ensure_ascii=False))
|
||||
|
||||
print(f"\n--- Testing date_sequence with standard indicators for {symbol} ---")
|
||||
params_std = {
|
||||
"codes": symbol,
|
||||
"startdate": start_date,
|
||||
"enddate": end_date,
|
||||
"functionpara": {"Interval": "D", "Days": "Alldays", "Fill": "Previous"},
|
||||
"indipara": [
|
||||
{"indicator": "total_mv", "indiparams": ["1", "BB"]},
|
||||
{"indicator": "pe_ttm", "indiparams": ["1", "BB"]}
|
||||
]
|
||||
}
|
||||
print(f"\n--- Testing basic_data_service with specific dates for {symbol} ---")
|
||||
params_dates = {
|
||||
"codes": symbol,
|
||||
"indipara": [
|
||||
{"indicator": "revenue_oas", "indiparams": ["20240331", "", "BB"]},
|
||||
{"indicator": "revenue_oas", "indiparams": ["20230331", "", "BB"]}
|
||||
]
|
||||
}
|
||||
res_dates = client.post("basic_data_service", params_dates)
|
||||
print(json.dumps(res_dates, indent=2, ensure_ascii=False))
|
||||
|
||||
if __name__ == "__main__":
|
||||
debug_ifind()
|
||||
@ -1,43 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Add src to path
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '../src'))
|
||||
|
||||
from strategies.hk_strategy import HK_Strategy
|
||||
|
||||
def test_hk_flow():
|
||||
load_dotenv()
|
||||
token = os.getenv("IFIND_REFRESH_TOKEN")
|
||||
if not token:
|
||||
print("Missing IFIND_REFRESH_TOKEN in .env")
|
||||
return
|
||||
|
||||
# Use Tencent (00700.HK) as a test case
|
||||
symbol = "00700"
|
||||
print(f"--- Testing HK Flow for {symbol} ---")
|
||||
|
||||
strategy = HK_Strategy(symbol, token)
|
||||
|
||||
print("Step 1: Fetching data...")
|
||||
strategy.fetch_data()
|
||||
|
||||
print("Step 2: Analyzing data...")
|
||||
strategy.analyze_data()
|
||||
|
||||
# Check the latest row of analysis
|
||||
if strategy.analysis_result is not None and not strategy.analysis_result.empty:
|
||||
latest = strategy.analysis_result.iloc[0]
|
||||
print(f"\nLatest Analysis Results:")
|
||||
print(f"PE: {latest.get('PE')}")
|
||||
print(f"PB: {latest.get('PB')}")
|
||||
print(f"DividendYield: {latest.get('DividendYield')}")
|
||||
|
||||
print("\nStep 3: Generating report...")
|
||||
strategy.generate_report()
|
||||
|
||||
print("--- Test Complete ---")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_hk_flow()
|
||||
@ -1,63 +0,0 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import pandas as pd
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Add src to path
|
||||
sys.path.append(os.path.join(os.path.dirname(__file__), '../src'))
|
||||
|
||||
from fetchers.jp_fetcher import JpFetcher
|
||||
|
||||
def test_jp_fetcher():
|
||||
load_dotenv()
|
||||
token = os.getenv("IFIND_REFRESH_TOKEN")
|
||||
if not token:
|
||||
print("Missing IFIND_REFRESH_TOKEN in .env")
|
||||
return
|
||||
|
||||
fetcher = JpFetcher(token)
|
||||
symbol = "7203" # Toyota
|
||||
|
||||
print(f"--- Fetching Market Metrics for {symbol} ---")
|
||||
metrics = fetcher.get_market_metrics(symbol)
|
||||
print(metrics)
|
||||
|
||||
print(f"\n--- Fetching Income Statement for {symbol} ---")
|
||||
df_is = fetcher.get_income_statement(symbol)
|
||||
if not df_is.empty:
|
||||
print(df_is.head())
|
||||
else:
|
||||
print("Income Statement is empty!")
|
||||
|
||||
print(f"\n--- Fetching Balance Sheet for {symbol} ---")
|
||||
df_bs = fetcher.get_balance_sheet(symbol)
|
||||
if not df_bs.empty:
|
||||
print(df_bs.head())
|
||||
else:
|
||||
print("Balance Sheet is empty!")
|
||||
|
||||
print(f"\n--- Fetching Cash Flow for {symbol} ---")
|
||||
df_cf = fetcher.get_cash_flow(symbol)
|
||||
if not df_cf.empty:
|
||||
print(df_cf.head())
|
||||
else:
|
||||
print("Cash Flow is empty!")
|
||||
|
||||
print(f"\n--- Fetching Historical Metrics for {symbol} ---")
|
||||
dates = ["2023-12-21", "2024-06-30"]
|
||||
df_hist = fetcher.get_historical_metrics(symbol, dates)
|
||||
if not df_hist.empty:
|
||||
print(df_hist)
|
||||
else:
|
||||
print("Historical Metrics is empty!")
|
||||
|
||||
print(f"\n--- Fetching Dividends for {symbol} ---")
|
||||
df_div = fetcher.get_dividends(symbol)
|
||||
if not df_div.empty:
|
||||
print(df_div.head())
|
||||
else:
|
||||
print("Dividends empty or not found.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_jp_fetcher()
|
||||
Loading…
Reference in New Issue
Block a user