package com.r35157.assetaz.services.ticker;

import com.r35157.libs.valuetypes.basic.TradingPair;
import org.jetbrains.annotations.NotNull;

/**
 * Provides price observations for trading pairs.
 */
public interface TickerService {

    /**
     * Starts the ticker service.
     *
     * @throws IllegalStateException if the service cannot be started
     */
    void start();

    /**
     * Stops every source started by this service.
     */
    void stop();

    /**
     * Returns the latest available price observation for a trading pair.
     *
     * @param tradingPair the requested trading pair
     * @return the latest available price observation
     *
     * @throws NullPointerException     if {@code tradingPair} is {@code null}
     * @throws IllegalArgumentException if the trading pair is not supported
     * @throws IllegalStateException    if no price observation is available
     */
    @NotNull PriceObservation getLatestPrice(@NotNull TradingPair tradingPair);
}
