Skip to content

hexresearch/crypto-history

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

crypto-history

Fetches historical data for cryptocurrencies from coinmarketcap.com.

With this library we can load and save historical data for various crypto-currencies. It uses API to coinmarketcap.com to fetch the data.

In the coinmarketcap the currencies are referenced by special ids. we can query the specific id with the function getCoinId:

> import Crypto.History
> Right coinId <- getCoinId (CoinCode "ETH")
> print coinId
> CoinId "ethereum"

Once we know the id we can query the historical data:

> Right hist <- getHistory (dateStr "01-01-2015") (dateStr "01-01-2018") coinId

The dateStr is a helper function to quickly construct UTCTime from string in the format dd-mm-yyyy. Also we can query all time history data:

> Right hist <- getAllTimeHistory coinId

All prices are relative to USD. But if we want to relate to another currency we can use a special variant that uses cross-prices to calculate the given relation:

> Right hist <- getHistory2 (dateStr "01-01-2015") (dateStr "01-01-2018") (coinIdA, coinIdB)

It uses the function cross :: History -> History -> History under the hood to create cross-prices relative to specific coins.

We can save and load the data to/from CSV files:

> writeHistory "file.csv" hist
> Just hist <- readHistory "file.csv"

The function readHistory - reads data strictly. For lazy reading we can use readHistoryLazy.

About

Fetches historical data for cryptocurrencies

Resources

License

Stars

2 stars

Watchers

13 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors