FA3-Datafetch/backend/verify_historical_currency.py
2026-01-12 19:20:18 +08:00

42 lines
1.5 KiB
Python

import sys
import asyncio
import json
from app.clients.bloomberg_client import BloombergClient
# Mock the PRICE_CONFIG to ensure we are fetching what we expect if it's not imported
# But BloombergClient imports it from configuration.
# Let's rely on the real client.
async def run():
client = BloombergClient()
company = "2503 JP Equity"
dates = ['2024-12-31', '2023-12-31', '2022-12-31', '2021-12-31', '2020-12-31', '2019-12-31', '2018-12-31', '2017-12-31', '2016-12-31']
currencies = ["CNY"]
print(f"Testing _fetch_price_by_dates_remote for {company} on {dates}...")
for curr in currencies:
print(f"\n--- Fetching in {curr} ---")
try:
# The method allows fetching price data for specific dates
# It uses PRICE_CONFIG which includes 'Market_Cap'
data = client._fetch_price_by_dates_remote(company, curr, dates)
# Filter for Market_Cap to show user
mkt_caps = [d for d in data if d['indicator'] == 'Market_Cap']
if mkt_caps:
for item in mkt_caps:
print(f"Currency: {item['currency']}, Date: {item['value_date']}, Value: {item['value']}")
else:
print("No Market_Cap data returned.")
print("Raw data returned:", json.dumps(data, indent=2))
except Exception as e:
print(f"Error fetching {curr}: {e}")
if __name__ == "__main__":
asyncio.run(run())