Skip to content

Commit

Permalink
adding kraken fetch pairs
Browse files Browse the repository at this point in the history
  • Loading branch information
mlake committed Jun 15, 2021
1 parent 4221a64 commit 5395d85
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 3 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ In addition to fetching all/btc/usd/usdt/etc, you may also fetch perpetual contr
# Creates bittrex_btc_pairs.csv
```

#### Download Trading Pairs From Kraken

```yaml
./atat fetch-pairs kraken usd

# Creates kraken_usd_pairs.csv
```


...and so on..


Expand Down
25 changes: 24 additions & 1 deletion dist/service/exchange-service.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/service/exchange-service.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 33 additions & 1 deletion src/service/exchange-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,40 @@ const BINANCEUS = "binanceus"
const BITTREX = "bittrex"
const COINBASE = "coinbase"
const FTX = "ftx"
const KRAKEN = "kraken"

export const exchangesAvailable = [BINANCEFUTURES, BINANCE, BINANCEUS, BITTREX, COINBASE, FTX]
export const exchangesAvailable = [BINANCEFUTURES, BINANCE, BINANCEUS, BITTREX, COINBASE, FTX, KRAKEN]

const CONST_ALL = "all"

const fetchKraken = async (quoteAsset: string): Promise<IExchangeSymbol[]> => {
const resp = await fetch("https://api.kraken.com/0/public/AssetPairs")

const responseObject = await resp.json()

const symbolsObject = responseObject.result

const exchangeSymbols: IExchangeSymbol[] = []

for (const key of Object.keys(symbolsObject)) { // key = "AAVEAUD"

const symbolObj = symbolsObject[key]

if (symbolObj.wsname){
const [symbolBase, symbolQuote] = symbolObj.wsname.split("\/") // "AAVE\/AUD"

if ((quoteAsset === CONST_ALL || symbolQuote === quoteAsset.toUpperCase())) {
exchangeSymbols.push(
new ExchangeSymbol("KRAKEN", symbolBase, symbolQuote)
)
}
} else {
// some results are strange things like "ETHCAD.d"
}
}
return exchangeSymbols
}

const fetchBittrex = async (quoteAsset: string): Promise<IExchangeSymbol[]> => {
const resp = await fetch("https://api.bittrex.com/api/v1.1/public/getmarkets")

Expand Down Expand Up @@ -168,6 +197,9 @@ export const fetchPairsForExchange = async (exchange: string, quoteAsset: string
case BITTREX:
symbolArray = await fetchBittrex(quoteAsset)
break;
case KRAKEN:
symbolArray = await fetchKraken(quoteAsset)
break;
default:
console.error("No exchange exists: ", exchange)
break;
Expand Down

0 comments on commit 5395d85

Please sign in to comment.