package com.copy.trade.enums;


import lombok.Getter;

import java.util.Arrays;

@Getter
public enum CloseTypeEnum {
    CLOSE(0,"CLOSE","平仓"),
    MARKET_CLOSE(1,"MARKET_CLOSE","市价平仓"),
    ONE_KEY_CLOSE(2,"ONE_KEY_CLOSE","一键平仓"),
    REVERSE_OPEN(3,"REVERSE_OPEN","反向开仓"),
    CUT(4,"CUT","止盈止损"),
    BLAST(5,"BLAST","爆仓"),
    ADMIN_CLOSE(6,"ADMIN_CLOSE","管理员强平"),
    FOLLOW_ACCOUNT_PROFIT(7, "FOLLOW_ACCOUNT_PROFIT", "跟单账户止盈"),
    FOLLOW_ACCOUNT_LOSS(8, "FOLLOW_ACCOUNT_LOSS", "跟单账户止损"),
    FOLLOW_POSITION_PROFIT(9, "FOLLOW_POSITION_PROFIT", "跟单仓位止盈"),
    FOLLOW_POSITION_LOSS(10, "FOLLOW_POSITION_LOSS", "跟单仓位止损"),
    FOLLOW_SELF_CLOSE(11, "FOLLOW_SELF_CLOSE", "跟单用户平仓"),
    ;

    private Integer closeType;
    private String closeTypeStr;
    private String des;

    CloseTypeEnum(Integer closeType, String closeTypeStr, String des) {
        this.closeType = closeType;
        this.closeTypeStr = closeTypeStr;
        this.des = des;
    }

    public static CloseTypeEnum getByCloseTypeStr(String closeTypeStr){
        return Arrays.asList(values()).stream()
                .filter(closeTypeEnum -> closeTypeEnum.getCloseTypeStr().equals(closeTypeStr))
                .findFirst()
                .orElse(null);
    }

}
