-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sh
More file actions
executable file
·52 lines (40 loc) · 1.18 KB
/
script.sh
File metadata and controls
executable file
·52 lines (40 loc) · 1.18 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
rm --f ./*.csv
yest_date=$(date -d '-1 day' '+%Y_%m_%d')
name_concat() {
local input_string=$1
local first_part="CFTC_CUMULATIVE_"
local second_part="${yest_date}.zip"
# Concatenate the strings
local result="$first_part$input_string"_"$second_part"
# Return the result
echo "$result"
}
url_concat() {
local input_string=$1
local first_part="https://pddata.dtcc.com/ppd/api/report/cumulative/cftc/CFTC_CUMULATIVE_"
local second_part="${yest_date}.zip"
# Concatenate the strings
local result="$first_part$input_string"_"$second_part"
# Return the result
echo "$result"
}
action() {
local input_one=$1
local input_two=$2
curl $input_one --output $input_two
unzip $input_two
rm $input_two
}
commods_name=$(name_concat "COMMODITIES")
commods_url=$(url_concat "COMMODITIES")
credits_name=$(name_concat "CREDITS")
credits_url=$(url_concat "CREDITS")
forex_name=$(name_concat "FOREX")
forex_url=$(url_concat "FOREX")
rates_name=$(name_concat "RATES")
rates_url=$(url_concat "RATES")
mkdir -p data
action $commods_url $commods_name
action $credits_url $credits_name
action $forex_url $forex_name
action $rates_url $rates_name