mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-02-06 14:20:24 +00:00
chore: update to modern typing syntax
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import logging
|
||||
from typing import Dict
|
||||
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
@@ -98,7 +97,7 @@ class FreqaiExampleHybridStrategy(IStrategy):
|
||||
exit_short_rsi = IntParameter(low=1, high=50, default=30, space="buy", optimize=True, load=True)
|
||||
|
||||
def feature_engineering_expand_all(
|
||||
self, dataframe: DataFrame, period: int, metadata: Dict, **kwargs
|
||||
self, dataframe: DataFrame, period: int, metadata: dict, **kwargs
|
||||
) -> DataFrame:
|
||||
"""
|
||||
*Only functional with FreqAI enabled strategies*
|
||||
@@ -151,7 +150,7 @@ class FreqaiExampleHybridStrategy(IStrategy):
|
||||
return dataframe
|
||||
|
||||
def feature_engineering_expand_basic(
|
||||
self, dataframe: DataFrame, metadata: Dict, **kwargs
|
||||
self, dataframe: DataFrame, metadata: dict, **kwargs
|
||||
) -> DataFrame:
|
||||
"""
|
||||
*Only functional with FreqAI enabled strategies*
|
||||
@@ -185,7 +184,7 @@ class FreqaiExampleHybridStrategy(IStrategy):
|
||||
return dataframe
|
||||
|
||||
def feature_engineering_standard(
|
||||
self, dataframe: DataFrame, metadata: Dict, **kwargs
|
||||
self, dataframe: DataFrame, metadata: dict, **kwargs
|
||||
) -> DataFrame:
|
||||
"""
|
||||
*Only functional with FreqAI enabled strategies*
|
||||
@@ -212,7 +211,7 @@ class FreqaiExampleHybridStrategy(IStrategy):
|
||||
dataframe["%-hour_of_day"] = dataframe["date"].dt.hour
|
||||
return dataframe
|
||||
|
||||
def set_freqai_targets(self, dataframe: DataFrame, metadata: Dict, **kwargs) -> DataFrame:
|
||||
def set_freqai_targets(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
|
||||
"""
|
||||
*Only functional with FreqAI enabled strategies*
|
||||
Required function to set the targets for the model.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import logging
|
||||
from functools import reduce
|
||||
from typing import Dict
|
||||
|
||||
import talib.abstract as ta
|
||||
from pandas import DataFrame
|
||||
@@ -46,7 +45,7 @@ class FreqaiExampleStrategy(IStrategy):
|
||||
can_short = True
|
||||
|
||||
def feature_engineering_expand_all(
|
||||
self, dataframe: DataFrame, period: int, metadata: Dict, **kwargs
|
||||
self, dataframe: DataFrame, period: int, metadata: dict, **kwargs
|
||||
) -> DataFrame:
|
||||
"""
|
||||
*Only functional with FreqAI enabled strategies*
|
||||
@@ -103,7 +102,7 @@ class FreqaiExampleStrategy(IStrategy):
|
||||
return dataframe
|
||||
|
||||
def feature_engineering_expand_basic(
|
||||
self, dataframe: DataFrame, metadata: Dict, **kwargs
|
||||
self, dataframe: DataFrame, metadata: dict, **kwargs
|
||||
) -> DataFrame:
|
||||
"""
|
||||
*Only functional with FreqAI enabled strategies*
|
||||
@@ -141,7 +140,7 @@ class FreqaiExampleStrategy(IStrategy):
|
||||
return dataframe
|
||||
|
||||
def feature_engineering_standard(
|
||||
self, dataframe: DataFrame, metadata: Dict, **kwargs
|
||||
self, dataframe: DataFrame, metadata: dict, **kwargs
|
||||
) -> DataFrame:
|
||||
"""
|
||||
*Only functional with FreqAI enabled strategies*
|
||||
@@ -172,7 +171,7 @@ class FreqaiExampleStrategy(IStrategy):
|
||||
dataframe["%-hour_of_day"] = dataframe["date"].dt.hour
|
||||
return dataframe
|
||||
|
||||
def set_freqai_targets(self, dataframe: DataFrame, metadata: Dict, **kwargs) -> DataFrame:
|
||||
def set_freqai_targets(self, dataframe: DataFrame, metadata: dict, **kwargs) -> DataFrame:
|
||||
"""
|
||||
*Only functional with FreqAI enabled strategies*
|
||||
Required function to set the targets for the model.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
from datetime import datetime
|
||||
from math import exp
|
||||
from typing import Dict
|
||||
|
||||
from pandas import DataFrame
|
||||
|
||||
@@ -41,7 +40,7 @@ class SampleHyperOptLoss(IHyperOptLoss):
|
||||
min_date: datetime,
|
||||
max_date: datetime,
|
||||
config: Config,
|
||||
processed: Dict[str, DataFrame],
|
||||
processed: dict[str, DataFrame],
|
||||
*args,
|
||||
**kwargs,
|
||||
) -> float:
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Callable, List, Optional, Union
|
||||
from typing import Callable, Optional, Union
|
||||
|
||||
from rich.console import ConsoleRenderable, Group, RichCast
|
||||
from rich.progress import Progress
|
||||
@@ -8,8 +8,8 @@ class CustomProgress(Progress):
|
||||
def __init__(
|
||||
self,
|
||||
*args,
|
||||
cust_objs: Optional[List[ConsoleRenderable]] = None,
|
||||
cust_callables: Optional[List[Callable[[], ConsoleRenderable]]] = None,
|
||||
cust_objs: Optional[list[ConsoleRenderable]] = None,
|
||||
cust_callables: Optional[list[Callable[[], ConsoleRenderable]]] = None,
|
||||
**kwargs,
|
||||
) -> None:
|
||||
self._cust_objs = cust_objs or []
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import sys
|
||||
from typing import Any, Dict, List, Optional, Sequence, Union
|
||||
from collections.abc import Sequence
|
||||
from typing import Any, Optional, Union
|
||||
|
||||
from pandas import DataFrame
|
||||
from rich.console import Console
|
||||
@@ -11,12 +12,12 @@ TextOrString = Union[str, Text]
|
||||
|
||||
|
||||
def print_rich_table(
|
||||
tabular_data: Sequence[Union[Dict[str, Any], Sequence[TextOrString]]],
|
||||
tabular_data: Sequence[Union[dict[str, Any], Sequence[TextOrString]]],
|
||||
headers: Sequence[str],
|
||||
summary: Optional[str] = None,
|
||||
*,
|
||||
justify="right",
|
||||
table_kwargs: Optional[Dict[str, Any]] = None,
|
||||
table_kwargs: Optional[dict[str, Any]] = None,
|
||||
) -> None:
|
||||
table = Table(
|
||||
*[c if isinstance(c, Column) else Column(c, justify=justify) for c in headers],
|
||||
@@ -34,7 +35,7 @@ def print_rich_table(
|
||||
)
|
||||
|
||||
else:
|
||||
row_to_add: List[Union[str, Text]] = [r if isinstance(r, Text) else str(r) for r in row]
|
||||
row_to_add: list[Union[str, Text]] = [r if isinstance(r, Text) else str(r) for r in row]
|
||||
table.add_row(*row_to_add)
|
||||
|
||||
width = None
|
||||
@@ -58,7 +59,7 @@ def print_df_rich_table(
|
||||
*,
|
||||
show_index=False,
|
||||
index_name: Optional[str] = None,
|
||||
table_kwargs: Optional[Dict[str, Any]] = None,
|
||||
table_kwargs: Optional[dict[str, Any]] = None,
|
||||
) -> None:
|
||||
table = Table(title=summary, **(table_kwargs or {}))
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
Jinja2 rendering utils, used to generate new strategy and configurations.
|
||||
"""
|
||||
|
||||
from typing import Dict, Optional
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def render_template(templatefile: str, arguments: Dict) -> str:
|
||||
def render_template(templatefile: str, arguments: dict) -> str:
|
||||
from jinja2 import Environment, PackageLoader, select_autoescape
|
||||
|
||||
env = Environment(
|
||||
@@ -17,7 +17,7 @@ def render_template(templatefile: str, arguments: Dict) -> str:
|
||||
|
||||
|
||||
def render_template_with_fallback(
|
||||
templatefile: str, templatefallbackfile: str, arguments: Optional[Dict] = None
|
||||
templatefile: str, templatefallbackfile: str, arguments: Optional[dict] = None
|
||||
) -> str:
|
||||
"""
|
||||
Use templatefile if possible, otherwise fall back to templatefallbackfile
|
||||
|
||||
Reference in New Issue
Block a user