core.test_deribit_client

Tests for Deribit Client

Tests pure functions and mocked API calls for the Deribit market data client.

class TestFormatInstrumentName:

Tests for instrument name formatting (pure function).

def test_format_put_option(self):

Test formatting a put option instrument name.

def test_format_call_option(self):

Test formatting a call option instrument name.

def test_format_btc(self):

Test formatting BTC option.

def test_format_january(self):

Test single-digit day formatting.

class TestGetSpotPrice:

Tests for spot price fetching (mocked API).

@patch('domains.hedge.core.deribit_client._api_call')
def test_get_spot_price_success(self, mock_api):

Test successful spot price fetch.

@patch('domains.hedge.core.deribit_client._api_call')
def test_get_spot_price_btc(self, mock_api):

Test BTC spot price fetch.

class TestGetAvailableExpiries:

Tests for expiry date fetching (mocked API).

@patch('domains.hedge.core.deribit_client._api_call')
def test_get_available_expiries(self, mock_api):

Test fetching available expiry dates.

@patch('domains.hedge.core.deribit_client._api_call')
def test_get_available_expiries_empty(self, mock_api):

Test with no available expiries.

class TestGetImpliedVolatility:

Tests for IV fetching (mocked API).

@patch('domains.hedge.core.deribit_client._api_call')
def test_get_iv_success(self, mock_api):

Test successful IV fetch.

@patch('domains.hedge.core.deribit_client._api_call')
def test_get_iv_fallback_on_error(self, mock_api):

Test fallback IV on API error.

@patch('domains.hedge.core.deribit_client._api_call')
def test_get_iv_fallback_on_zero(self, mock_api):

Test fallback IV when API returns zero.

class TestGetOptionChain:

Tests for option chain fetching (mocked API).

@patch('domains.hedge.core.deribit_client._api_call')
def test_get_option_chain_puts(self, mock_api):

Test fetching put options for expiry.

@patch('domains.hedge.core.deribit_client._api_call')
def test_get_option_chain_empty(self, mock_api):

Test with no matching options.

class TestValidateStrikeAvailability:

Tests for strike availability validation (mocked API).

@patch('domains.hedge.core.deribit_client.get_option_chain')
def test_validate_all_available(self, mock_chain):

Test when all strikes are available.

@patch('domains.hedge.core.deribit_client.get_option_chain')
def test_validate_some_unavailable(self, mock_chain):

Test when some strikes are not available.

class TestGetMarketData:

Tests for complete market data fetching (mocked API).

@patch('domains.hedge.core.deribit_client.get_implied_volatility')
@patch('domains.hedge.core.deribit_client.get_available_expiries')
@patch('domains.hedge.core.deribit_client.get_spot_price')
def test_get_market_data_success(self, mock_spot, mock_expiries, mock_iv):

Test successful market data fetch.

@patch('domains.hedge.core.deribit_client.get_implied_volatility')
@patch('domains.hedge.core.deribit_client.get_available_expiries')
@patch('domains.hedge.core.deribit_client.get_spot_price')
def test_get_market_data_expiry_index_out_of_range(self, mock_spot, mock_expiries, mock_iv):

Test with expiry_index beyond available expiries.