Exemple #1
0
def test_exchanges_filtering(database, exchange_manager,
                             function_scope_messages_aggregator):
    kraken1 = MockKraken(
        name='mockkraken_1',
        api_key=make_api_key(),
        secret=make_api_secret(),
        database=database,
        msg_aggregator=function_scope_messages_aggregator,
    )
    kraken2 = MockKraken(
        name='mockkraken_2',
        api_key=make_api_key(),
        secret=make_api_secret(),
        database=database,
        msg_aggregator=function_scope_messages_aggregator,
    )
    ftx1 = Ftx(
        name='mockftx_1',
        api_key=make_api_key(),
        secret=make_api_secret(),
        database=database,
        msg_aggregator=function_scope_messages_aggregator,
        ftx_subaccount=None,
    )
    ftx2 = Ftx(
        name='mockftx_2',
        api_key=make_api_key(),
        secret=make_api_secret(),
        database=database,
        msg_aggregator=function_scope_messages_aggregator,
        ftx_subaccount=None,
    )

    exchange_manager.initialize_exchanges({}, database)
    exchange_manager.connected_exchanges[Location.KRAKEN].append(kraken1)
    exchange_manager.connected_exchanges[Location.KRAKEN].append(kraken2)
    exchange_manager.connected_exchanges[Location.FTX].append(ftx1)
    exchange_manager.connected_exchanges[Location.FTX].append(ftx2)
    assert set(exchange_manager.iterate_exchanges()) == {
        kraken1, kraken2, ftx1, ftx2
    }

    database.set_settings(
        ModifiableDBSettings(non_syncing_exchanges=[
            kraken1.location_id(),
            kraken2.location_id()
        ], ))
    assert set(exchange_manager.iterate_exchanges()) == {ftx1, ftx2}

    database.set_settings(
        ModifiableDBSettings(non_syncing_exchanges=[ftx1.location_id()], ))
    assert set(
        exchange_manager.iterate_exchanges()) == {ftx2, kraken1, kraken2}
Exemple #2
0
def create_test_ftx(
        database: DBHandler,
        msg_aggregator: MessagesAggregator,
) -> Ftx:
    mock = Ftx(
        api_key=make_api_key(),
        secret=make_api_secret(),
        database=database,
        msg_aggregator=msg_aggregator,
    )
    return mock
Exemple #3
0
def create_test_ftx(
    database: DBHandler,
    msg_aggregator: MessagesAggregator,
) -> Ftx:
    mock = Ftx(
        name='ftx',
        api_key=make_api_key(),
        secret=make_api_secret(),
        database=database,
        msg_aggregator=msg_aggregator,
        ftx_subaccount=None,
    )
    return mock
Exemple #4
0
def test_name():
    exchange = Ftx('ftx1', 'a', b'a', object(), object())
    assert exchange.location == Location.FTX
    assert exchange.name == 'ftx1'
Exemple #5
0
def test_name(database):
    exchange = Ftx('ftx1', 'a', b'a', database, object(), None)
    assert exchange.location == Location.FTX
    assert exchange.name == 'ftx1'
Exemple #6
0
def test_name():
    exchange = Ftx('a', b'a', object(), object())
    assert exchange.name == 'ftx'