Using Elixir to Track The Price of Bitcoin

Using Elixir to Track The Price of Bitcoin
фото показано с : bitcoints.com

2018-7-10 19:38

Since our project will be fetching the price of a Bitcoin, we need a place to fetch Bitcoin data.
Finally let’s get the price with Map.get, now that we have the price let’s print what the price was.
lib/teacher/coin_data_worker.ex

defmodule Teacher.CoinDataWorker do
use GenServer

def start_link(args) do
GenServer.start_link(__MODULE__, args, name: __MODULE__)
end

def init(state) do
schedule_coin_fetch()
{:ok, state}
end

def handle_info(:coin_fetch, state) do
price = coin_price()
IO.inspect(“Current Bitcoin price is $#{price}”)
schedule_coin_fetch()
{:noreply, Map.put(state, :btc, price)}
end

defp coin_price do
“http://coincap.io/page/BTC”
|> HTTPoison.get!
$ iex -S mix
“Current Bitcoin price is $6149.728”
“Current Bitcoin price is $6149.728”
“Current Bitcoin price is $6149.728”
“Current Bitcoin price is $6149.728”
> :observer.start()
This is great – we’re fetching data from the API, parsing it, and logging the price.
$ iex -S mix
> “Current Litecoin price is $81.0156”
“Current Ethereum price is $454.076”
“Current Bitcoin price is $6148.09”
> :observer.start()
And let’s start the observer.

origin »

Bitcoin (BTC) на Currencies.ru

$ 94422.27 (+0.27%)
Объем 24H $27.21b
Изменеия 24h: -0.16 %, 7d: 1.14 %
Cегодня L: $94126.68 - H: $94691.62
Капитализация $1875.07b Rank 1
Цена в час новости $ 6401.89 (1374.91%)

price bitcoin genserver def start data let

price bitcoin → Результатов: 126


Bitcoin (BTC)’s price swings shake confidence while BinoFi (BINO) investors enjoy 1200% price appreciation

Bitcoin has captured headlines once again with its notorious price volatility, leaving traders uncertain about its next move. Recent fluctuations saw the leading cryptocurrency plunge from pivotal resistance levels, fueling debates about whether Bitcoin can sustain its dominance amidst shifting market dynamics.

2025-4-4 01:00


Bitcoin Price Holds Above $96,000 — Analyst Explains This Level’s Significance

The Bitcoin price appears to have settled within the $92,000 – $102,000 consolidation range, sparking discussions about the coin’s future trajectory. While it remains unclear whether the premier cryptocurrency has enough momentum to forge new all-time highs soon, it would take significant bearish pressure to pull down the BTC price.

2025-2-9 16:00


Bitcoin Price Struggles With Liquidity Blocks From $86,000 To $104,000, Analyst Reveals The Logical Thing To Do

The Bitcoin price has spent the majority of the past seven days consolidating around the $94,000 mark with signs of a break to either side. According to a crypto analyst, Bitcoin’s recent price movements have led to the creation of liquidity blocks observed between the $86,000 to $104,000 range, which raises an equal likelihood of a bounce towards $104,000 or a downside break to $86,000 from the current price.

2025-1-13 14:00


Bitcoin price analysis: economic headwinds push price lower

Bitcoin tested the $92,000 level yesterday after falling from a weekly high of $102,000 as sell pressures mounted Macroeconomic factors cause doubts about the market strength as sticky inflation becomes a concern Spot crypto ETFs logged large outflows on Wednesday following the release of the Fed meeting notes Bitcoin’s price has fallen from a high […] The post Bitcoin price analysis: economic headwinds push price lower appeared first on CoinJournal.

2025-1-11 17:48