Removed unecessary code

This commit is contained in:
Sam Germain 2021-10-17 08:01:21 -06:00
parent 06dea121fd
commit f09f8db45e
5 changed files with 10 additions and 69 deletions

View File

@ -1,9 +1,8 @@
""" Binance exchange subclass """ """ Binance exchange subclass """
import json import json
import logging import logging
from datetime import datetime
from pathlib import Path from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple from typing import Dict, List, Optional, Tuple
import arrow import arrow
import ccxt import ccxt
@ -30,13 +29,7 @@ class Binance(Exchange):
"l2_limit_range": [5, 10, 20, 50, 100, 500, 1000], "l2_limit_range": [5, 10, 20, 50, 100, 500, 1000],
} }
funding_fee_times: List[int] = [0, 8, 16] # hours of the day funding_fee_times: List[int] = [0, 8, 16] # hours of the day
_funding_interest_rates: Dict = {} # TODO-lev: delete # but the schedule won't check within this timeframe
def __init__(self, config: Dict[str, Any], validate: bool = True) -> None:
super().__init__(config, validate)
# TODO-lev: Uncomment once lev-exchange merged in
# if self.trading_mode == TradingMode.FUTURES:
# self._funding_interest_rates = self._get_funding_interest_rates()
_supported_trading_mode_collateral_pairs: List[Tuple[TradingMode, Collateral]] = [ _supported_trading_mode_collateral_pairs: List[Tuple[TradingMode, Collateral]] = [
# TradingMode.SPOT always supported and not required in this list # TradingMode.SPOT always supported and not required in this list
@ -218,37 +211,6 @@ class Binance(Exchange):
except ccxt.BaseError as e: except ccxt.BaseError as e:
raise OperationalException(e) from e raise OperationalException(e) from e
def _get_mark_price(self, pair: str, date: datetime) -> float:
# TODO-lev: implement
raise OperationalException(f'_get_mark_price has not been implemented on {self.name}')
def _get_funding_rate(self, pair: str, when: datetime):
"""
Get's the funding_rate for a pair at a specific date and time in the past
"""
# TODO-lev: implement
raise OperationalException(f"get_funding_rate has not been implemented for {self.name}")
def _get_funding_fee(
self,
pair: str,
contract_size: float,
funding_rate: float,
mark_price: Optional[float],
) -> float:
"""
Calculates a single funding fee
:param contract_size: The amount/quanity
:param mark_price: The price of the asset that the contract is based off of
:param funding_rate: the interest rate and the premium
- interest rate: 0.03% daily, BNBUSDT, LINKUSDT, and LTCUSDT are 0%
- premium: varies by price difference between the perpetual contract and mark price
"""
if mark_price is None:
raise OperationalException("Mark price cannot be None for Binance._get_funding_fee")
nominal_value = mark_price * contract_size
return nominal_value * funding_rate
async def _async_get_historic_ohlcv( async def _async_get_historic_ohlcv(
self, self,
pair: str, pair: str,

View File

@ -1,6 +1,5 @@
""" FTX exchange subclass """ """ FTX exchange subclass """
import logging import logging
from datetime import datetime
from typing import Any, Dict, List, Optional, Tuple from typing import Any, Dict, List, Optional, Tuple
import ccxt import ccxt
@ -184,6 +183,3 @@ class Ftx(Exchange):
:nominal_value: Here for super method, not used on FTX :nominal_value: Here for super method, not used on FTX
""" """
return 20.0 return 20.0
def _get_funding_rate(self, pair: str, when: datetime) -> Optional[float]:
raise OperationalException(f'_get_mark_price has not been implemented on {self.name}')

View File

@ -342,14 +342,6 @@ def test__set_leverage_binance(mocker, default_conf):
) )
def test_get_funding_rate():
return
def test__get_funding_fee():
return
@pytest.mark.asyncio @pytest.mark.asyncio
async def test__async_get_historic_ohlcv_binance(default_conf, mocker, caplog): async def test__async_get_historic_ohlcv_binance(default_conf, mocker, caplog):
ohlcv = [ ohlcv = [

View File

@ -3258,3 +3258,11 @@ def test_get_funding_fee_dates():
def test_calculate_funding_fees(): def test_calculate_funding_fees():
return return
def test__get_funding_rate(default_conf, mocker):
return
def test__get_funding_fee():
return

View File

@ -1,4 +1,3 @@
from datetime import datetime, timedelta
from random import randint from random import randint
from unittest.mock import MagicMock from unittest.mock import MagicMock
@ -268,19 +267,3 @@ def test_fill_leverage_brackets_ftx(default_conf, mocker):
exchange = get_patched_exchange(mocker, default_conf, id="ftx") exchange = get_patched_exchange(mocker, default_conf, id="ftx")
exchange.fill_leverage_brackets() exchange.fill_leverage_brackets()
assert exchange._leverage_brackets == {} assert exchange._leverage_brackets == {}
@pytest.mark.parametrize("pair,when", [
('XRP/USDT', datetime.utcnow()),
('ADA/BTC', datetime.utcnow()),
('XRP/USDT', datetime.utcnow() - timedelta(hours=30)),
])
def test__get_funding_rate(default_conf, mocker, pair, when):
# api_mock = MagicMock()
# exchange = get_patched_exchange(mocker, default_conf, api_mock, id="ftx")
# assert exchange._get_funding_rate(pair, when) is None
return
def test__get_funding_fee():
return