예제 #1
0
    def test_tickers(self):
        exchange_population = 3
        asset_population = 15

        # exchanges = select_random_exchanges(
        #     exchange_population,
        #     features=['fetchTickers'],
        # )  # Type: list[Exchange]
        exchanges = list(get_exchanges(['binance']).values())
        for exchange in exchanges:
            exchange.init()

            if exchange.assets and len(exchange.assets) >= asset_population:
                assets = select_random_assets(
                    exchange.assets, asset_population
                )
                tickers = exchange.tickers(assets)

                assert len(tickers) == asset_population

            else:
                print(
                    'skipping exchange without assets {}'.format(exchange.name)
                )
                exchange_population -= 1
        pass
예제 #2
0
    def test_tickers(self):
        exchange_population = 3
        asset_population = 15

        # exchanges = select_random_exchanges(
        #     exchange_population,
        #     features=['fetchTickers'],
        # )  # Type: list[Exchange]
        exchanges = list(get_exchanges(['binance']).values())
        for exchange in exchanges:
            exchange.init()

            if exchange.assets and len(exchange.assets) >= asset_population:
                assets = select_random_assets(
                    exchange.assets, asset_population
                )
                tickers = exchange.tickers(assets)

                assert len(tickers) == asset_population

            else:
                print(
                    'skipping exchange without assets {}'.format(exchange.name)
                )
                exchange_population -= 1
        pass
예제 #3
0
    def test_history_compare_exchanges(self):
        exchanges = get_exchanges(['bittrex', 'bitfinex', 'poloniex'])
        assets = get_common_assets(exchanges)

        date = rnd_history_date_days()
        bar_count = rnd_bar_count()
        data = self.data_portal_backtest.get_history_window(
            assets=assets,
            end_dt=date,
            bar_count=bar_count,
            frequency='1d',
            field='close',
            data_frequency='daily')

        log.info('found history window: {}'.format(data))
예제 #4
0
    def test_history_compare_exchanges(self):
        exchanges = get_exchanges(['bittrex', 'bitfinex', 'poloniex'])
        assets = get_common_assets(exchanges)

        date = rnd_history_date_days()
        bar_count = rnd_bar_count()
        data = self.data_portal_backtest.get_history_window(
            assets=assets,
            end_dt=date,
            bar_count=bar_count,
            frequency='1d',
            field='close',
            data_frequency='daily'
        )

        log.info('found history window: {}'.format(data))
예제 #5
0
    def setup(self):
        log.info('creating bitfinex exchange')
        exchanges = get_exchanges(['bitfinex', 'bittrex', 'poloniex'])
        open_calendar = get_calendar('OPEN')
        asset_finder = ExchangeAssetFinder()

        self.data_portal_live = DataPortalExchangeLive(
            exchanges=exchanges,
            asset_finder=asset_finder,
            trading_calendar=open_calendar,
            first_trading_day=pd.to_datetime('today', utc=True))

        self.data_portal_backtest = DataPortalExchangeBacktest(
            exchanges=exchanges,
            asset_finder=asset_finder,
            trading_calendar=open_calendar,
            first_trading_day=None  # will set dynamically based on assets
        )
예제 #6
0
    def setup(self):
        log.info('creating bitfinex exchange')
        exchanges = get_exchanges(['bitfinex', 'bittrex', 'poloniex'])
        open_calendar = get_calendar('OPEN')
        asset_finder = ExchangeAssetFinder()

        self.data_portal_live = DataPortalExchangeLive(
            exchanges=exchanges,
            asset_finder=asset_finder,
            trading_calendar=open_calendar,
            first_trading_day=pd.to_datetime('today', utc=True)
        )

        self.data_portal_backtest = DataPortalExchangeBacktest(
            exchanges=exchanges,
            asset_finder=asset_finder,
            trading_calendar=open_calendar,
            first_trading_day=None  # will set dynamically based on assets
        )
예제 #7
0
    def test_candles(self):
        exchange_population = 3
        asset_population = 3

        # exchanges = select_random_exchanges(
        #     population=exchange_population,
        #     features=['fetchOHLCV'],
        # )  # Type: list[Exchange]
        exchanges = list(get_exchanges(['binance']).values())
        for exchange in exchanges:
            exchange.init()

            if exchange.assets and len(exchange.assets) >= asset_population:
                frequencies = exchange.get_candle_frequencies()
                freq = random.sample(frequencies, 1)[0]

                bar_count = random.randint(1, 10)
                end_dt = pd.Timestamp.utcnow().floor('1T')
                dt_range = pd.date_range(
                    end=end_dt, periods=bar_count, freq=freq
                )
                assets = select_random_assets(
                    exchange.assets, asset_population
                )

                candles = exchange.get_candles(
                    freq=freq,
                    assets=assets,
                    bar_count=bar_count,
                    start_dt=dt_range[0],
                )

                assert len(candles) == asset_population

            else:
                print(
                    'skipping exchange without assets {}'.format(exchange.name)
                )
                exchange_population -= 1
        pass
예제 #8
0
    def test_candles(self):
        exchange_population = 3
        asset_population = 3

        # exchanges = select_random_exchanges(
        #     population=exchange_population,
        #     features=['fetchOHLCV'],
        # )  # Type: list[Exchange]
        exchanges = list(get_exchanges(['binance']).values())
        for exchange in exchanges:
            exchange.init()

            if exchange.assets and len(exchange.assets) >= asset_population:
                frequencies = exchange.get_candle_frequencies()
                freq = random.sample(frequencies, 1)[0]

                bar_count = random.randint(1, 10)
                end_dt = pd.Timestamp.utcnow().floor('1T')
                dt_range = pd.date_range(
                    end=end_dt, periods=bar_count, freq=freq
                )
                assets = select_random_assets(
                    exchange.assets, asset_population
                )

                candles = exchange.get_candles(
                    freq=freq,
                    assets=assets,
                    bar_count=bar_count,
                    start_dt=dt_range[0],
                )

                assert len(candles) == asset_population

            else:
                print(
                    'skipping exchange without assets {}'.format(exchange.name)
                )
                exchange_population -= 1
        pass