package top.baogutang.strategy.strategies;

import top.baogutang.strategy.commons.configs.AppProperties;

import java.util.*;

public class StrategyFactory {
    public static Map<String, List<Strategy>> build(AppProperties props) {
        Map<String, List<Strategy>> map = new HashMap<String, List<Strategy>>();
        for (AppProperties.SymbolConfig sc : props.getSymbols()) {
            if (!sc.isEnable()) continue;
            AppProperties.SymbolConfig.Levels lv = sc.getLevels();
            List<Strategy> list = new ArrayList<Strategy>();
            for (String name : sc.getStrategies()) {
                if ("LowReboundLong".equals(name)) {
                    list.add(new StrategyLowReboundLong(
                            lv.getS1High(), lv.getS1Low(), lv.getS2High(), lv.getS2Low()));
                } else if ("MeanRevertShort".equals(name)) {
                    list.add(new StrategyMeanRevertShort(lv.getR1Low(), lv.getR1High()));
                } else if ("BreakdownRetestShort".equals(name)) {
                    list.add(new StrategyBreakdownRetestShort(lv.getS1Low()));
                } else if ("BreakoutRetestLong".equals(name)) {
                    list.add(new StrategyBreakoutRetestLong(
                            lv.getBreakoutConfirm(), lv.getR2Low(), lv.getR2High()));
                }
            }
            map.put(sc.getInstId(), list);
        }
        return map;
    }
}
