-
Notifications
You must be signed in to change notification settings - Fork 6
/
010_get_fundamentals
executable file
·43 lines (37 loc) · 1.08 KB
/
010_get_fundamentals
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
#!/usr/bin/env bash
CONF_DIR='./data/conf/'
FUNDAMENTALS_DIR='data/fundamentals/'
FUNDAMENTALS_LOG_DIR=${FUNDAMENTALS_DIR}'logs/'
mkdir -p ${FUNDAMENTALS_LOG_DIR}
stdout_log() {
echo "`date +%Y-%m-%d:%H:%M:%S` ${1}"
}
loop_in_tickers_in_row() {
tickers_row=$1
stdout_log "Processing tickers '${tickers_row}'"
IFS=',' read -ra tickers <<< "$tickers_row"
for ticker in "${tickers[@]}"; do
stdout_log "Processing current ticker [$ticker]"
pystock-crawler reports ${ticker} -o ${FUNDAMENTALS_DIR}fundamentals_${ticker}.csv -s 20060101 -e 20161231 --sort -l "${FUNDAMENTALS_LOG_DIR}tickers_${ticker}.log"
done
}
loop_in_csv_rows() {
INPUT=$1
OLDIFS=$IFS
IFS=:
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read category tickers_row
do
stdout_log "Processing tickers in category: '${category}'"
loop_in_tickers_in_row $tickers_row
done < $INPUT
IFS=$OLDIFS
}
loop_on_files_in_directory() {
for csv_file in ${CONF_DIR}tickers_*.csv
do
stdout_log "Reading ${csv_file}"
loop_in_csv_rows $csv_file
done
}
loop_on_files_in_directory