示例#1
0
    def requires(self):
        cbp_conn = coinbasepro.PublicClient()
        cbp_products_raw = cbp_conn.get_products()
        cbp_products = [product['id'] for product in cbp_products_raw]

        phemex_conn, phemex_ws = get_phemex_connection()
        phemex_products_raw = phemex_conn.get_products()['data']
        phemex_products = [
            product['symbol'] for product in phemex_products_raw
        ]

        exchanges = {
            'PHEMEX': {
                'db_prefix': 'PHEMEX',
                'supported_products': phemex_products
            },
            'COINBASEPRO': {
                'db_prefix': 'COINBASE_PRO',
                'supported_products': cbp_products
            }
        }
        for exchange in exchanges.keys():
            db_prefix = exchanges[exchange]['db_prefix']
            supported_products = exchanges[exchange]['supported_products']
            for db in ['BOOKS', 'TRADES']:
                for product in supported_products:
                    yield AzureBlobUploadTask(
                        behemoth_path=self.behemoth_path,
                        storage_account=self.storage_account,
                        db=f'{db_prefix}_{db}',
                        product=product,
                        start_date=self.start_date,
                        end_date=self.end_date)
示例#2
0
    def __init__(self,
                 scheduler: NetworkScheduler,
                 instrument_cache: InstrumentCache,
                 instance_id: str = 'prod'):
        self.scheduler = scheduler
        self.instrument_cache = instrument_cache
        (self.phemex,
         self.ws_uri) = get_phemex_connection(PublicCredentials(), instance_id)
        self.instrument_marks = {}

        # timeout in seconds
        self.timeout = 60
示例#3
0
    def __init__(self,
                 credentials: AuthCredentials,
                 scheduler: NetworkScheduler,
                 oms: OrderManagerService,
                 account: str,
                 instance_id: str = 'prod'):
        super().__init__(OrderFactory(account))
        self.oms = oms

        self.oe_subscriber = OrderEventSubscriber(credentials, scheduler, oms,
                                                  instance_id)
        self.oe_subscriber.start()

        (self.trading_conn,
         ws_uri) = get_phemex_connection(credentials, instance_id)
示例#4
0
    def __init__(self,
                 credentials: AuthCredentials,
                 scheduler: NetworkScheduler,
                 oms: OrderManagerService,
                 instance_id: str = 'prod'):
        self.auth = PhemexWebsocketAuthenticator(credentials)
        self.scheduler = scheduler
        self.oms = oms

        # timeout in seconds
        self.timeout = 60

        self.order_events = MutableSignal()
        self.scheduler.network.attach(self.order_events)

        (self.phemex,
         self.ws_uri) = get_phemex_connection(credentials, instance_id)
示例#5
0
    def __init__(self,
                 scheduler: NetworkScheduler,
                 instrument_cache: InstrumentCache,
                 include_symbol: str = '*',
                 instance_id: str = 'prod'):
        (self.phemex,
         self.ws_uri) = get_phemex_connection(PublicCredentials(), instance_id)

        # ensure we've initialized PhemexConnection before loading instruments in super()
        super().__init__(scheduler, instrument_cache, instance_id)

        self.instrument_trades = {}
        self.instrument_order_book_events = {}
        self.instrument_order_books = {}

        self.include_symbol = include_symbol

        # timeout in seconds
        self.timeout = 60
示例#6
0
    def __init__(self,
                 credentials: AuthCredentials,
                 scheduler: NetworkScheduler,
                 instrument_cache: InstrumentCache,
                 account: str,
                 instance_id: str = 'prod'):
        super().__init__(scheduler)
        self.auth = PhemexWebsocketAuthenticator(credentials)
        self.scheduler = scheduler
        self.instrument_cache = instrument_cache
        self.account = account

        # timeout in seconds
        self.timeout = 60

        self.order_events = MutableSignal()
        self.scheduler.network.attach(self.order_events)

        (self.phemex,
         self.ws_uri) = get_phemex_connection(credentials, instance_id)
示例#7
0
        quote_ccy = symbol[3:].upper()
        currency_pair = instrument_cache.get_or_create_cryptocurrency_pair(base_ccy, quote_ccy)
        instrument_cache.get_or_create_exchange_instrument(symbol, currency_pair.get_instrument(), gemini)

    # map all Coinbase Pro products to exchange_instrument table
    cbp_client = coinbasepro.PublicClient()
    cbp = exch_service.instrument_cache.get_crypto_exchange("COINBASEPRO")
    for product in cbp_client.get_products():
        symbol = product['id']
        base_ccy = product['base_currency']
        quote_ccy = product['quote_currency']
        currency_pair = instrument_cache.get_or_create_cryptocurrency_pair(base_ccy, quote_ccy)
        instrument_cache.get_or_create_exchange_instrument(symbol, currency_pair.get_instrument(), cbp)

    # map all Phemex products to exchange_instrument table
    (phemex, ws_uri) = get_phemex_connection(PublicCredentials())
    products = phemex.get_products()
    exchange_code = 'PHEMEX'
    for product in products['data']:
        symbol = product['symbol']
        base_ccy = product['baseCurrency']
        quote_ccy = product['quoteCurrency']
        price_scale = product['priceScale']
        ul_symbol = f'.M{base_ccy}'
        ccy_pair = instrument_cache.get_or_create_cryptocurrency_pair(base_ccy, quote_ccy)
        ul_instr = ccy_pair.get_instrument()
        exchange = instrument_cache.get_crypto_exchange(exchange_code)
        instrument_cache.get_or_create_exchange_instrument(ul_symbol, ul_instr, exchange)
        future = instrument_cache.get_or_create_perpetual_future(ul_instr)
        instr = future.get_instrument()
        exch_instrument = instrument_cache.get_or_create_exchange_instrument(symbol, instr, exchange)