merge with feat/short interest changes
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
# from decimal import Decimal
|
||||
from decimal import Decimal
|
||||
from math import isclose
|
||||
|
||||
import pytest
|
||||
|
||||
from freqtrade.enums import Collateral, TradingMode
|
||||
from freqtrade.leverage import liquidation_price
|
||||
from freqtrade.leverage import interest, liquidation_price
|
||||
|
||||
|
||||
# from freqtrade.exceptions import OperationalException
|
||||
@@ -87,3 +90,34 @@ def test_liquidation_price():
|
||||
|
||||
# liquidation_price(ftx, trading_mode=futures, collateral=isolated)
|
||||
# assert exception thrown #TODO-lev: Check that exception is thrown
|
||||
|
||||
|
||||
ten_mins = Decimal(1/6)
|
||||
five_hours = Decimal(5.0)
|
||||
twentyfive_hours = Decimal(25.0)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('exchange,interest_rate,hours,expected', [
|
||||
('binance', 0.0005, ten_mins, 0.00125),
|
||||
('binance', 0.00025, ten_mins, 0.000625),
|
||||
('binance', 0.00025, five_hours, 0.003125),
|
||||
('binance', 0.00025, twentyfive_hours, 0.015625),
|
||||
# Kraken
|
||||
('kraken', 0.0005, ten_mins, 0.06),
|
||||
('kraken', 0.00025, ten_mins, 0.03),
|
||||
('kraken', 0.00025, five_hours, 0.045),
|
||||
('kraken', 0.00025, twentyfive_hours, 0.12),
|
||||
# FTX
|
||||
# TODO-lev: - implement FTX tests
|
||||
# ('ftx', Decimal(0.0005), ten_mins, 0.06),
|
||||
# ('ftx', Decimal(0.0005), five_hours, 0.045),
|
||||
])
|
||||
def test_interest(exchange, interest_rate, hours, expected):
|
||||
borrowed = Decimal(60.0)
|
||||
|
||||
assert isclose(interest(
|
||||
exchange_name=exchange,
|
||||
borrowed=borrowed,
|
||||
rate=Decimal(interest_rate),
|
||||
hours=hours
|
||||
), expected)
|
||||
|
Reference in New Issue
Block a user