from typing import OrderedDict


def _get_price_statistics(trading_day_feed):
    """Calculate and print the following data for each Symbol as a comma-delimiter string.
    Rows should be printed in alphabetical order based on Symbol

        i. Time: Most recent timestamp for that Symbol in YYYY-mm-dd HH:MM:SS format
        ii. Symbol
        iii. High: Maximum Price that occurred for that Symbol during the trading day.
        iv. Low: Minimum Price that occurred for that Symbol during the trading day
    """
    stat = dict()
    for feed in trading_day_feed:
        symbol = feed.symbol
        if stat.get(symbol):
            prev_feed = stat[symbol]
            prev_feed["time"] = max(prev_feed["time"], feed.time)
            prev_feed["high"] = max(prev_feed["high"], feed.price)
            prev_feed["low"] = min(prev_feed["low"], feed.price)
        else:
            stat[symbol] = {
                "date": feed.date,
                "time": feed.time,
                "high": feed.price,
                "low": feed.price,
            }

    # alphabetical order based on Symbol
    price_statistics = OrderedDict.fromkeys(sorted(stat.keys()))
    for symbol, symbol_info in stat.items():
        price_statistics[symbol] = symbol_info
    return price_statistics