setting API Key (to AVClient) throws Error and/or does not pick up env var
gwd999 opened this issue · 8 comments
Based on the provided Usage example
julia> client = AlphaVantage.GLOBAL[]
AVClient("", "https://www.alphavantage.co/")
julia> client.key = "AV_APIKEY"
ERROR: setfield! immutable struct of type AVClient cannot be changed
Stacktrace:
[1] setproperty!(x::AVClient, f::Symbol, v::String)
@ Base ./Base.jl:34
[2] top-level scope
@ REPL[13]:1
@gwd999 can you share your output of versioninfo()
and Pkg.status("AlphaVantage")
?
I'm not able to reproduce this
Steps performed today
...
(@v1.6) pkg> add AlphaVantage
Updating registry at `~/.julia/registries/General`
Resolving package versions...
Installed Nullables ──── v1.0.0
Installed ArgCheck ───── v2.1.0
Installed HttpCommon ─── v0.5.0
Installed AlphaVantage ─ v0.3.0
Updating `~/.julia/environments/v1.6/Project.toml`
[6348297c] + AlphaVantage v0.3.0
Updating `~/.julia/environments/v1.6/Manifest.toml`
[6348297c] + AlphaVantage v0.3.0
[dce04be8] + ArgCheck v2.1.0
[77172c1b] + HttpCommon v0.5.0
[4d1e1d77] + Nullables v1.0.0
[30578b45] + URIParser v0.4.1
Precompiling project...
5 dependencies successfully precompiled in 9 seconds (107 already precompiled)
julia> using AlphaVantage
julia> client = AlphaVantage.GLOBAL[]
AVClient("", "https://www.alphavantage.co/")
julia> client.key="My_AV_APIKEY"
ERROR: setfield! immutable struct of type AVClient cannot be changed
Stacktrace:
[1] setproperty!(x::AVClient, f::Symbol, v::String)
@ Base ./Base.jl:34
[2] top-level scope
@ REPL[7]:1
julia> versioninfo()
Julia Version 1.6.1
Commit 6aaedecc44 (2021-04-23 05:59 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, icelake-client)
julia> Pkg.status("AlphaVantage")
Status `~/.julia/environments/v1.6/Project.toml`
[6348297c] AlphaVantage v0.3.0
@ellisvalentiner Sorry for the delay in reply
So I updated Julia to latest version and tried again
In Bash shell I ran
export ALPHA_VANTAGE_API_KEY="123456"
started julia
julia> versioninfo()
Julia Version 1.8.0-DEV
Commit 50fcb03242 (2021-10-18 17:28 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-12.0.1 (ORCJIT, icelake-client)
Environment:
JULIA_NUM_THREADS = 6
julia> Pkg.status()
Status `~/.julia/environments/v1.8/Project.toml`
[6348297c] AlphaVantage v0.3.0
[a93c6f00] DataFrames v1.2.2
[864edb3b] DataStructures v0.18.10
[587475ba] Flux v0.12.8
[2b0e0bc5] LanguageServer v4.1.0
[5fb14364] OhMyREPL v0.5.10
[295af30f] Revise v3.1.20
[f3b207a7] StatsPlots v0.14.28
julia> using AlphaVantage
julia> AlphaVantage.GLOBAL[]
AVClient("", "https://www.alphavantage.co/")
despite
julia> ENV
...
"ALPHA_VANTAGE_API_KEY" => "123456"
...
and
julia> get(ENV, "ALPHA_VANTAGE_API_KEY", "")
"123456"
this happens ...
julia> spy=time_series_daily("SPY");
┌ Warning: No API key found
└ @ AlphaVantage ~/.julia/packages/AlphaVantage/TvEib/src/avclient.jl:22
@ellisvalentiner
I think that it could be this line 23 in AlphaVantage.jl
export global_key!, global_entry!, AVClient
I changed it to
export global_key!, global_entry!, AVClient!
and the error was gone.
Can you try using the dev version of AlphaVantage please, it looks like it has been fixed?
> add https://github.com/ellisvalentiner/AlphaVantage.jl
We will get the latest release in the general repo shortly
Can you try using the dev version of AlphaVantage please, it looks like it has been fixed?
> add https://github.com/ellisvalentiner/AlphaVantage.jl
We will get the latest release in the general repo shortly
Will do - but basically the change to line 23 fixed it for me
@dm13450: as a sidenote I have noticed that the format of the "spy" data seems to have changed
@dm13450
and info to @stefanradev93
Pkg.add(url="https://github.com/ellisvalentiner/AlphaVantage.jl")
did the trick - all green now