File size: 2,529 Bytes
3e26349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
"""
Example usage of the Ticker Scanner module

This script demonstrates how to use the ticker scanner to find
fast-growing stocks and send notifications to Telegram.
"""

import asyncio
from src.core.ticker_scanner import TickerAnalyzer, Scheduler


async def example_one_time_analysis():
    """Run a single analysis of top growing tickers"""
    print("Running one-time ticker analysis...")

    # Create analyzer for NASDAQ
    analyzer = TickerAnalyzer(
        exchange="NASDAQ",
        limit=100  # Analyze top 100 tickers
    )

    # Run analysis
    top_tickers = await analyzer.run_analysis()

    print(f"\nFound {len(top_tickers)} top tickers!")
    for i, ticker_data in enumerate(top_tickers[:5], 1):
        ticker = ticker_data['ticker']
        metrics = ticker_data['metrics']
        print(f"{i}. {ticker}: Score={metrics.growth_velocity_score:.1f}, CAGR={metrics.cagr:.1f}%")


async def example_scheduled_analysis():
    """Run scheduled hourly analysis"""
    print("Starting scheduled ticker scanner...")

    # Create scheduler for hourly analysis
    scheduler = Scheduler(
        exchange="NASDAQ",
        interval_hours=1,
        telegram_bot_service=None  # Replace with your TelegramBotService instance
    )

    # Start scheduler (runs until interrupted)
    await scheduler.start()


async def example_with_telegram():
    """Example with Telegram integration"""
    from src.telegram_bot.telegram_bot_service import TelegramBotService

    # Initialize Telegram service
    telegram_service = TelegramBotService()
    await telegram_service.initialize()

    # Create analyzer with Telegram integration
    analyzer = TickerAnalyzer(
        exchange="NASDAQ",
        telegram_bot_service=telegram_service,
        limit=200
    )

    # Run analysis and send to Telegram
    await analyzer.run_analysis()

    # Cleanup
    await telegram_service.cleanup()


def main():
    """Main entry point"""
    print("=" * 80)
    print("Ticker Scanner Examples")
    print("=" * 80)
    print()
    print("Choose an example:")
    print("1. One-time analysis")
    print("2. Scheduled hourly analysis")
    print("3. With Telegram integration")
    print()

    choice = input("Enter choice (1-3): ")

    if choice == "1":
        asyncio.run(example_one_time_analysis())
    elif choice == "2":
        asyncio.run(example_scheduled_analysis())
    elif choice == "3":
        asyncio.run(example_with_telegram())
    else:
        print("Invalid choice")


if __name__ == "__main__":
    main()