feat: add analysis-only crypto asset mode

This commit is contained in:
CadeYu
2026-04-18 20:42:11 +08:00
parent f362a160c3
commit e7ec980021
13 changed files with 141 additions and 19 deletions

View File

@@ -3,7 +3,7 @@ from typing import List, Optional, Tuple, Dict
from rich.console import Console
from cli.models import AnalystType
from cli.models import AnalystType, AssetType
console = Console()
@@ -14,6 +14,8 @@ ANALYST_ORDER = [
("Fundamentals Analyst", AnalystType.FUNDAMENTALS),
]
CRYPTO_SUFFIXES = ("-USD", "-USDT", "-USDC", "-BTC", "-ETH")
def get_ticker() -> str:
"""Prompt the user to enter a ticker symbol."""
@@ -35,6 +37,25 @@ def get_ticker() -> str:
return ticker.strip().upper()
def detect_asset_type(ticker: str) -> AssetType:
normalized_ticker = ticker.strip().upper()
if normalized_ticker.endswith(CRYPTO_SUFFIXES):
return AssetType.CRYPTO
return AssetType.STOCK
def filter_analysts_for_asset_type(
analysts: List[AnalystType], asset_type: AssetType
) -> List[AnalystType]:
if asset_type != AssetType.CRYPTO:
return analysts
return [
analyst
for analyst in analysts
if analyst != AnalystType.FUNDAMENTALS
]
def get_analysis_date() -> str:
"""Prompt the user to enter a date in YYYY-MM-DD format."""
import re
@@ -68,12 +89,18 @@ def get_analysis_date() -> str:
return date.strip()
def select_analysts() -> List[AnalystType]:
def select_analysts(asset_type: AssetType = AssetType.STOCK) -> List[AnalystType]:
"""Select analysts using an interactive checkbox."""
available_analysts = filter_analysts_for_asset_type(
[value for _, value in ANALYST_ORDER],
asset_type,
)
choices = questionary.checkbox(
"Select Your [Analysts Team]:",
choices=[
questionary.Choice(display, value=value) for display, value in ANALYST_ORDER
questionary.Choice(display, value=value)
for display, value in ANALYST_ORDER
if value in available_analysts
],
instruction="\n- Press Space to select/unselect analysts\n- Press 'a' to select/unselect all\n- Press Enter when done",
validate=lambda x: len(x) > 0 or "You must select at least one analyst.",