Strategy vault / Tools & templates
Get cryptocurrency current and max supply
Use the API provided by CoinMarketCap to obtain cryptocurrency supply and circulation, which can be used to calculate total market capitalization.
Use the API provided by CoinMarketCap to obtain cryptocurrency supply and circulation, which can be used to calculate total market capitalization.
Source JavaScript
function GetSupply(symbol, max){
var ids = null
if(_G('ids')){
ids = _G('ids')
}else{
ids = JSON.parse(HttpQuery('https://api.coinmarketcap.com/v2/listings/')).data
_G('ids', ids)
}
var coinId = null
for (var i=0; i<ids.length; i++){
if(ids[i].symbol.toLowerCase() == symbol.toLowerCase() ){
coinId = ids[i].id
break
}
}
if(coinId){
var ticker = JSON.parse(HttpQuery('https://api.coinmarketcap.com/v2/ticker/'+ coinId + '/')).data
return parseFloat(max == undefined ? ticker.total_supply: ticker.max_supply)
}else{
throw 'symbol not found'
}
}
function main() {
Log(GetSupply('BTC')) // Get total current supply
Log(GetSupply('BTC', true)) // Get max supply
}Published by 小草 on the FMZ strategy square · last modified 2019-07-03. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a tested, production-ready module from strategies/Get-cryptocurrency-current-and-max-supply.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.
Related specs
- Binance Account Cross Transfer Small ToolJavaScript · Tools & templates
- Interaction TemplateJavaScript · Tools & templates
- KuCoin Fund Transfer PluginJavaScript · Tools & templates
- Moving Average Bot 30 linesJavaScript · Tools & templates · 1d
- OKEx V5 Candlestick Data Paginated Query ExampleJavaScript · Tools & templates
- Single Currency Dynamic Equilibrium V10 District LeaderJavaScript · Tools & templates · 1d