Exemplo n.º 1
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))
Exemplo n.º 2
0
    def setup(self):
        log.info('creating bitfinex exchange')
        exchanges = get_exchanges(['bitfinex', 'bittrex', 'poloniex'])
        open_calendar = get_calendar('OPEN')
        asset_finder = AssetFinderExchange()

        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
        )
Exemplo n.º 3
0
        df2 = pd.DataFrame(series)
        path = output_df(df2, assets, '{}_api'.format(freq))
        log.info('saved exchange api candles: {}\n{}'.format(
            path, df2.tail(10)))

        try:
            assert_frame_equal(df1, df2)
            return True
        except:
            log.warn('differences found in dataframes')
            return False


if __name__ == '__main__':
    exchanges = get_exchanges(['poloniex'])
    exchange = six.next(six.itervalues(exchanges))
    assets = exchange.get_assets(symbols=['eth_btc'])

    open_calendar = get_calendar('OPEN')
    asset_finder = AssetFinderExchange()
    data_portal = DataPortalExchangeBacktest(
        exchanges=exchanges,
        asset_finder=asset_finder,
        trading_calendar=open_calendar,
        first_trading_day=None  # will set dynamically based on assets
    )
    validator = Validator(data_portal=data_portal)

    validator.compare_bundle_with_exchange(exchange=exchange,
                                           assets=assets,