package com.smppw.common.pojo.enums.strategy;

import org.apache.commons.lang3.StringUtils;

import java.util.stream.Stream;

public enum SysStrategy {

    OtherStrategy(-1, "其他策略", ""), /**/
    EquityLongOnly(100101,"主观多头", "IN00000008"), /**/
    EquityQuantitative(100102,"量化多头", ""), /**/
    EquityLongShort(100103, "股票多空", "IN00000008"), /**/
    EquityNeutral(100104,"股票市场中性", "IN00000008"), /**/
    BondPure(100201,"纯债策略", "IN00000077"), /**/
    BondStrong(100202,"债券增强", "IN00000077"), /**/
    BondMultiple(100203,"债券复合", "IN00000077"), /**/
    CnvtbBondTrd(100204,"转债交易", "IN0000008J"),
    OptionStrgy(100303, "期权策略", "IN0000008S"),
    OtherFutures(100304, "其他衍生品", "IN0000008S"),
    MacroStrgy(100401, "宏观策略", "IN00000008"),
    ArbitrageStrgy(100402, "套利策略", "IN00000008"),
    CombinedStrgy(100403, "复合策略", "IN00000008"),
    FOF(100501, "FOF", ""), /**/
    MOM(100502, "MOM", ""),

    ActTrendFlw(10030101, "主观趋势", "IN0000008S"),
    ActMktNutrl(10030102, "主观套利", "IN0000008S"),
    MltFutMgtStrgy(10030103, "主观多策略", "IN0000008S"),
    TrendFlwQuant(10030201, "量化趋势", "IN0000008S"),
    MktNutrlQuant(10030202, "量化套利", "IN0000008S"),
    MltFutMgtQuant(10030203, "量化多策略", "IN0000008S");

    private Integer id;
    private String name;
    private String benchmark;

    private SysStrategy(Integer id, String name, String benchmark) {
        this.id = id;
        this.name = name;
        this.benchmark = benchmark;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getBenchmark() {
        return benchmark;
    }

    public static SysStrategy getSysStrategy(int id) {
        return Stream.of(SysStrategy.values()).filter(e -> e.id == id).findFirst().orElse(OtherStrategy);
    }

    public static boolean isStrategy(String str) {
        if (StringUtils.isEmpty(str)) {
            return false;
        }

        for (SysStrategy s : SysStrategy.values()) {
            if (str.equals(s.getId() + "") || str.equals(s.name())) {
                return true;
            }
        }

        return false;
    }
}
