Skip to content

Commit

Permalink
Merge branch 'freqtrade:develop' into freqtrade-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
stash86 authored Aug 7, 2024
2 parents e3b4eae + a1d02ca commit e6c4027
Show file tree
Hide file tree
Showing 19 changed files with 111 additions and 50 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ jobs:
- name: Documentation build
run: |
pip install -r docs/requirements-docs.txt
pip install mkdocs
mkdocs build
- name: Discord notification
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pycqa/flake8
rev: "7.1.0"
rev: "7.1.1"
hooks:
- id: flake8
additional_dependencies: [Flake8-pyproject]
# stages: [push]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "v1.11.0"
rev: "v1.11.1"
hooks:
- id: mypy
exclude: build_helpers
Expand All @@ -31,7 +31,7 @@ repos:

- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: 'v0.5.5'
rev: 'v0.5.6'
hooks:
- id: ruff

Expand Down
28 changes: 22 additions & 6 deletions build_helpers/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
],
"minimum": -1
},
"new_pairs_days": {
"description": "Download data of new pairs for given number of days",
"type": "integer",
"default": 30
},
"timeframe": {
"description": "The timeframe to use (e.g `1m`, `5m`, `15m`, `30m`, `1h` ...). \nUsually specified in the strategy and missing in the configuration.",
"type": "string"
Expand Down Expand Up @@ -1065,7 +1060,7 @@
"default": {},
"properties": {
"process_throttle_secs": {
"description": "Throttle time in seconds for processing.",
"description": "Minimum loop duration for one bot iteration in seconds.",
"type": "integer"
},
"interval": {
Expand Down Expand Up @@ -1106,6 +1101,15 @@
"description": "Enable position adjustment. \nUsually specified in the strategy and missing in the configuration.",
"type": "boolean"
},
"new_pairs_days": {
"description": "Download data of new pairs for given number of days",
"type": "integer",
"default": 30
},
"download_trades": {
"description": "Download trades data by default (instead of ohlcv data).",
"type": "boolean"
},
"max_entry_position_adjustment": {
"description": "Maximum entry position adjustment allowed. \nUsually specified in the strategy and missing in the configuration.",
"type": [
Expand All @@ -1114,6 +1118,13 @@
],
"minimum": -1
},
"add_config_files": {
"description": "Additional configuration files to load.",
"type": "array",
"items": {
"type": "string"
}
},
"orderflow": {
"description": "Settings related to order flow.",
"type": "object",
Expand Down Expand Up @@ -1209,6 +1220,11 @@
},
"uniqueItems": true
},
"log_responses": {
"description": "Log responses from the exchange.Useful/required to debug issues with order processing.",
"type": "boolean",
"default": false
},
"unknown_fee_rate": {
"description": "Fee rate for unknown markets.",
"type": "number"
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements-docs.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
markdown==3.6
mkdocs==1.6.0
mkdocs-material==9.5.30
mkdocs-material==9.5.31
mdx_truly_sane_lists==1.3
pymdown-extensions==10.9
jinja2==3.1.4
2 changes: 1 addition & 1 deletion docs/strategy-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Out of the box, freqtrade installs the following technical libraries:

- [ta-lib](https://ta-lib.github.io/ta-lib-python/)
- [pandas-ta](https://twopirllc.github.io/pandas-ta/)
- [technical](https://github.com/freqtrade/technical/)
- [technical](https://technical.freqtrade.io)

Additional technical libraries can be installed as necessary, or custom indicators may be written / invented by the strategy author.

Expand Down
4 changes: 2 additions & 2 deletions freqtrade/commands/list_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def start_list_exchanges(args: Dict[str, Any]) -> None:
)

if args["print_one_column"]:
print("\n".join([e["name"] for e in available_exchanges]))
print("\n".join([e["classname"] for e in available_exchanges]))
else:
if args["list_exchanges_all"]:
title = (
Expand All @@ -50,7 +50,7 @@ def start_list_exchanges(args: Dict[str, Any]) -> None:
table.add_column("Reason")

for exchange in available_exchanges:
name = Text(exchange["name"])
name = Text(exchange["classname"])
if exchange["supported"]:
name.append(" (Official)", style="italic")
name.stylize("green bold")
Expand Down
13 changes: 13 additions & 0 deletions freqtrade/configuration/config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,11 @@
"type": ["integer", "number"],
"minimum": -1,
},
"add_config_files": {
"description": "Additional configuration files to load.",
"type": "array",
"items": {"type": "string"},
},
"orderflow": {
"description": "Settings related to order flow.",
"type": "object",
Expand Down Expand Up @@ -963,6 +968,14 @@
"items": {"type": "string"},
"uniqueItems": True,
},
"log_responses": {
"description": (
"Log responses from the exchange."
"Useful/required to debug issues with order processing."
),
"type": "boolean",
"default": False,
},
"unknown_fee_rate": {
"description": "Fee rate for unknown markets.",
"type": "number",
Expand Down
4 changes: 4 additions & 0 deletions freqtrade/configuration/config_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ def sanitize_config(config: Config, *, show_sensitive: bool = False) -> Config:
return config
keys_to_remove = [
"exchange.key",
"exchange.api_key",
"exchange.apiKey",
"exchange.secret",
"exchange.password",
"exchange.uid",
"exchange.account_id",
"exchange.accountId",
"exchange.wallet_address",
"exchange.walletAddress",
"exchange.private_key",
"exchange.privateKey",
"telegram.token",
"telegram.chat_id",
Expand Down
1 change: 1 addition & 0 deletions freqtrade/exchange/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from freqtrade.exchange.gate import Gate
from freqtrade.exchange.hitbtc import Hitbtc
from freqtrade.exchange.htx import Htx
from freqtrade.exchange.hyperliquid import Hyperliquid
from freqtrade.exchange.idex import Idex
from freqtrade.exchange.kraken import Kraken
from freqtrade.exchange.kucoin import Kucoin
Expand Down
17 changes: 11 additions & 6 deletions freqtrade/exchange/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,18 @@ def _init_ccxt(
raise OperationalException(f"Exchange {name} is not supported by ccxt")

ex_config = {
"apiKey": exchange_config.get("apiKey", exchange_config.get("key")),
"apiKey": exchange_config.get(
"api_key", exchange_config.get("apiKey", exchange_config.get("key"))
),
"secret": exchange_config.get("secret"),
"password": exchange_config.get("password"),
"uid": exchange_config.get("uid", ""),
"accountId": exchange_config.get("accountId", ""),
"accountId": exchange_config.get("account_id", exchange_config.get("accountId", "")),
# DEX attributes:
"walletAddress": exchange_config.get("walletAddress"),
"privateKey": exchange_config.get("privateKey"),
"walletAddress": exchange_config.get(
"wallet_address", exchange_config.get("walletAddress")
),
"privateKey": exchange_config.get("private_key", exchange_config.get("privateKey")),
}
if ccxt_kwargs:
logger.info("Applying additional ccxt config: %s", ccxt_kwargs)
Expand Down Expand Up @@ -2608,12 +2612,13 @@ async def _async_get_candle_history(
except (ccxt.OperationFailed, ccxt.ExchangeError) as e:
raise TemporaryError(
f"Could not fetch historical candle (OHLCV) data "
f"for pair {pair} due to {e.__class__.__name__}. "
f"for {pair}, {timeframe}, {candle_type} due to {e.__class__.__name__}. "
f"Message: {e}"
) from e
except ccxt.BaseError as e:
raise OperationalException(
f"Could not fetch historical candle (OHLCV) data for pair {pair}. Message: {e}"
f"Could not fetch historical candle (OHLCV) data for "
f"{pair}, {timeframe}, {candle_type}. Message: {e}"
) from e

async def _fetch_funding_rate_history(
Expand Down
17 changes: 9 additions & 8 deletions freqtrade/exchange/exchange_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ def available_exchanges(ccxt_module: Optional[CcxtModuleType] = None) -> List[st
return [x for x in exchanges if validate_exchange(x)[0]]


def validate_exchange(exchange: str) -> Tuple[bool, str, bool]:
def validate_exchange(exchange: str) -> Tuple[bool, str, Optional[ccxt.Exchange]]:
"""
returns: can_use, reason
returns: can_use, reason, exchange_object
with Reason including both missing and missing_opt
"""
try:
Expand All @@ -64,11 +64,10 @@ def validate_exchange(exchange: str) -> Tuple[bool, str, bool]:
ex_mod = getattr(ccxt.async_support, exchange.lower())()

if not ex_mod or not ex_mod.has:
return False, "", False
return False, "", None

result = True
reason = ""
is_dex = getattr(ex_mod, "dex", False)
missing = [
k
for k, v in EXCHANGE_HAS_REQUIRED.items()
Expand All @@ -87,19 +86,21 @@ def validate_exchange(exchange: str) -> Tuple[bool, str, bool]:
if missing_opt:
reason += f"{'. ' if reason else ''}missing opt: {', '.join(missing_opt)}. "

return result, reason, is_dex
return result, reason, ex_mod


def _build_exchange_list_entry(
exchange_name: str, exchangeClasses: Dict[str, Any]
) -> ValidExchangesType:
valid, comment, is_dex = validate_exchange(exchange_name)
valid, comment, ex_mod = validate_exchange(exchange_name)
result: ValidExchangesType = {
"name": exchange_name,
"name": getattr(ex_mod, "name", exchange_name),
"classname": exchange_name,
"valid": valid,
"supported": exchange_name.lower() in SUPPORTED_EXCHANGES,
"comment": comment,
"dex": is_dex,
"dex": getattr(ex_mod, "dex", False),
"is_alias": getattr(ex_mod, "alias", False),
"trade_modes": [{"trading_mode": "spot", "margin_mode": ""}],
}
if resolved := exchangeClasses.get(exchange_name.lower()):
Expand Down
2 changes: 2 additions & 0 deletions freqtrade/types/valid_exchanges_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ class TradeModeType(TypedDict):

class ValidExchangesType(TypedDict):
name: str
classname: str
valid: bool
supported: bool
comment: str
dex: bool
is_alias: bool
trade_modes: List[TradeModeType]
16 changes: 10 additions & 6 deletions freqtrade/util/rich_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ def print_rich_table(
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)

console = Console(
width=200 if "pytest" in sys.modules else None,
)
width = None
if any(module in ["pytest", "ipykernel"] for module in sys.modules):
width = 200

console = Console(width=width)
console.print(table)


Expand Down Expand Up @@ -71,7 +73,9 @@ def print_df_rich_table(
row = [_format_value(x, floatfmt=".3f") for x in value_list]
table.add_row(*row)

console = Console(
width=200 if "pytest" in sys.modules else None,
)
width = None
if any(module in ["pytest", "ipykernel"] for module in sys.modules):
width = 200

console = Console(width=width)
console.print(table)
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
-r docs/requirements-docs.txt

coveralls==4.0.1
ruff==0.5.5
mypy==1.11.0
ruff==0.5.6
mypy==1.11.1
pre-commit==3.8.0
pytest==8.3.2
pytest-asyncio==0.23.8
Expand Down
4 changes: 2 additions & 2 deletions requirements-freqai-rl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
-r requirements-freqai.txt

# Required for freqai-rl
torch==2.3.1; sys_platform != 'darwin' or platform_machine != 'x86_64'
torch==2.2.2; sys_platform == 'darwin' and platform_machine == 'x86_64'
torch==2.4.0; sys_platform != 'darwin' or platform_machine != 'x86_64'
gymnasium==0.29.1
stable_baselines3==2.3.2
sb3_contrib>=2.2.1
# Progress bar for stable-baselines3 and sb3-contrib
tqdm==4.66.4
tqdm==4.66.5
3 changes: 3 additions & 0 deletions requirements-freqai.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
scikit-learn==1.5.1
joblib==1.4.2
catboost==1.2.5; 'arm' not in platform_machine
# Pin Matplotlib - it's depended on by catboost
# Temporary downgrade of matplotlib due to https://github.com/matplotlib/matplotlib/issues/28551
matplotlib==3.9.0
lightgbm==4.5.0
xgboost==2.0.3
tensorboard==2.17.0
Expand Down
13 changes: 7 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ pandas-ta==0.3.14b
finta>=1.3
ta>=0.10.1

ccxt==4.3.68
cryptography==43.0.0
ccxt==4.3.73
cryptography==42.0.8; platform_machine == 'armv7l'
cryptography==43.0.0; platform_machine != 'armv7l'
aiohttp==3.9.5
SQLAlchemy==2.0.31
python-telegram-bot==21.4
Expand All @@ -19,7 +20,7 @@ requests==2.32.3
urllib3==2.2.2
jsonschema==4.23.0
TA-Lib==0.4.32
technical==1.4.3
technical==1.4.4
tabulate==0.9.0
pycoingecko==3.1.0
jinja2==3.1.4
Expand All @@ -40,10 +41,10 @@ orjson==3.10.6
sdnotify==0.3.2

# API Server
fastapi==0.111.1
fastapi==0.112.0
pydantic==2.8.2
uvicorn==0.30.3
pyjwt==2.8.0
uvicorn==0.30.5
pyjwt==2.9.0
aiofiles==24.1.0
psutil==6.0.0

Expand Down
6 changes: 6 additions & 0 deletions tests/exchange_online/test_ccxt_ws_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def test_ccxt_watch_ohlcv(self, exchange_ws: EXCHANGE_WS_FIXTURE_TYPE, caplog, m
m_hist = mocker.spy(exch, "_async_get_historic_ohlcv")
m_cand = mocker.spy(exch, "_async_get_candle_history")

while True:
# Don't start the test if we are too close to the end of the minute.
if dt_now().second < 50 and dt_now().second != 0:
break
sleep(1)

res = exch.refresh_latest_ohlcv([pair_tf])
assert m_cand.call_count == 1

Expand Down
Loading

0 comments on commit e6c4027

Please sign in to comment.