Add Stocks and FX to a default Freqtrade
This revision is from 2024/12/12 03:44. You can Restore it.
To make a custom exchange.
config.json
{"max_open_trades": 100,
"stake_currency": "USDT",
"stake_amount": 1000,
"dry_run": true,
"dry_run_wallet": 100000,
"cache": "none", //avoid lookahead bias
"enable_protections": false, //avoid lookahead bias
"exit_pricing":{
"price_side": "other"
},
"entry_pricing": {
"price_side": "other"
},
"exchange": {
"name": "custard_tart",
"key": "",
"secret": "",
"pair_whitelist": ["TSLA/USDT"],
"pair_blacklist": []
},
"pairlists": [
{
"method": "StaticPairList",
"pairs": ["TSLA/USDT"]
}
]
}
Run...
freqtrade backtesting -c user_data/config.json -s SMA --timerange=20240101-20240201
and
freqtrade download-data --exchange custard_tart
and
freqtrade download-data --config user_data/config.json --timeframes 1m --timerange 20240101-
- freqtrade - ERROR - Exchange "custard_tart" is not known to the ccxt library and therefore not available for the bot.
There are 3 places to edit.
Step 1: Create a Custom Exchange Class
Create a new file custom_exchange.py in the freqtrade/exchange directory. In this file, define a class custardtart.py.
freqtrade/exchange/custardtart.py
from freqtrade.exchange import Exchange
class Custardtart(Exchange):
def __init__(self, config, validate=True, exchange_config=None, load_leverage_tiers=False):
@property
def name(self):
return "custardtart"
Register it with freqtrade/exchange/__init__.py
from freqtrade.exchange.custardtart import Custardtart
Add it to /freqtrade/exchange/common.py
SUPPORTED_EXCHANGES = [
"custardtart",
]
freqtrade/exchange/check_exchange.py
from freqtrade.exchange.common import MAP_EXCHANGE_CHILDCLASS, SUPPORTED_EXCHANGES
....
exchange = config.get("exchange", {}).get("name", "").lower()
if not exchange:
raise OperationalException(
f"This command requires a configured exchange. You should either use "
f"`--exchange <exchange_name>` or specify a configuration file via `--config`.\n"
f"The following exchanges are available for Freqtrade: "
f'{", ".join(available_exchanges())}'
)
if exchange in SUPPORTED_EXCHANGES:
print("Custardtart exchange recognized")
return True
Make sure the __pycache__ is deleted.
Make it so custardtart.py exits gracefully.