Skip to content

Commit 81d0361

Browse files
committed
workaround another dumb bittrex api issue
1 parent 32cde73 commit 81d0361

File tree

5 files changed

+45
-6
lines changed

5 files changed

+45
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "bittrex-typescript",
3-
"version": "2.1.1",
3+
"version": "2.1.2",
44
"description": "Bittrex client using typescript",
55
"main": "src/index.js",
66
"types": "src/index.d.ts",

src/Bittrex.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ export declare class BittrexClient implements Bittrex {
4343
*/
4444
marketSummary(market: string): Promise<MarketSummaryData>;
4545
marketSummaries(): Promise<MarketSummaryData[]>;
46+
/**
47+
* The Bittrex API is stupid. The API returns the MarketName inverted. USDT-BTC is really BTC-USDT.
48+
* So, keep the documented behavior and set the DisplayMarketName since the API doesn't return
49+
* that documented value anyway.
50+
*/
51+
private displayMarketName;
52+
private displayMarketNames;
4653
orderBook(market: string, type: 'buy' | 'sell' | 'both'): Promise<OrderBookData | OrderBookItem[]>;
4754
buyLimit(market: string, quantity: number | string | BigNumber, rate: number | string | BigNumber): Promise<UuidData>;
4855
sellLimit(market: string, quantity: number | string | BigNumber, rate: number | string | BigNumber): Promise<UuidData>;

src/Bittrex.js

Lines changed: 17 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Bittrex.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Bittrex.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,30 @@ export class BittrexClient implements Bittrex {
8989
*/
9090
public async marketSummary(market: string): Promise<MarketSummaryData> {
9191
const promise = this.transport.request(MarketSummaryData, '/public/getmarketsummary', {market: market}) as Promise<MarketSummaryData[]>;
92-
return promise.then((result:MarketSummaryData[]) => { return result[0]; });
92+
return promise.then((result:MarketSummaryData[]) => { return this.displayMarketName(result[0]); });
9393
}
9494

9595
public async marketSummaries(): Promise<MarketSummaryData[]> {
96-
return this.transport.request(MarketSummaryData, '/public/getmarketsummaries') as Promise<MarketSummaryData[]>;
96+
const promise = this.transport.request(MarketSummaryData, '/public/getmarketsummaries') as Promise<MarketSummaryData[]>;
97+
return promise.then((results:MarketSummaryData[]) => { return this.displayMarketNames(results); });
9798
}
9899

100+
/**
101+
* The Bittrex API is stupid. The API returns the MarketName inverted. USDT-BTC is really BTC-USDT.
102+
* So, keep the documented behavior and set the DisplayMarketName since the API doesn't return
103+
* that documented value anyway.
104+
*/
105+
private displayMarketName = (marketSummary: MarketSummaryData): MarketSummaryData => {
106+
marketSummary.DisplayMarketName = marketSummary.MarketName.split('-').reverse().join('-');
107+
return marketSummary;
108+
};
109+
110+
private displayMarketNames = (marketSummaries: MarketSummaryData[]): MarketSummaryData[] => {
111+
return marketSummaries.map((marketSummary) => {
112+
return this.displayMarketName(marketSummary);
113+
});
114+
};
115+
99116
public async orderBook(market: string, type: 'buy' | 'sell' | 'both'): Promise<OrderBookData | OrderBookItem[]> {
100117
const pathname = '/public/getorderbook';
101118
const data = {market: market, type: type};

0 commit comments

Comments
 (0)