defmodule Pump do
#Get most actively traded pairs as often as possible from https://api.wavesplatform.com/v0/pairs.
trading_activity = HTTPoison.get! ("https://api.wavesplatform.com/v0/pairs")
snapshot = Poison.decode! trading_activity.body, keys: :atoms
#Exclude all pairs with volumeWAVES < 500
volume_waves_greater_than_or_equal_to_500 = Enum.filter(snapshot.data, fn pairs -> pairs.data.volumeWaves >= 500.0 end)
#Send results to database.
end
Ah shoot I totally missed that. Yeah, that’s the reason, the applications like HTTpoison are not started at compile time. The whole code probably should be within some function.
By using defmodule you are creating a module, its body will get evaluated at compile time to eventually become the modules functions and then gets stored to disk.
Those module and the functions within can then be used at runtime to produce values.
Elixirs compilation though can also call function in another module and use the result to produce code that creates functions, so thats what your current code looks like it’s eventually trying to do that.
I’m not sure though if you really get what I’m writing, as I’m not sure how to explain properly, also I’m on the bus crowded with people and I can’t properly think in such an environment…