29 lines
660 B
Bash
Executable File
29 lines
660 B
Bash
Executable File
#!/bin/bash
|
|
CredsFile=${1}
|
|
CredKey=${2}
|
|
|
|
if [ "${CredsFile}" == "" ] ; then
|
|
CredsFile="${HOME}/.creds"
|
|
fi
|
|
|
|
if [ "${CredKey}" == "" ] ; then
|
|
CredKey="ALPACA_SANDBOX"
|
|
fi
|
|
|
|
key=$(jq -r ".[\"${CredKey}\"] | .api_key" ${CredsFile})
|
|
secret=$(jq -r ".[\"${CredKey}\"] | .secret_key" ${CredsFile})
|
|
|
|
Cmd="curl -s --request GET --url 'https://paper-api.alpaca.markets/v2/assets?status=active'"
|
|
Cmd="${Cmd} --header 'APCA-API-KEY-ID: ${key}'"
|
|
Cmd="${Cmd} --header 'APCA-API-SECRET-KEY: ${secret}'"
|
|
Cmd="${Cmd} --header 'accept: application/json'"
|
|
|
|
eval ${Cmd}
|
|
|
|
# split string into array
|
|
Instruments=()
|
|
for Inst in $(eval ${Cmd})
|
|
do
|
|
Instruments+=("$Inst")
|
|
done
|