from typing import Optional
from db.connection import get_connection
from db.queries import get_instruments


def get_moex_tickers() -> list[str]:
    instruments = get_instruments(instrument_type='moex')
    return [row['name'] for row in instruments]


def get_ticker_type(ticker: str) -> Optional[str]:
    instruments = get_instruments()
    for row in instruments:
        if row['name'] == ticker:
            return row['type']
    return None
