The Krypto.Binance and Krypto.CoinPair servers are started along with application.
This module simulates a Persistent Server for subscribing the coinpair and storing the prices of coinpair using GenServer.
It will start as soon as our krypto app starts.
At the moment of developing this project, I used the following versions of Elixir and Erlang.
iex> mix hex.info
Hex: 2.0.6
Elixir: 1.16.1
OTP: 26.2.2
Built with: Elixir 1.16.1 and OTP 24.3.4.16mix deps.get
mix release krypto
I added the releases path to ./releases
So, we are provided with following commands.
Release created at releases
# To start your system
releases/bin/krypto start
Once the release is running:
# To connect to it remotely
releases/bin/krypto remote
# To stop it gracefully (you may also send SIGINT/SIGTERM)
releases/bin/krypto stop
To list all commands:
releases/bin/krypto
Running Interactively
- Websockex Integration (Binance) Subscription Implementation.
- CoinPair Server for subscribing and updating the coinpair prices.
When the application starts, we have two modules available. Krypto.Binance and Krypto.CoinPair. The Krypto.Binance establish a websocket connection as soon as the application starts.
iex> Krypto.CoinPair.subscribe "btcusdt"
:ok
iex> Krypto.CoinPair.subscribe "ethusdt"
:okiex> Krypto.CoinPair.get_average "btcusdt"
{:ok, 64019.6706875}
iex> Krypto.CoinPair.get_average "ethusdt"
{:ok, 3150.221481481482}
iex> :sys.trace(Process.whereis(Krypto.Binance), true)I felt it is a well framed to test core concepts of Elixir as project made me to code in all the core concepts of Elixir like GenServers, Enumaration, message communications, websocket.
Thank You :)
Best Regards,
Ankanna