Crypto backtesting
Loading...
Searching...
No Matches
marketstack.sh
Go to the documentation of this file.
1#!bin/bash
2
3# Get Marketstack API key
4[[ -z $MARKETSTACK_API_KEY ]] && echo "MARKETSTACK_API_KEY not set" && exit 1
5
6readonly tmp_dir=/tmp/stocks
7readonly stocks_file=stocks.txt
8
9mkdir -p $tmp_dir
10
11# Calculate number of entries
12readonly num_lines=$(wc -l < $stocks_file)
13
14echo "Fetching $num_lines stocks"
15
16# Fetch JSON for each currency pair
17cat $stocks_file | while read token; do
18
19 # Break out if there's a blank line
20 [[ -z $token ]] && break
21
22 output_file=$tmp_dir/Marketstack-$token.json
23 echo Writing prices for $token to $output_file
24
25 # Get as many recent data as we can from Marketstack using 1 hour intervals
26 curl --silent "http://api.marketstack.com/v1/intraday?access_key=$MARKETSTACK_API_KEY&symbols=$token&limit=2000&interval=1hour" > $output_file
27
28done