-
-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathdocker-entrypoint.sh
More file actions
139 lines (127 loc) · 3.4 KB
/
docker-entrypoint.sh
File metadata and controls
139 lines (127 loc) · 3.4 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/sh
# Copyright (c) 2021-2026 Onur Cinar.
# The source code is provided under GNU AGPLv3 License.
# https://github.com/cinar/indicator
set -e
API_KEY=""
DAYS=365
LAST=365
ASSETS=""
OUTPUT="/app/output"
DATA_DIR="/app/data"
show_usage() {
echo "Usage: indicator [OPTIONS]"
echo ""
echo "Sync market data from Tiingo and run backtests."
echo ""
echo "Options:"
echo " --api-key KEY Tiingo API key (required)"
echo " --days N Days of historical data to fetch (default: 365)"
echo " --last N Days to backtest (default: 365)"
echo " --assets TICKERS Space-separated list of ticker symbols (default: all available)"
echo " --output DIR Output directory for reports (default: /app/output)"
echo " --help Show this help message"
echo ""
echo "Example:"
echo " indicator --api-key YOUR_KEY --days 365 --assets aapl msft googl"
echo ""
echo "Get your free Tiingo API key at: https://www.tiingo.com/"
}
while [ $# -gt 0 ]; do
case "$1" in
--api-key)
API_KEY="$2"
shift 2
;;
--days)
DAYS="$2"
shift 2
;;
--last)
LAST="$2"
shift 2
;;
--assets)
shift
ASSETS=""
while [ $# -gt 0 ] && [ "${1#-}" = "$1" ]; do
ASSETS="${ASSETS:+$ASSETS }$1"
shift
done
;;
--output)
OUTPUT="$2"
shift 2
;;
--help)
show_usage
exit 0
;;
*)
echo "Unknown option: $1"
show_usage
exit 1
;;
esac
done
if [ -z "$API_KEY" ]; then
echo "Error: --api-key is required"
echo ""
show_usage
exit 1
fi
echo "=========================================="
echo "Indicator Docker - Sync & Backtest"
echo "=========================================="
echo ""
echo "Configuration:"
echo " API Key: ***"
echo " Days: $DAYS"
echo " Backtest Period: $LAST days"
echo " Assets: ${ASSETS:-all}"
echo " Output: $OUTPUT"
echo ""
mkdir -p "$OUTPUT"
echo "Step 1: Syncing market data from Tiingo..."
echo "-------------------------------------------"
if [ -z "$ASSETS" ]; then
./indicator-sync \
-source-name tiingo \
-source-config "$API_KEY" \
-target-name filesystem \
-target-config "$DATA_DIR" \
-days "$DAYS"
else
./indicator-sync \
-source-name tiingo \
-source-config "$API_KEY" \
-target-name filesystem \
-target-config "$DATA_DIR" \
-days "$DAYS" \
$ASSETS
fi
echo ""
echo "Step 2: Running backtests..."
echo "-------------------------------------------"
if [ -z "$ASSETS" ]; then
./indicator-backtest \
-repository-name filesystem \
-repository-config "$DATA_DIR" \
-report-name html \
-report-config "$OUTPUT" \
-last "$LAST"
else
./indicator-backtest \
-repository-name filesystem \
-repository-config "$DATA_DIR" \
-report-name html \
-report-config "$OUTPUT" \
-last "$LAST" \
$ASSETS
fi
echo ""
echo "=========================================="
echo "Done! Reports generated in: $OUTPUT"
echo "=========================================="
echo ""
echo "Open $OUTPUT/index.html in your browser to view the results."