Open Wisdom132 opened 3 years ago
Once my other PR is merged , you can create entries for bit coin like shown below :
new ExchangeApiStructure({
exchange: Exchange.findOne({
name: 'binance'
}),
coin: Coin.findOne({
symbol: 'BTC'
}),
endPointPath: '',
queryParams: {
symbol: 'BTCUSD'
},
///See https://www.npmjs.com/package/jsonpath for syntax reference
priceJsonPath: '$.weightedAvgPrice',
///See https://www.npmjs.com/package/jsonpath for syntax reference
volumeJsonPath: '$.volume',
})
For Ethereum like shown below :
new ExchangeApiStructure({
exchange: Exchange.findOne({
name: 'binance'
}),
coin: Coin.findOne({
symbol: 'ETH'
}),
endPointPath: '',
queryParams: {
symbol: 'ETHUSD'
},
priceJsonPath: '$.weightedAvgPrice',
volumeJsonPath: '$.volume',
})
You can repeat the same for other exchange sites also by changing the endPointPath, queryParams , priceJsonPath and volumeJsonPath guys.
I have raised the PR here : #52 which contains some example entries for the collection.
@nateshmbhat @Wisdom132 are we only going to list two coins? what about maintaining the db with API endpoints and fetching it likewise?
@sangamkotalwar We will add other coins, we're starting with BTC and ETH for now
@melodyogonna if we are going to create seperate class instances for each exchange for each coin, that is not a feasible solution for scalability. Can you please confirm if this is only for POC?
@sangameshBB, it's just a POC so we are going to store all the endpoints in the database later on.
These are the API docs of the exchanges that were used to get the price of the coins:
https://docs.pro.coinbase.com/ https://www.kraken.com/features/api https://docs.bitfinex.com/reference https://docs.gemini.com/rest-api/ https://github.com/binance-us/binance-official-api-docs/blob/master/rest-api.md
Use these endpoints to get Bitcoin price and volume: https://api.gemini.com/v1/pubticker/btcusd https://api.kraken.com/0/public/Ticker?pair=BTCUSD https://api-pub.bitfinex.com/v2/tickers?symbols=tBTCUSD
And these endpoints to get Ethereum price and volume: https://api.gemini.com/v1/pubticker/ethusd https://api.kraken.com/0/public/Ticker?pair=ethUSD https://api-pub.bitfinex.com/v2/tickers?symbols=tETHUSD
And this methodology to get the Volume Weighted Average: https://github.com/coinratecap/Backend/issues/40#issuecomment-778971838