-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpull_data.sh
More file actions
executable file
·41 lines (37 loc) · 1.08 KB
/
pull_data.sh
File metadata and controls
executable file
·41 lines (37 loc) · 1.08 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
#!/bin/bash
# Constant file names to reference for pulling data
JSON_FILE_NAMES=(getmarketsummaries)
TEXT_FILE_NAMES=(Ask BaseVolume Bid High Last Low MarketName OpenBuyOrders OpenSellOrders Volume)
# Function for pulling json data to be cleaned
pull_data() {
for name in $JSON_FILE_NAMES
do
wget -qO- https://bittrex.com/api/v1.1/public/$name | jq ".result" > "$name.json"
done
}
# Function for cleaning and parsing to store in text files to use later
clean_data() {
for ((i=0;i<${#TEXT_FILE_NAMES[@]};i++))
do
> "pulled_data/${TEXT_FILE_NAMES[$i]}.txt"
for value in $(jq ".[].${TEXT_FILE_NAMES[$i]}" ${JSON_FILE_NAMES[0]}.json)
do
echo ${value//\"/} >> "pulled_data/${TEXT_FILE_NAMES[$i]}.txt"
done
done
}
# Main body of script starts here
# Make directory to contain pulled data files
if ! [ -e pulled_data ]
then
mkdir pulled_data
fi
while true
do
pull_data
clean_data
paste -d "," ./pulled_data/*.txt > "aggregate.txt"
./getHighLow.sh Volume 30 H
node index.js
sleep 1
done