Skip to content

Commit

Permalink
hotfix: getTickersPrices helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
yeikiu committed Nov 16, 2024
1 parent 7a3e2a4 commit d6d87c2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

> All major changes will be added to this file top-to-bottom
- ### v4.0.5

- #### hotfix:
- Fixed `getTickersPrices` helper method: The `pairs` param is optional now. Not passing it will default to all pairs available.

- ### v4.0.4

- #### features:
- Added support for `AmendOrder` under REST and WS2 apis.

- ### v4.0.0

- #### features:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-kraken",
"version": "4.0.4",
"version": "4.0.5",
"description": "A strongly typed library to operate with the Kraken Crypto Exchange",
"keywords": [
"kraken",
Expand Down
9 changes: 7 additions & 2 deletions src/api/rest/public/helpers/get_tickers_prices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ import { publicRestRequest } from '../public_rest_request';
console.log({ btcUsdPrice, ethEurPrice });
});
getTickersPrices()
.then(allPairsTickers => {
console.table(allPairsTickers);
});
* ```
*/
export const getTickersPrices = async (pair: string) => {
const result = await publicRestRequest({ url: 'Ticker', params: { pair } });
export const getTickersPrices = async (pairs?: string) => {
const result = await publicRestRequest({ url: 'Ticker', params: { pair: pairs } });

return Object.keys(result).map(pairKey => {
const rawKrakenPayload = result[pairKey];
Expand Down
8 changes: 7 additions & 1 deletion src/demo_playground/public_playground.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { publicRestRequest, publicWsSubscription } from '..';
import { getTickersPrices, publicRestRequest, publicWsSubscription } from '..';

const runAsync = async () => {

Expand All @@ -19,6 +19,12 @@ const runAsync = async () => {
fiveMinsBtcUsdCandles$.subscribe(({ data: [{ open, high, low, close }] }) => {
console.log({ open, high, low, close });
});

const [{ price: btcUsdPrice }, { price: ethEurPrice }] = await getTickersPrices('BTCUSD,ETHEUR');
console.log({ btcUsdPrice, ethEurPrice });

const allPairsTickers = await getTickersPrices();
console.table(allPairsTickers);
};

runAsync();

0 comments on commit d6d87c2

Please sign in to comment.