-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript-en.sh
71 lines (56 loc) · 2.96 KB
/
script-en.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run with sudo."
echo "Re-running the script using sudo..."
sudo "$0" "$@"
exit $?
fi
echo "
'##::: ##:::'#####:::'##::: ##::::'###::::'##::::'##:'########:'##::: ##:'##::::'##:'##:::::::'##:::::::
###:: ##::'##.. ##:: ###:: ##:::'## ##::: ###::'###: ##.....:: ###:: ##: ##:::: ##: ##::::::: ##:::::::
####: ##:'##:::: ##: ####: ##::'##:. ##:: ####'####: ##::::::: ####: ##: ##:::: ##: ##::::::: ##:::::::
## ## ##: ##:::: ##: ## ## ##:'##:::. ##: ## ### ##: ######::: ## ## ##: ##:::: ##: ##::::::: ##:::::::
##. ####: ##:::: ##: ##. ####: #########: ##. #: ##: ##...:::: ##. ####: ##:::: ##: ##::::::: ##:::::::
##:. ###:. ##:: ##:: ##:. ###: ##.... ##: ##:.:: ##: ##::::::: ##:. ###: ##:::: ##: ##::::::: ##:::::::
##::. ##::. #####::: ##::. ##: ##:::: ##: ##:::: ##: ########: ##::. ##:. #######:: ########: ########:
..::::..::::.....::::..::::..::..:::::..::..:::::..::........::..::::..:::.......:::........::........::
"
echo "List of running Docker containers:"
docker ps --format "table {{.Names}}\t{{.Image}}"
read -p "Enter the name of the Docker container or just press Enter if the name is freqtrade: " container_name
default_container_name="freqtrade"
if [ -z "$container_name" ]; then
container_name=$default_container_name
fi
if docker ps -a --format "{{.Names}}" | grep -q $container_name; then
echo "Container with name '$container_name' found. Running 'docker exec' command to enter the container..."
read -p "Enter the strategy name or multiple separated by space: " strategy_input
num_strategies=$(echo $strategy_input | wc -w)
strategies=""
if [ "$num_strategies" -eq 1 ]; then
strategies="-s $strategy_input"
elif [ "$num_strategies" -gt 1 ]; then
strategies="--strategy-list $strategy_input"
fi
read -p "Enter test timerange in YYYYMMDD-YYYYMMDD format: " timerange
read -p "Specify timeframe (requered for multiple strategies): " timeframe
read -p "Maximum number of open trades: " max_open_trades
read -p "Amount per stake: " stake_amount
read -p "List of pairs in format XYZ/ABC for spot and XYZ/ABC:HJK for futures: " p
read -p "Absolute path to config file or filename: " config
command="freqtrade backtesting $strategies"
[[ -n $timerange ]] && command="$command --timerange $timerange"
[[ -n $timeframe ]] && command="$command --timeframe $timeframe"
[[ -n $max_open_trades ]] && command="$command --max-open-trades $max_open_trades"
[[ -n $stake_amount ]] && command="$command --stake-amount $stake_amount"
[[ -n $p ]] && command="$command -p $p"
[[ -n $config ]] && command="$command --config $config"
if docker exec -it $container_name bash -c "$command"; then
echo "The command completed successfully."
else
echo "An error occurred while executing a command in the container."
fi
echo "$command"
else
echo "Container with name '$container_name' not found."
fi