|
|
""" |
|
|
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...") |
|
|
|
|
|
|
|
|
analyzer = TickerAnalyzer( |
|
|
exchange="NASDAQ", |
|
|
limit=100 |
|
|
) |
|
|
|
|
|
|
|
|
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...") |
|
|
|
|
|
|
|
|
scheduler = Scheduler( |
|
|
exchange="NASDAQ", |
|
|
interval_hours=1, |
|
|
telegram_bot_service=None |
|
|
) |
|
|
|
|
|
|
|
|
await scheduler.start() |
|
|
|
|
|
|
|
|
async def example_with_telegram(): |
|
|
"""Example with Telegram integration""" |
|
|
from src.telegram_bot.telegram_bot_service import TelegramBotService |
|
|
|
|
|
|
|
|
telegram_service = TelegramBotService() |
|
|
await telegram_service.initialize() |
|
|
|
|
|
|
|
|
analyzer = TickerAnalyzer( |
|
|
exchange="NASDAQ", |
|
|
telegram_bot_service=telegram_service, |
|
|
limit=200 |
|
|
) |
|
|
|
|
|
|
|
|
await analyzer.run_analysis() |
|
|
|
|
|
|
|
|
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() |