This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const bitcore = require('bitcore-lib'); | |
const Insight = require('bitcore-insight').Insight; | |
let insight = new Insight('testnet'); | |
// Our private key and address | |
const wif = 'xBtatQED9H44gCmp6HAdmemAzU3n84H3dGkuWTKvE23JgHMW8gct'; | |
const privateKey = new bitcore.PrivateKey(wif); | |
const myAddress = privateKey.toAddress(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const request = require('request'); | |
const Table = require('cli-table'); | |
// Algorithm will run every 5 seconds | |
setInterval( () =>{ | |
// API request to Coin Market Cap for top 20 cryptocurrencies | |
request('https://api.coinmarketcap.com/v1/ticker/', function(error, response, body) { | |
const chart = JSON.parse(body); | |
// The cap of how much of the portfolio could allocate to a certain cryptocurrency (0.05 = 5%) | |
// no cryptocurrency will surpass this cap amount in portfolio allocation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calc_allocations(self, date, quantity, cap): | |
"""Figure out ideal allocations for a given date""" | |
# { | |
# coin_name: (percent_allocation, data) | |
# } | |
top_market = self.get_top_market(date, quantity) | |
total_cap = sum([coin.market_cap for coin in top_market]) | |
allocations = [{ |