package com.simuwang.base.common.conts;

import java.util.stream.Stream;


public enum HoldingType {
    Cash(2, "现金"),
    CostCash(20, "冲抵现金(估值增值)"),
    Interest(22, "应计利息"),
    Stock(0, "股票"),
    StockSZH(110, "深港通"),
    StockSHH(111, "沪港通"),
    StockHGT(112, "港股通"),
    Bond(1, "债券"),
    BondBack(5, "回购"),
    BondBackRepo(51, "正回购"),
    BondBackReverseRepo(52, "逆回购"),
    Derivatives(7, "其他衍生品"),
    Future(3, "期货"),
    IndexFuture(31, "股指期货"),
    CmdtFuture(32, "商品期货"),
    BondFuture(33, "国债期货"),
    Option(4, "期权"),
    ETFOption(40, "ETF期权"),
    IndexOption(41, "股指期权"),
    CmdtOption(42, "商品期权"),
    Fund(6, "基金"),
    FundPrivate(61, "私募基金"),
    Warrant(21, "权证"),
    Other(99, "其他"),
    OTHER_ASSET(101, "其他资产"),
    OTHER_DEBT(102, "其他负债"),
    All(-1, "全部"),//方便过滤
    Tail(100, "尾部");

    private final int id;
    private final String name;

    public int getId() {
        return id;
    }

    HoldingType(int id, String name2) {
        this.id = id;
        this.name = name2;
    }

    public static HoldingType getHoldingType(int id) {
        return Stream.of(HoldingType.values()).filter(e -> e.id == id).findFirst().orElse(null);
    }

    public String getName() {
        return name;
    }

    public boolean isTrue(int stockType) {
        return this.id == stockType;
    }
}
