コード例 #1
0
    def __init__(self, symbol):
        self.symbol = symbol
        self.exchange = bi.Binance()
        self.df = self.exchange.GetSymbolData(symbol, '4h')
        self.last_price = self.df['close'][len(self.df['close'])-1]
        self.buy_signals = []

        try:
            self.df['fast_sma'] = sma(self.df['close'].tolist(), 10)
            self.df['slow_sma'] = sma(self.df['close'].tolist(), 30)
            self.df['low_boll'] = lbb(self.df['close'].tolist(), 14)
            self.df['up_boll'] = ubb(self.df['close'].tolist(), 14)
            self.df['vwap'] = (self.df['volume']*(self.df['close'])).cumsum() / self.df['volume'].cumsum()
            #self.df['vwap'] = (self.df['volume']*(self.df['high']+self.df['low'])/2).cumsum() / self.df['volume'].cumsum()
            self.df['vwma'] = self.vwma(14)

            # From Indicators
            self.df = ind.macd(self.df)
            self.df = ind.money_flow_index(self.df)
            self.df = ind.rsi(self.df)

            #From Finta
            vw_macd = TA.VW_MACD(self.df)
            self.df['vw_macd'] = vw_macd['MACD']
            self.df['vw_macd_sig'] = vw_macd['SIGNAL']
            

        except Exception as e:
            print(" Exception raised when trying to compute indicators on "+self.symbol)
            print(e)
            return None
コード例 #2
0
def screen():
    client = Client("api-key", "api-secret", {"verify": False, "timeout": 20})
    positiveCoin = get_positive_coin.positiveCoin
    bullishKScoin = []
    for m in positiveCoin:
        candles = client.get_klines(symbol=m, interval=client.KLINE_INTERVAL_30MINUTE)
        if candles[-2][1] < candles[-2][4] <= candles[-1][1] < candles[-1][4]:
            bullishKScoin.append(m)

    macdCoin = []
    for m in bullishKScoin:
        candles = client.get_klines(symbol=m, interval=client.KLINE_INTERVAL_1HOUR)
        close = []
        for n in candles:
            close.append(float(n[4]))
        mac = macd(close, 12, 26)
        macs = macds(mac)
        mach = macdh(mac, macs)
        # if mach[-1] > 0 and (macs[-1] - macs[-2]) > 0 and (mac[-1] - mac[-2]) > 0:
        #     macdCoin.append(m)
        if mach[-1] > 0 and (macs[-1] - macs[-2]) > 0 and (mac[-1] - mac[-2]) > 0:
            macdCoin.append(m)

    bollCoin = []
    for m in macdCoin:
        candles = client.get_klines(symbol=m, interval=client.KLINE_INTERVAL_1HOUR)
        close = []
        for n in candles:
            close.append(float(n[4]))
        lb = lbb(close, 20, 2)
        mb = mbb(close, 20, 2)
        ub = ubb(close, 20, 2)

        if lb[-1] < close[-1] < ((0.8 * ub[-1]) + (0.2 * mb[-1])):
            bollCoin.append(m)

    maxDemandRatio = 0
    buyingCoin = ''
    for m in bollCoin:
        depth = client.get_order_book(symbol=m)
        buyingVol = 0
        sellingVol = 0
        for n in depth['bids'][0:20]:
            buyingVol = buyingVol + float(n[1])
        for n in depth['asks'][0:20]:
            sellingVol = sellingVol + float(n[1])
        demandRatio = buyingVol / sellingVol
        print(demandRatio)
        print(maxDemandRatio)
        if demandRatio > maxDemandRatio:
            maxDemandRatio = demandRatio
            buyingCoin = m

    print(bullishKScoin)
    print(macdCoin)
    print(bollCoin)
    print(buyingCoin)
    return buyingCoin
コード例 #3
0
	def __init__(self, symbol):
		self.symbol = symbol
		self.exchange = Binance()
		self.df = self.exchange.GetSymbolData(symbol, '4h')
		self.last_price = self.df['close'][len(self.df['close'])-1]
		self.buy_signals = []

		try:
			self.df['fast_sma'] = sma(self.df['close'].tolist(), 10)
			self.df['slow_sma'] = sma(self.df['close'].tolist(), 30)
			self.df['low_boll'] = lbb(self.df['close'].tolist(), 14)
		except Exception as e:
			print(" Exception raised when trying to compute indicators on "+self.symbol)
			print(e)
			return None
コード例 #4
0
    def __init__(self, symbol, timeframe: str = '4h'):
        self.symbol = symbol
        self.exchange = Binance()
        self.df = self.exchange.get_symbol_data(symbol, timeframe)
        self.last_price = self.df['close'][len(self.df['close']) - 1]

        try:
            self.df['short_sma'] = sma(self.df['close'].tolist(), 10)
            self.df['long_sma'] = sma(self.df['close'].tolist(), 30)
            self.df['low_boll'] = lbb(self.df['close'].tolist(), 14)
        except Exception as e:
            print(' Exception when trying to computer indicators on: ' +
                  self.symbol)
            print(e)
            return None
コード例 #5
0
    def __init__(self, symbol, timeframe='4h'):
        self.symbol = symbol
        self.timeframe = timeframe
        self.exchange = Binance()
        self.df = self.exchange.GetSymbolData(symbol, timeframe)
        self.last_price = self.df['close'][len(self.df['close']) - 1]

        try:
            self.df['fast_sma'] = sma(self.df['close'].tolist(), 10)
            self.df['slow_sma'] = sma(self.df['close'].tolist(), 30)
            self.df['low_boll'] = lbb(self.df['close'].tolist(), 14)
        except Exception as e:
            print(
                "Exception occurred when attempting to compute indicators on "
                + self.symbol)
            print(e)
            return None
コード例 #6
0
def screen():
    client = Client("api-key", "api-secret", {"verify": False, "timeout": 20})
    positiveCoin = get_positive_coin.positiveCoin

    bollCoin = []
    for m in positiveCoin:
        candles = client.get_klines(symbol=m,
                                    interval=client.KLINE_INTERVAL_15MINUTE)
        close = []
        for n in candles:
            close.append(float(n[4]))
        pb = pbb(close, 20, 2.0, 2.0)
        lb = lbb(close, 20, 2.0)
        ub = ubb(close, 20, 0.2)
        if pb[-1] > 50 and ((ub[-1] - lb[-1]) / lb[-1]) > 0.03:
            if candles[-2][1] < candles[-2][4]:
                if candles[-2][4] <= candles[-1][1]:
                    if candles[-1][1] < candles[-1][4]:
                        bollCoin.append(m)

    buyingCoin = ''
    maxDemandRatio = 0
    for m in bollCoin:
        depth = client.get_order_book(symbol=m)
        buyingVol = 0
        sellingVol = 0
        for n in depth['bids'][0:20]:
            buyingVol = buyingVol + float(n[1])
        for n in depth['asks'][0:20]:
            sellingVol = sellingVol + float(n[1])
        demandRatio = buyingVol / sellingVol
        print(demandRatio)
        print(maxDemandRatio)
        if demandRatio > maxDemandRatio:
            maxDemandRatio = demandRatio
            buyingCoin = m

    if maxDemandRatio < 1.5:
        buyingCoin = ''

    print(bollCoin)
    print(buyingCoin)
    return buyingCoin
コード例 #7
0
ファイル: cryptocalculator.py プロジェクト: dappsar/CryptoViz
 def lbb(self, df):
     period = 20
     if len(df) < period:
         period = len(df) // 2
     data = lbb(df, period)
     return (data)
コード例 #8
0
# In[5]:


data = socket.get_candles(instrument = 'GBP/USD', period = 'D1', start = dt.datetime(2016,1,1), end = dt.datetime(2018, 6, 10))


# In[6]:


#Define useful variables


data['upper_band'] = ubb(data['askclose'], period = 20)
data['mid_band'] = mbb(data['askclose'], period = 20 )
data['lower_band'] = lbb(data['askclose'], period = 20 )
data['percent_b'] = percent_b(data['askclose'], period =20)
data


# In[7]:


fig = plt.figure(figsize=(12,8))

ax1 = fig.add_subplot(111,  xlabel = 'Date',ylabel='Close')


data['askclose'].plot(ax=ax1, color='r', lw=1)
data['upper_band'].plot(ax=ax1, color = 'b', lw= 1)
data['mid_band'].plot(ax=ax1, color = 'g', lw= 1)
コード例 #9
0
def lower_bollinger_band(data, period):
    return lbb(data, period)