예제 #1
0
def do_upload(behemoth_path: str, upload_date: datetime.date,
              cloud_upload: bool):
    logger.info(f'uploading into Behemoth for upload date = {upload_date}')
    conn = connect_serenity_db()
    conn.autocommit = True
    cur = conn.cursor()
    instr_cache = InstrumentCache(cur, TypeCodeCache(cur))

    exchanges = {
        'PHEMEX': {
            'db_prefix': 'PHEMEX',
            'supported_products': {'BTCUSD'}
        },
        'COINBASEPRO': {
            'db_prefix': 'COINBASE_PRO',
            'supported_products': {'BTC-USD'}
        }
    }
    for exchange in exchanges.keys():
        logger.info(f'Uploading for exchange: {exchange}')
        db_prefix = exchanges[exchange]['db_prefix']
        supported_products = exchanges[exchange]['supported_products']
        for instrument in instr_cache.get_all_exchange_instruments(exchange):
            symbol = instrument.get_exchange_instrument_code()
            if symbol in supported_products:
                upload_trades(behemoth_path, db_prefix, exchange, symbol,
                              upload_date, cloud_upload)
                upload_order_books(behemoth_path, db_prefix, exchange, symbol,
                                   upload_date, cloud_upload)
예제 #2
0
def do_upload(behemoth_path: str, upload_date: datetime.date):
    logger.info(f'uploading into Behemoth for upload date = {upload_date}')
    conn = connect_serenity_db()
    conn.autocommit = True
    cur = conn.cursor()
    instr_cache = InstrumentCache(cur, TypeCodeCache(cur))

    exchanges = {'PHEMEX': 'PHEMEX', 'COINBASE_PRO': 'COINBASE_PRO'}
    for exchange, db_prefix in exchanges.items():
        for instrument in instr_cache.get_all_exchange_instruments(exchange):
            symbol = instrument.get_exchange_instrument_code()

            upload_trades(behemoth_path, db_prefix, exchange, symbol,
                          upload_date)
            upload_order_books(behemoth_path, db_prefix, exchange, symbol,
                               upload_date)