示例#1
0
def universe(context, today):
    json_symbols = get_exchange_symbols('poloniex')
    poloniex_universe_df = pd.DataFrame.from_dict(
        json_symbols).transpose().astype(str)
    poloniex_universe_df['base_currency'] = poloniex_universe_df.apply(
        lambda row: row.symbol.split('_')[1],
        axis=1)
    poloniex_universe_df['market_currency'] = poloniex_universe_df.apply(
        lambda row: row.symbol.split('_')[0],
        axis=1)
    poloniex_universe_df = poloniex_universe_df[
        poloniex_universe_df['base_currency'] == context.base_currency]
    poloniex_universe_df = poloniex_universe_df[
        poloniex_universe_df.symbol != 'gas_btc']

    # Markets currently not working on Catalyst 0.3.1
    # 2017-01-01
    # poloniex_universe_df = poloniex_universe_df[poloniex_universe_df.symbol != 'bcn_btc']
    # poloniex_universe_df = poloniex_universe_df[poloniex_universe_df.symbol != 'burst_btc']
    # poloniex_universe_df = poloniex_universe_df[poloniex_universe_df.symbol != 'dgb_btc']
    # poloniex_universe_df = poloniex_universe_df[poloniex_universe_df.symbol != 'doge_btc']
    # poloniex_universe_df = poloniex_universe_df[poloniex_universe_df.symbol != 'emc2_btc']
    # poloniex_universe_df = poloniex_universe_df[poloniex_universe_df.symbol != 'pink_btc']
    # poloniex_universe_df = poloniex_universe_df[poloniex_universe_df.symbol != 'sc_btc']
    print(poloniex_universe_df.head())

    date = str(today).split(' ')[0]

    poloniex_universe_df = poloniex_universe_df[
        poloniex_universe_df.start_date < date]
    context.coins = symbols(*poloniex_universe_df.symbol)
    print(len(poloniex_universe_df))
    return poloniex_universe_df.symbol.tolist()
示例#2
0
    def fetch_symbol_map(self, is_local=False):
        index = 1 if is_local else 0
        if self._symbol_maps[index] is not None:
            return self._symbol_maps[index]

        else:
            symbol_map = get_exchange_symbols(self.name, is_local)
            self._symbol_maps[index] = symbol_map
            return symbol_map
示例#3
0
def universe(context, lookback_date, current_date):
    json_symbols = get_exchange_symbols(
        context.exchange)  # get all the pairs for the exchange
    universe_df = pd.DataFrame.from_dict(json_symbols).transpose().astype(
        str)  # convert into a dataframe
    universe_df['base_currency'] = universe_df.apply(
        lambda row: row.symbol.split('_')[1], axis=1)
    universe_df['market_currency'] = universe_df.apply(
        lambda row: row.symbol.split('_')[0], axis=1)
    # Filter all the exchange pairs to only the ones for a give base currency
    universe_df = universe_df[universe_df['base_currency'] ==
                              context.base_currency]

    # Filter all the pairs to ensure that pair existed in the current date range
    universe_df = universe_df[universe_df.start_date < lookback_date]
    universe_df = universe_df[universe_df.end_daily >= current_date]
    context.coins = symbols(
        *universe_df.symbol)  # convert all the pairs to symbols
    return universe_df.symbol.tolist()
示例#4
0
 def fetch_symbol_map(self):
     return get_exchange_symbols(self.name)
示例#5
0
 def fetch_symbol_map(self, is_local=False):
     return get_exchange_symbols(self.name, is_local)