Skip to content

Latest commit

 

History

History
132 lines (94 loc) · 4.85 KB

README.md

File metadata and controls

132 lines (94 loc) · 4.85 KB

Citcoins logo

Status GitHub Issues GitHub Pull Requests License


A crypto price discovery tool for the time travelling investor.

📝 Table of Contents

🧐 About

The assignment was to create an application or an API backend that would let users check the price of bitcoin between two dates. We should also determine, during the given time frame:

  1. how many days did the longest downtrend last?
  2. which date had the highest trading volume?
  3. on which dates should we have bought and sold to maximize profits, if at all possible?

We were to use Coingecko's API for the data. The user is interested in daily values.

Citcoins is a REST API backend. It adds fields to the JSON responses from Coingecko, answering the assignment's questions. It forces daily granularity by requesting at least 91 days worth of data.

💥 Live Demo

The API is running at https://citcoins.herokuapp.com/api/

To get daily prices, volumes and market caps for bitcoin in euros for the first week of December 2021, with the insights for longest downtrend, day with the highest volume and maximum profit included, send a GET request to

https://citcoins.herokuapp.com/api/coins/bitcoin/market_chart/range?from=1638309600&to=1638828000&insights=true

The response JSON has the unix timestamps in milliseconds:

{
  "prices" : [],
  "market_caps" : [],
  "total_volumes" : [],
  "max_volume" : [1638662400000, 49444429183.12263],
  "longest_downtrend" : { 
    "found" : true,
    "start" : [1638403200000, 50506.910551023844],
    "end" : [1638662400000, 43452.36627055587],
    "length_in_days" : 3
  },
  "max_profit" : { 
    "should_buy" : true,
    "when_to_buy" : [1638316800000, 50310.23157858034],
    "when_to_sell" : [1638403200000, 50506.910551023844],
    "profit" : 196.67897244350752 
  },
  "attribution" : "Data provided by CoinGecko"
}

📓 API reference

The Citcoins API is organized around REST. The API has predictable resource-oriented URLs, returns JSON-encoded responses, and uses standard HTTP response codes.

Endpoint Description
GET /api Returns links to API resources.
GET /api/coins Returns links to API resources.
GET /api/coins/list Lists the IDs of supported crypto and fiat currencies.
GET /api/coins/:id Basic information on a cryptocurrency.
id - cryptocurrency identifier, ex. bitcoin
GET /api/coins/:id/market_chart Returns daily data for 100 days on prices, market caps and total volumes.
id - cryptocurrency identifier, ex. bitcoin
vs_currency - optional parameter for fiat currency, ex. eur
GET /api/coins/:id/market_chart/range Returns daily data between the two dates given as parameters.
Can also add analytical insights to the response.
id - cryptocurrency identifier, ex. bitcoin
from=1638309600 - unix timestamp in seconds
to=1638828000 - unix timestamp in seconds
insights=true - optional parameter for insights
vs_currency - optional parameter for fiat currency, ex. eur

🏁 Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

Make sure you have a recent version of Node.js installed.

Installing

Clone the repository, install Node.js modules.

git clone https://github.com/simosavonen/citcoins.git
cd citcoins
cd server
npm install

Start the application in development mode.

npm run dev

The API should now be running at http://localhost:3001/api

🔧 Running the tests

To run the battery of tests

npm test

The tests are found in directory /tests and are separated into integration and unit tests. Integration tests use real data fetched from Coingecko API.

⛏️ Built Using

Notes to self

Push server subdirectory to heroku

git subtree push --prefix server heroku master