This application calculates the Nigerian Naira (NGN) equivalence of the current bitcoin price in United States Dollar (USD). This is calculated using 3 (three) parameters:
-
Type
: This specifies the transaction type which is eitherbuy
orsell
, nothing else. -
Margin
: This is a percentage that is used in the calculation. Not a fraction, a percentage. For example, if0.2
is passed into this argument, then the calculation is done with 0.2%. -
Exchange rate
: This is a custom USD/NGN exchange rate that will be used in the calculation.
Bitcoin Exchange Calculator consumes CoinDesk's API. CoinDesk provides a simple API to make its Bitcoin Price Index (BPI) data programmatically available to all. CoinDesk data is made available through a number of HTTP resources, and data is returned in JSON format.
Bitcoin Exchange Calculator:
-
On the homepage, displays the current bitcoin
buy
andsell
prices in Nigerian Naira. -
Offers a GraphQL API with one query. The query
calculatePrice
accepts three required arguments:type
,margin
, andexchangeRate
with with the calculation is done.
This template was tested with Ruby 2.4.1 and Ruby on Rails 5.2.4.
The database used for this application is PostgreSQL. Ensure it is installed on your machine.
-
Create a
.env
file in the root directory -
Provide db credentials in the
.env
file for the following keys:
- POSTGRES_USER=
- POSTGRES_HOST=
- POSTGRES_PASSWORD=
- Run the command:
rails db:create
-
Clone this repo -
git clone https://github.com/ODINAKACHUKWU/bitcoin-exchange-calculator.git
-
Switch into the newly-cloned directory
cd bitcoin-exchange-calculator
-
Run
bundle install
to install all the necessary gems -
Start the server using the command
rails s
-
Visit the site on your browser using
localhost:3000
For more details contact solomonzbk@gmail.com
Support or Contributions are highly appreciated. Please send me an email for any suggestion, support or issue. To contribute:
-
Fork this repository or clone the repository with the command:
$ git clone https://github.com/ODINAKACHUKWU/bitcoin-exchange-calculator
. -
Change directory into the root of the project directory.
-
Create your feature branch and make your contributions to your local copy of the project.
-
Raise a pull request against the master branch describing what your feature does and how it can be tested.
I thank CoinDesk for making this API freely available to others.