Skip to content

Commit

Permalink
Merge pull request #65 from vansergen/getpricefeed
Browse files Browse the repository at this point in the history
Getpricefeed
  • Loading branch information
vansergen committed Mar 21, 2020
2 parents 973c1cc + dc14080 commit 061a36c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ const history = await client.getAuctionHistory({
});
```

- [`getPriceFeed`](https://docs.gemini.com/rest-api/#price-feed)

```typescript
const priceFeed = await client.getPriceFeed();
```

### AuthenticatedClient

```typescript
Expand Down
13 changes: 13 additions & 0 deletions src/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ export type AuctionHistory = {
unmatched_collar_quantity?: string;
};

export type PriceFeedItem = {
pair: string;
price: string;
percentChange24h: string;
};

export type PublicClientOptions = {
symbol?: string;
sandbox?: boolean;
Expand Down Expand Up @@ -201,4 +207,11 @@ export class PublicClient extends RPC {
const uri = "v1/auction/" + symbol + "/history";
return this.get({ uri, qs: { limit_auction_results, ...qs } });
}

/**
* Get the price feed.
*/
getPriceFeed(): Promise<PriceFeedItem[]> {
return this.get({ uri: "v1/pricefeed" });
}
}
30 changes: 29 additions & 1 deletion test/public.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
OrderBook,
Trade,
AuctionInfo,
AuctionHistory
AuctionHistory,
PriceFeedItem
} from "../index";

const client = new PublicClient();
Expand Down Expand Up @@ -702,4 +703,31 @@ suite("PublicClient", () => {
const data = await client.getAuctionHistory();
assert.deepStrictEqual(data, response);
});

test(".getPriceFeed()", async () => {
const uri = "/v1/pricefeed";
const response: PriceFeedItem[] = [
{ pair: "LTCETH", price: "0.2905", percentChange24h: "-0.0027" },
{ pair: "LTCBCH", price: "0.1773", percentChange24h: "-0.0599" },
{ pair: "BTCUSD", price: "6198.36", percentChange24h: "-0.0424" },
{ pair: "LTCUSD", price: "38.4", percentChange24h: "-0.0504" },
{ pair: "ZECBTC", price: "0.00526", percentChange24h: "0.0648" },
{ pair: "BCHUSD", price: "217.05", percentChange24h: "-0.0415" },
{ pair: "ZECUSD", price: "33.66", percentChange24h: "0.0457" },
{ pair: "ETHBTC", price: "0.02138", percentChange24h: "-0.0028" },
{ pair: "BCHBTC", price: "0.03509", percentChange24h: "-0.0293" },
{ pair: "ETHUSD", price: "132.63", percentChange24h: "-0.0434" },
{ pair: "ZECBCH", price: "0", percentChange24h: "0.0000" },
{ pair: "ZECETH", price: "0.249", percentChange24h: "0.0600" },
{ pair: "LTCBTC", price: "0.00624", percentChange24h: "-0.0016" },
{ pair: "BCHETH", price: "1.614", percentChange24h: "0.0000" },
{ pair: "ZECLTC", price: "0.861", percentChange24h: "0.0630" }
];
nock(ApiUri)
.get(uri)
.reply(200, response);

const data = await client.getPriceFeed();
assert.deepStrictEqual(data, response);
});
});

0 comments on commit 061a36c

Please sign in to comment.