예제 #1
0
    def __init__(self, strategy_name):
        StrategyBase.__init__(self, strategy_name)

        # loads score chart from file
        self.score_chart = scorechart.from_file(
            Config.get_instance().get(Config.SCORECHART_FILE)
        )
예제 #2
0
    def  __init__(self, symbol, manager):
        StrategyBase.__init__(self, symbol, "KillerNinja", manager)
        self.TAG = "KillerNinja"
        self.MAX_EARN = 25
        self.MAX_TRADE_TERM =20 #最长交易时间
        self.BREAK_PROFIT2 = 25
        self.BREAK_PROFIT2 = 20
        self.BREAK_PROFIT1 = 13
        self.RUSH_PROFIT = 15
        self.trade_dir = TradeDirection.BUYSELL

        self.hh = 0
        self.ll = 0
        self.event_recorder = EventRecorder("NinjaRecorder") #记录传入的event
        self.idor_record = KIndictorRecorder("idor_rd") #内部记录

        self.last_greaters = 0
        self.last_greaters_mark_bar = 0
        self.last_lesses = 0
        self.last_lesses_mark_bar = 0
        self.greaters = 0
        self.lesses = 0

        self.step = 0
        self.make_type = 0 # 1 overs and downs; 2 break flow; 3 break opposite; 4 open
        print("........[%s] running..........."%(self.TAG))
예제 #3
0
    def  __init__(self, symbol, manager):
        StrategyBase.__init__(self, symbol, "StrategyFlowStronger", manager)
        self.MAX_HOLD = 120
        self.TAG = "StrategyFlowStronger"

        self.trade_dir = TradeDirection.BUYSELL

        #big bang
        self.bigbang_up_height = 0
        self.bigbang_up_bar_start = 0
        self.bigbang_up_bar_end = 0

        self.bigbang_down_height = 0
        self.bigbang_down_bar_start = 0
        self.bigbang_down_bar_end = 0
        #
        self.region_last_h = 0
        self.region_last_l = 0

        self.break_region_bar = 0

        #调整 when loss
        self.adjust_loss = 0

        self.kpi = 0
        print("[%s] running..........."%(self.TAG))

        self.init_data()
예제 #4
0
    def __init__(self, symbol, managerager, HH2, HH1, LL1, LL2):
        StrategyBase.__init__(self, symbol, "StrategyGrid", managerager)
        self.TAG = "StrategyGrid"
        self.FLOW_GAP_BAR = 3
        self.MAX_HOLD = 100

        self.HH2 = HH2
        self.HH1 = HH1
        self.LL1 = LL1
        self.LL2 = LL2

        self.run_flag = True
        self.h_break_flag = False
        self.l_break_flag = False
        self.cur_price_flag = 0

        self.price_immediate = False

        self.H2_breakout_flag = False
        self.H2_breakout_index = 0
        self.L2_breakout_flag = False
        self.L2_breakout_index = 0

        self.mark_bar = 0

        self.report_flag = 0

        self.STD_CHECHSUM = 5

        print("[%s] runing............" % (self.TAG))
        print("[%s] hh2=%d hh1=%d ll1=%d ll2=%d" %
              (self.TAG, self.HH2, self.HH1, self.LL1, self.LL2))
예제 #5
0
    def __init__(self, strategy_name):
        StrategyBase.__init__(self, strategy_name)

        # uses score chart to determine best response
        self.score_chart = scorechart.from_file(
            Config.get_instance().get(Config.SCORECHART_FILE)
        )
예제 #6
0
    def __init__(self, symbol, manager):
        StrategyBase.__init__(self, symbol, "StrategyAvgCross", manager)

        self.MAX_HOLD = 159
        self.interval_bar = 20

        self.cross_avg_run_flag = 0
        self.total_bars_inday = 4 * 60 - 15

        self.short_term = 10
        self.long_term = 30

        self.init_crs_downs = 0
        self.init_crs_overs = 0

        self.trade_dir = TradeDirection.BUYSELL
        self.TAG = "StrategyAvgCross"

        #=============================================#
        self.lastday_bar = 2
        self.hh_20 = 0
        self.ll_20 = 0
        self.to_hh_20_bar = 0
        self.to_ll_20_bar = 0

        self.d_hh_3 = 0
        self.d_hh_3_bar = 0
        self.d_ll_3 = 0
        self.d_ll_3_bar = 0

        self.last_crossdown_bar = 999
        self.last_crossover_bar = 999

        print("[%s] runing............" % (self.TAG))
예제 #7
0
    def __init__(self, symbol, manager):
        StrategyBase.__init__(self, symbol, "StrategyBollDaily", manager)
        self.TAG = "StrategyBollDaily"
        self.boll_trade_dir = TradeDirection.BUYSELL
        self.mark_bar = 0

        self.debug("runing.......................")
예제 #8
0
    def __init__(self, strategy_name):
        StrategyBase.__init__(self, strategy_name)

        # uses score chart to determine best response
        self.score_chart = scorechart.from_file(
            Config.get_instance().get(Config.SCORECHART_FILE),
            self.bot_list
        )
예제 #9
0
    def __init__(self, symbol, manager):
        StrategyBase.__init__(self, symbol, "KillerS", manager)
        self.MAX_EARN = 30
        self.level = 3

        self.mark_start_bar = 0
        self.done_flag = False

        print("........[KillerS] running........")
예제 #10
0
    def __init__(self, strategy_name):
        """
        Initializes epsilon-greedy strategy selection method
        """

        StrategyBase.__init__(self, strategy_name)
        self.result_list = []
        self.match_list = []
        self.s_id = None
        self.epsilon = Config.get_instance().egreedy_exploration
예제 #11
0
    def __init__(self, symbol,manager):
        StrategyBase.__init__(self, symbol, "KillerPriceDirect",manager)
        
        self.hh = 0
        self.ll = 0
        self.TAG = "KillerPriceDirect"

        self.MAX_LOSS = 20

        print(".....[%s] running......."%(self.TAG))
예제 #12
0
    def __init__(self, strategy_name):
        """
        Initializes epsilon-greedy strategy selection method
        """

        StrategyBase.__init__(self, strategy_name)
        self.result_list = []
        self.match_list = []
        self.s_id = None
        self.epsilon = Config.get_instance().egreedy_exploration
예제 #13
0
    def __init__(self, symbol, manager):
        StrategyBase.__init__(self, symbol, "KillerL", manager)
        self.MAX_EARN = 50
        self.level = 1

        self.mark_start_id = 0

        self.init_flag = False
        self.done_flag = False

        print("........[KillerL] running........")
예제 #14
0
    def __init__(self, symbol, manager):
        StrategyBase.__init__(self, symbol, "McIndictors", manager)
        self.TAG = "McIndictors"
        self.symbol = symbol
        self.UPDATE_INTERVAL = 2  # minute

        self.trade_dir = TradeDirection.INVALID

        self.init_flag = False

        self.init_var()
예제 #15
0
    def __init__(self, strategy_name):
        """
        Initializes UCB1 strategy selection method
        """

        StrategyBase.__init__(self, strategy_name)
        self.formula = self.ucb1

        # overrides bot_list with bandit choices
        self.bot_list = Config.get_instance().get_bandit_choices()

        self.data = {choice: {'trials': 0, 'sum': 0, 'sum_of_squares': 0} for choice in self.bot_list}
예제 #16
0
    def __init__(self, strategy_name):
        """
        Initializes Exp3
        """

        StrategyBase.__init__(self, strategy_name)

        # overrides bot_list with bandit choices
        self.bot_list = Config.get_instance().get_bandit_choices()

        self.gamma = Config.get_instance().exp3_gamma
        self.alpha = 1
        #self.weights = {choice: 1.0 for choice in self.bot_list}
        self.weights = {choice: 0.0 for choice in self.bot_list}
예제 #17
0
    def __init__(self, strategy_name):
        StrategyBase.__init__(self, strategy_name)

        self.result_list = []
        self.match_list = []

        config = Config.get_instance()

        # read score chart from a file
        self.score_chart = scorechart.from_file(
            config.get(Config.SCORECHART_FILE))

        # get weights
        self.regrets = config.get(Config.INITIAL_REGRETS)
예제 #18
0
    def __init__(self, strategy_name):
        """
        Initializes Exp3
        """

        StrategyBase.__init__(self, strategy_name)

        # overrides bot_list with bandit choices
        self.bot_list = Config.get_instance().get_bandit_choices()

        self.gamma = Config.get_instance().exp3_gamma
        self.alpha = 1
        #self.weights = {choice: 1.0 for choice in self.bot_list}
        self.weights = {choice: 0.0 for choice in self.bot_list}
예제 #19
0
    def __init__(self, symbol, manager):
        StrategyBase.__init__(self, symbol, "RiskManager", manager)
        self.TAG = "RiskManager"
        self.update_interval = 5
        self.trade_dir = TradeDirection.BUYSELL
        self.hold_pos = 0
        self.mark_price = 0
        self.ABS_MAX_LOSS = 20
        self.hold_profit = 0

        self.filter_head_bar = 5
        self.bar_count = 0

        self.exit_internal = 0

        self.last_bigbang_up_id = 99
        self.last_bigbang_down_id = 99

        self.lastday_bar = 2
        self.hh_50 = 0
        self.ll_50 = 0
        self.to_hh_50_bar = 0
        self.to_ll_50_bar = 0

        self.key_hh = 0
        self.key_ll = 0
        self.key_mark_bar = 0
        self.key_mark_flag = 0

        self.dklines = []
        self.account_recorder = IndicatorRecorder("account")
        self.account_recorder.set_interval(1)

        self.capital_record = CapitalRecord(0)

        #key_price =
        self.kp = KParser()
        self.kpt_record = KPatternRecord("RiskHave")
        self.task_list = []

        #c = ['id', 'account']
        #self.df_profit = pd.DataFrame(columns=c)

        self.controler_manager = ControlerManager()

        #self.this_new_data()
        print("[RiskManager] running .....................")

        self.define_data()
예제 #20
0
    def __init__(self, strategy_name):
        StrategyBase.__init__(self, strategy_name)

        self.result_list = []
        self.match_list = []
        
        config = Config.get_instance()
        
        # read score chart from a file
        self.score_chart = scorechart.from_file(
            config.get(Config.SCORECHART_FILE)
        )
        
        # get weights
        self.regrets = config.get(Config.INITIAL_REGRETS)
예제 #21
0
    def __init__(self, symbol, manager):
        StrategyBase.__init__(self, symbol, "KillerRush", manager)
        self.TAG = "KillerRush"
        self.MAX_EARN = 45
        self.MAX_TRADE_TERM = 65  #最长交易时间
        self.trade_dir = TradeDirection.BUYSELL

        self.hh = 0
        self.ll = 0

        self.inited = False
        self.start_bar_id = 0

        self.step = 0
        print("........[%s] running..........." % (self.TAG))
예제 #22
0
    def __init__(self, strategy_name):
        """
        Initializes Epsilon-Nash strategy
        :param epsilon: probability of EXPLOITATION
        :return:
        """
        StrategyBase.__init__(self, strategy_name)
        # probability of exploitation (different of e-greedy which is exploration)
        self.epsilon = Config.get_instance().enash_exploitation

        # Nash equilibrium strategy
        self.nash = nash.Nash('Nash inside e-Nash')

        # exploitation strategy
        self.exploitation = frequentist.Frequentist(
            'Frequentist inside e-Nash')
예제 #23
0
    def __init__(self, symbol, manager):
        StrategyBase.__init__(self, symbol, "StrategyThreeStepLDaliy", manager)
        self.MAX_EARN = 50
        self.level = 1

        self.mark_start_id = 0

        self.init_flag = False
        self.done_flag = False

        self.last_red_or_green = 0
        self.continue_flag = False
        self.low_range_flag = False
        self.hh_3day = 0
        self.ll_3day = 0
        self.skip_flag = False
        print("........[StrategyThreeStepLDaliy] running........")
예제 #24
0
    def __init__(self, symbol, manager):
        StrategyBase.__init__(self, symbol, "StrategyKeyPrice", manager)
        self.TAG = "StrategyKeyPrice"
        self.key_price = 0

        self.inited = False
        self.init_price_state = 0

        self.KEY_MA = 1
        self.KEY_STRONG = 2
        self.KEY_GOOG_NUM = 3

        self.auto = True

        self.KParser = KParser()

        self.debug("running..........")
예제 #25
0
    def __init__(self, symbol, manager):
        StrategyBase.__init__(self, symbol, "KillerTank", manager)
        self.TAG = "KillerTank"
        self.SMALL_COUNT = 35
        self.LARGE_COUNT = 60
        self.EXTENDED_BARS = 20
        self.std_overs_max = 130
        self.std_downs_max = 130

        self.trade_dir = TradeDirection.BUYSELL
        self.manager = manager

        self.run_flag = True
        self.position = 0
        self.cond_down_count = 0
        self.cond_up_count = 0
        self.entry_bar = 0

        self.ups = 0
        self.downs = 0
        self.last_uper_bar = -999
        self.last_downer_bar = -999
        self.last_uper_count = 0
        self.last_downer_count = 0

        self.low_range_flag = False
        self.count_for_checksum = 10

        if (self.trade_dir == TradeDirection.SELLONLY):
            self.cond_down_count = self.LARGE_COUNT
            self.cond_up_count = self.SMALL_COUNT
        elif (self.trade_dir == TradeDirection.BUYONLY):
            self.cond_down_count = self.SMALL_COUNT
            self.cond_up_count = self.LARGE_COUNT
        else:
            self.cond_down_count = 50
            self.cond_up_count = 50

        c = ['id', 'time', 'avg']
        self.list_ = pd.DataFrame(columns=c)

        print("[%s] running..........." % (self.TAG))

        self.debug("cond_down_count=%d cond_up_count=%d" %
                   (self.cond_down_count, self.cond_up_count))
예제 #26
0
    def __init__(self, symbol, manager):
        StrategyBase.__init__(self, symbol, "StrategyWatcher", manager)
        #def __init__(self):

        self.TAG = "StrategyWatcher"
        self.MAX_LOSS = 25

        #self.manager = manager
        self.ATR_day = 60
        self.last_inrange_bar = 999
        self.last_inrange_height = 0
        self.last_inrange_high = 0
        self.last_inrange_low = 0
        self.last_big_red_candle = 999
        self.last_big_green_candle = 999
        self.last_break_bar = 999
        self.cur_price = 0

        self.trade_dir = TradeDirection.BUYSELL
        self.position = 0

        #preset
        self.preset_dir = TradeDirection.INVALID

        ##runing time##
        self.inited = False
        self.run_break_flag = 0

        self.entry_bar = 999
        self.entry_price = 0

        self.cond_flag = 0
        self.cond_mark_bar = 0

        self.BreakOut = 0
        self.TrendGoOn = 1
        self.GoBack = 2

        #parse
        self.trend_status = TrendStatus.Unkown
        self.predict_walkpath = WalkPath.InRange

        self.my_print("running.......")
예제 #27
0
    def __init__(self, symbol, manager):
        StrategyBase.__init__(self, symbol, "StrategyWaves", manager)
        self.TAG = "StrategyWaves"
        self.period = 1  #min
        self.MAX_HOLD = 55
        self.run_flag = True
        self.manager = manager

        self.position = 0
        self.trade_dir = 0

        self.init_flag = False
        self.hh = 0
        self.ll = 0

        self.w_checksum = 0
        self.m_checksum = 0

        self.ups_at_open = 0
        self.downs_at_open = 0

        self.swing_trade_dir = TradeDirection.BUYONLY
        print("[%s] running....." % (self.TAG))
예제 #28
0
 def __init__(self, strategy_name):
     StrategyBase.__init__(self, strategy_name)
     self.result_list = []
     self.match_list = []
     self.s_id = None
     pass
예제 #29
0
 def __init__(self, strategy_name):
     StrategyBase.__init__(self, strategy_name)
예제 #30
0
 def __init__(self, strategy_name):
     StrategyBase.__init__(self, strategy_name)
     self.result_list = []
     self.match_list = []
     self.s_id = None
     pass
예제 #31
0
 def __init__(self, strategy_name):
     StrategyBase.__init__(self, strategy_name)
예제 #32
0
 def __init__(self, symbol, manager):
     StrategyBase.__init__(self, symbol, "StrategyAtr", manager)