package top.baogutang.strategy.commons.configs;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@ConfigurationProperties(prefix = "app")
public class AppProperties {

    private Account account;
    private List<String> timeframes;
    private List<SymbolConfig> symbols;
    private Alert alert;

    public static class Account {
        private double equity;
        private double riskPercent;
        private double maxDailyLossPercent;
        private int maxConsecutiveLoss;
        private double portfolioMaxOpenRiskPercent;

        public double getEquity() {
            return equity;
        }

        public void setEquity(double equity) {
            this.equity = equity;
        }

        public double getRiskPercent() {
            return riskPercent;
        }

        public void setRiskPercent(double riskPercent) {
            this.riskPercent = riskPercent;
        }

        public double getMaxDailyLossPercent() {
            return maxDailyLossPercent;
        }

        public void setMaxDailyLossPercent(double maxDailyLossPercent) {
            this.maxDailyLossPercent = maxDailyLossPercent;
        }

        public int getMaxConsecutiveLoss() {
            return maxConsecutiveLoss;
        }

        public void setMaxConsecutiveLoss(int maxConsecutiveLoss) {
            this.maxConsecutiveLoss = maxConsecutiveLoss;
        }

        public double getPortfolioMaxOpenRiskPercent() {
            return portfolioMaxOpenRiskPercent;
        }

        public void setPortfolioMaxOpenRiskPercent(double portfolioMaxOpenRiskPercent) {
            this.portfolioMaxOpenRiskPercent = portfolioMaxOpenRiskPercent;
        }
    }

    public static class SymbolConfig {
        private String instId;
        private boolean enable = true;
        private Double riskPercentOverride;
        private Levels levels;
        private List<String> strategies;

        public String getInstId() {
            return instId;
        }

        public void setInstId(String instId) {
            this.instId = instId;
        }

        public boolean isEnable() {
            return enable;
        }

        public void setEnable(boolean enable) {
            this.enable = enable;
        }

        public Double getRiskPercentOverride() {
            return riskPercentOverride;
        }

        public void setRiskPercentOverride(Double riskPercentOverride) {
            this.riskPercentOverride = riskPercentOverride;
        }

        public Levels getLevels() {
            return levels;
        }

        public void setLevels(Levels levels) {
            this.levels = levels;
        }

        public List<String> getStrategies() {
            return strategies;
        }

        public void setStrategies(List<String> strategies) {
            this.strategies = strategies;
        }

        public static class Levels {
            private double s1High, s1Low, s2High, s2Low;
            private double r1Low, r1High, r2Low, r2High, breakoutConfirm;

            public double getS1High() {
                return s1High;
            }

            public void setS1High(double s1High) {
                this.s1High = s1High;
            }

            public double getS1Low() {
                return s1Low;
            }

            public void setS1Low(double s1Low) {
                this.s1Low = s1Low;
            }

            public double getS2High() {
                return s2High;
            }

            public void setS2High(double s2High) {
                this.s2High = s2High;
            }

            public double getS2Low() {
                return s2Low;
            }

            public void setS2Low(double s2Low) {
                this.s2Low = s2Low;
            }

            public double getR1Low() {
                return r1Low;
            }

            public void setR1Low(double r1Low) {
                this.r1Low = r1Low;
            }

            public double getR1High() {
                return r1High;
            }

            public void setR1High(double r1High) {
                this.r1High = r1High;
            }

            public double getR2Low() {
                return r2Low;
            }

            public void setR2Low(double r2Low) {
                this.r2Low = r2Low;
            }

            public double getR2High() {
                return r2High;
            }

            public void setR2High(double r2High) {
                this.r2High = r2High;
            }

            public double getBreakoutConfirm() {
                return breakoutConfirm;
            }

            public void setBreakoutConfirm(double breakoutConfirm) {
                this.breakoutConfirm = breakoutConfirm;
            }
        }
    }

    public static class Alert {
        private DingTalk dingTalk;

        public DingTalk getDingTalk() {
            return dingTalk;
        }

        public void setDingTalk(DingTalk dingTalk) {
            this.dingTalk = dingTalk;
        }

        public static class DingTalk {
            private List<DingTalkRobot> robots;

            public List<DingTalkRobot> getRobots() {
                return robots;
            }

            public void setRobots(List<DingTalkRobot> robots) {
                this.robots = robots;
            }
        }

        public static class DingTalkRobot {
            private String name;
            private String webhook;
            private Security security;
            private List<String> atMobiles;
            private boolean atAll;

            public String getName() {
                return name;
            }

            public void setName(String name) {
                this.name = name;
            }

            public String getWebhook() {
                return webhook;
            }

            public void setWebhook(String webhook) {
                this.webhook = webhook;
            }

            public Security getSecurity() {
                return security;
            }

            public void setSecurity(Security security) {
                this.security = security;
            }

            public List<String> getAtMobiles() {
                return atMobiles;
            }

            public void setAtMobiles(List<String> atMobiles) {
                this.atMobiles = atMobiles;
            }

            public boolean isAtAll() {
                return atAll;
            }

            public void setAtAll(boolean atAll) {
                this.atAll = atAll;
            }
        }

        public static class Security {
            private boolean enable;
            private String secret;

            public boolean isEnable() {
                return enable;
            }

            public void setEnable(boolean enable) {
                this.enable = enable;
            }

            public String getSecret() {
                return secret;
            }

            public void setSecret(String secret) {
                this.secret = secret;
            }
        }
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    public List<String> getTimeframes() {
        return timeframes;
    }

    public void setTimeframes(List<String> timeframes) {
        this.timeframes = timeframes;
    }

    public List<SymbolConfig> getSymbols() {
        return symbols;
    }

    public void setSymbols(List<SymbolConfig> symbols) {
        this.symbols = symbols;
    }

    public Alert getAlert() {
        return alert;
    }

    public void setAlert(Alert alert) {
        this.alert = alert;
    }
}
