import { TradeMode } from "@/common/constants/enumCommon";
import APP from '@/services';
import { Marketrun } from "../go/commonMarket/interface";
import { Market } from "../go/useInfo/interface";

export function getMarketByTradeMode(trademode: TradeMode): Market | undefined {
    return APP.get('markets').find((el: Market) => el.trademode === trademode)
}

// 获取市场运行信息
export function getMarketRunByTradeMode(trademode: TradeMode): Marketrun | null {
    const marketInfo = getMarketByTradeMode(trademode)
    let result = null
    if (marketInfo) {
        const temp = APP.get('marketRun').find((el: Market) => el.marketid === marketInfo.marketid)
        result = temp ? temp : null;
    }
    return result
}