예제 #1
0
 def build_args(self, cmds):
   args = collections.defaultdict(dict)
   strats = filter(Strat.is_valid, cmds.keys())
   for strat in strats:
     params = cmds[strat]
     strat = Strat.get_strat(strat)
     args["strategy"][strat] = params
   masks = filter(Mask.is_valid, cmds.keys())
   for mask in masks:
     args["masks"][mask] = cmds[mask]
   return args
예제 #2
0
    def sign(self, symbol: str, timeframe: str):
        """



    """

        df = self.exchange.GetSymbolKlines(symbol=symbol, interval=timeframe)
        #df = self.exchange.technicalA(df)

        df['3_ema'] = TA.EMA(df, 3)
        df['25_sma'] = TA.SMA(df, 25)
        #df['10_ema'] = TA.EMA(df, 10)
        #df['55_ema'] = TA.EMA(df, 55)

        #df2= TA.MACD(df = df, period_fast = 30, period_slow = 20, signal = 30)
        df2 = TA.MACD(df, period_fast=30, period_slow=20, signal=30)
        df2["HIST"] = df2["MACD"] - df2["SIGNAL"]
        df["MACD"] = df2["MACD"]
        df["SIGNAL"] = df2["SIGNAL"]
        df["HIST"] = df2["HIST"]
        df['HIST_ESMA'] = df['3_ema'] - df['25_sma']

        #ADX
        df["ADX"] = TA.ADX(df)
        df["ADX"] = df["ADX"].fillna(0)
        df["HIST_ESMA"] = df["HIST_ESMA"].fillna(0)

        self.slopCalculator(df)

        df.to_csv('./export.csv', sep='\t')
        print(df)
        exit()
        df["sign"] = ""
        entrypoint = 'off'
        for i in range(0, len(df['close']) - 1):
            #strategy_result = Strategies.marginTrade(df = df, step = i)
            strategy_result = Strategies.tlStrategy(df=df, step=i)

            if strategy_result['signal'] == 'BUY' and entrypoint == 'off':
                #print('buy: ',i)
                self.buy_signals.append([df['time'][i], df['low'][i]])
                df.loc[i, 'sign'] = 'buy'
                entrypoint = 'on'
            elif strategy_result['signal'] == 'SELL' and entrypoint == 'on':
                #print('sell: ',i)
                df.loc[i, 'sign'] = 'sell'
                self.sell_signals.append([df['time'][i], df['low'][i]])

                entrypoint = 'off'

        #print(self.sell_signals)
        self.chart.plotData(df, symbol, timeframe, self.param,
                            self.buy_signals, self.sell_signals)
예제 #3
0
 def buildStrategy(self, strats):
   strat = strats.keys()[0]
   params = strats[strat]
   return Strat.build(strat, params)