updatetools
v0.3.7
Published
Update the data for mongodb database of Cryptocurrency
Readme
% updateTools This library is designed to Read & Write Crypto Currency historical data to and from a Mongo Database
The DB functions often call the cbxQuery library that I created to read the data from the coinbase api located at:
"https://api.exchange.coinbase.com/products/";The functions that are at the heart of this libary are:
- DBcollectionList- is used to get a list of collections from the mongo database.
- DBproductExist- is a simple check to see if a specific product exists in the mongo database.
- DBmostRecentDate- looks to see when the last update was run by finding the most recent data for a specific collection.
- DBfillBlanks- when the Coinbase server was down for maintenance or in the early years when volume was not high enough to have an entry every hour, there are missing spots in the data. This code will create records with zero volume and the Last recorded price. This makes analysis more consistant especially for earlier data.
- DBpatchBlanks- Sometimes blank spaces are due to download errors, this routine tries to re-read the data to fill in missing points
- DBrecordCount- Count how many records are in collection
- DBupdateCollection- Update the collection for a single collection
- DBupdateCollections- get the list of all collections and up date each one of them.
- DBupdateSet- This function actually write the data to the server
- DBpatchCollection- patch all missing data for a collection
To use this library, I created a mongodb Atlas server and change the definition of MONGODB_URI to use the address given by doing the following:
Open Atlas database in MongoDB Compass
Click on the 3 dots on the database line
Choose "Copy Connection String
Paste the string as a replacement for: "mongodb//user:password@hosturl/databasename"
I named the Database: Coinbase And created empty collections with names such as:
- ADA-USD
- BTC-USD
- ETH-USD
When there is an empty collection, running DBupdateCollection passing the new collection name or DBupdateCollections will start to fill the data for the new collection.
This library is used by cryptoUpdate code set. For information on cryptoUpdate see:
Maintenance
When making modifications to this code make sure to do the following:
- Make modifications and test locally using /testing/testuTools.js
- Update Version number int package.json file
- Update github by clicking the source control button in VSC and Providing a short description of changes and then pressing the commit button
- Update NPM by doing the following: a) In terminal run this command: npm publish b) It wll ask you to authenticate the npm account in the browser. c) Press enter key d) You will be taken to the browser and asked for authenticator code for npm e) Provide the authenticator code
- You will need to Update the code CryptoUpdate to use this new code and then update the code on the server
