Example #1
0
    def is6hEMA1226Bull(self):
        try:
            if isinstance(self.ema1226_6h_cache, pd.DataFrame):
                df_data = self.ema1226_6h_cache
            elif self.exchange == 'coinbasepro':
                api = CBPublicAPI()
                df_data = api.getHistoricalData(self.market, 21600)
                self.ema1226_6h_cache = df_data
            elif self.exchange == 'binance':
                api = BPublicAPI()
                df_data = api.getHistoricalData
                self.ema1226_6h_cache = df_data(self.market, '6h')
            else:
                return False

            ta = TechnicalAnalysis(df_data)

            if 'ema12' not in df_data:
                ta.addEMA(12)

            if 'ema26' not in df_data:
                ta.addEMA(26)

            df_last = ta.getDataFrame().copy().iloc[-1, :]
            df_last['bull'] = df_last['ema12'] > df_last['ema26']
            return bool(df_last['bull'])
        except Exception:
            return False
    def is1hEMA1226Bull(self):
        try:
            if self.exchange == 'coinbasepro':
                api = CBPublicAPI()
                df_data = api.getHistoricalData(self.market, 3600)
            elif self.exchange == 'binance':
                api = BPublicAPI()
                df_data = api.getHistoricalData(self.market, '1h')
            else:
                return False

            ta = TechnicalAnalysis(df_data)
            ta.addEMA(12)
            ta.addEMA(26)
            df_last = ta.getDataFrame().copy().iloc[-1, :]
            df_last['bull'] = df_last['ema12'] > df_last['ema26']
            return bool(df_last['bull'])
        except Exception:
            return False
Example #3
0
    def is6hEMA1226Bull(self, iso8601end: str = ''):
        try:
            if self.isSimulation() and isinstance(self.ema1226_6h_cache,
                                                  pd.DataFrame):
                df_data = self.ema1226_6h_cache[(self.ema1226_6h_cache['date']
                                                 <= iso8601end)]
            elif self.exchange == 'coinbasepro':
                api = CBPublicAPI()
                df_data = api.getHistoricalData(self.market, 21600)
                self.ema1226_6h_cache = df_data
            elif self.exchange == 'binance':
                api = BPublicAPI()
                df_data = api.getHistoricalData(self.market, '6h')
                self.ema1226_6h_cache = df_data
            else:
                return False

            ta = TechnicalAnalysis(df_data)

            if 'ema12' not in df_data:
                ta.addEMA(12)

            if 'ema26' not in df_data:
                ta.addEMA(26)

            df_last = ta.getDataFrame().copy().iloc[-1, :]
            df_last['bull'] = df_last['ema12'] > df_last['ema26']

            Logger.debug("---- EMA1226 6H Check----")
            if self.isSimulation():
                Logger.debug("simdate: " + str(df_last['date']))
                Logger.debug("ema12 6h: " + str(df_last['ema12']))
                Logger.debug("ema26 6h: " + str(df_last['ema26']))

            Logger.debug("bull 6h: " +
                         str(df_last['ema12'] > df_last['ema26']))

            return bool(df_last['bull'])
        except Exception:
            return False
Example #4
0
            0).astype(int)
        df_markets.sort_values(by=["market"], ascending=True, inplace=True)
        df_markets.set_index("market", inplace=True)

        print("Processing, please wait...")

        ROW = 1
        for market, data in df_markets.T.iteritems():
            print(
                f"[{ROW}/{len(df_markets)}] {market} {round((ROW/len(df_markets))*100, 2)}%"
            )
            try:
                if int(data["volume"]) > 0:
                    ta = TechnicalAnalysis(
                        api.getHistoricalData(market, GRANULARITY, None))
                    ta.addEMA(12)
                    ta.addEMA(26)
                    ta.addATR(72)
                    df_1h = ta.getDataFrame()
                    df_1h["ema12ltema26"] = df_1h.ema12 < df_1h.ema26
                    df_1h_last = df_1h.tail(1)

                    # volatility over the last 72 hours
                    df_markets.at[market,
                                  "atr72"] = float(df_1h_last[["atr72"
                                                               ]].values[0][0])
                    df_markets["atr72_pcnt"] = (df_markets["atr72"] /
                                                df_markets["price"] *
                                                100).round(2)
                    df_markets.at[market, "buy_next"] = df_1h_last[
                        df_1h_last["market"] ==
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
from models.Trading import TechnicalAnalysis
from models.CoinbasePro import PublicAPI
from views.TradingGraphs import TradingGraphs

market = 'BTC-GBP'
granularity = 3600

api = PublicAPI()
tradingData = api.getHistoricalData(market, granularity)
technicalAnalysis = TechnicalAnalysis(tradingData)
technicalAnalysis.addEMA(12)
technicalAnalysis.addEMA(26)
technicalAnalysis.addCandleHammer()
technicalAnalysis.addCandleInvertedHammer()
technicalAnalysis.addCandleShootingStar()
technicalAnalysis.addCandleHangingMan()
technicalAnalysis.addCandleThreeWhiteSoldiers()
technicalAnalysis.addCandleThreeBlackCrows()
technicalAnalysis.addCandleDoji()
technicalAnalysis.addCandleThreeLineStrike()
technicalAnalysis.addCandleTwoBlackGapping()
technicalAnalysis.addCandleEveningStar()
technicalAnalysis.addCandleAbandonedBaby()
df = technicalAnalysis.getDataFrame()

tradinggraphs = TradingGraphs(technicalAnalysis)
tradinggraphs.renderEMA12EMA26CloseCandles()
#tradinggraphs.renderEMA12EMA26CloseCandles(30, 'candles.png')