mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Add candletype from string
This commit is contained in:
parent
f9cf59bb4d
commit
f33643cacf
|
@ -275,6 +275,7 @@ def convert_ohlcv_format(
|
|||
:param convert_from: Source format
|
||||
:param convert_to: Target format
|
||||
:param erase: Erase source data (does not apply if source and target format are identical)
|
||||
:param candle_type: Any of the enum CandleType (must match trading mode!)
|
||||
"""
|
||||
from freqtrade.data.history.idatahandler import get_datahandler
|
||||
src = get_datahandler(config['datadir'], convert_from)
|
||||
|
|
|
@ -11,3 +11,10 @@ class CandleType(str, Enum):
|
|||
PREMIUMINDEX = "premiumIndex"
|
||||
# TODO-lev: not sure this belongs here, as the datatype is really different
|
||||
FUNDING_RATE = "funding_rate"
|
||||
|
||||
@classmethod
|
||||
def from_string(cls, value: str) -> 'CandleType':
|
||||
if not value:
|
||||
# Default to spot
|
||||
return CandleType.SPOT
|
||||
return CandleType(value)
|
||||
|
|
18
tests/leverage/test_candletype.py
Normal file
18
tests/leverage/test_candletype.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import pytest
|
||||
|
||||
from freqtrade.enums import CandleType
|
||||
|
||||
|
||||
@pytest.mark.parametrize('input,expected', [
|
||||
('', CandleType.SPOT),
|
||||
('spot', CandleType.SPOT),
|
||||
(CandleType.SPOT, CandleType.SPOT),
|
||||
(CandleType.FUTURES, CandleType.FUTURES),
|
||||
(CandleType.INDEX, CandleType.INDEX),
|
||||
(CandleType.MARK, CandleType.MARK),
|
||||
('futures', CandleType.FUTURES),
|
||||
('mark', CandleType.MARK),
|
||||
('premiumIndex', CandleType.PREMIUMINDEX),
|
||||
])
|
||||
def test_candle_type_from_string(input, expected):
|
||||
assert CandleType.from_string(input) == expected
|
Loading…
Reference in New Issue
Block a user