Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tardis-machine

Package Overview
Dependencies
Maintainers
1
Versions
145
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tardis-machine - npm Package Compare versions

Comparing version 1.3.4 to 1.3.5

87

dist/mappers.js

@@ -31,14 +31,21 @@ "use strict";

const topLevelSymbols = message.product_ids;
return message.channels.map((channel) => {
if (typeof channel == 'string') {
return {
const finalChannels = [];
const channelMappings = {
full: ['received', 'open', 'done', 'match', 'change'],
level2: ['snapshot', 'l2update'],
match: ['match', 'last_match'],
ticker: ['ticker']
};
message.channels.forEach((channel) => {
const channelName = typeof channel == 'string' ? channel : channel.name;
const symbols = typeof channel == 'string' ? topLevelSymbols : channel.product_ids;
const mappedChannels = channelMappings[channelName];
mappedChannels.forEach((channel) => {
finalChannels.push({
channel,
symbols: topLevelSymbols
};
}
return {
channel: channel.name,
symbols: channel.product_ids
};
symbols
});
});
});
return finalChannels;
}

@@ -109,2 +116,3 @@ };

};
// https://docs.ftx.com/#request-format
const ftxMapper = {

@@ -123,2 +131,56 @@ canHandle: (message) => {

};
// https://www.kraken.com/features/websocket-api#message-subscribe
const krakenMapper = {
canHandle: (message) => {
return message.event === 'subscribe';
},
map: (message) => {
return [
{
channel: message.subscription.name,
symbols: message.pair
}
];
}
};
// https://lightning.bitflyer.com/docs?lang=en#json-rpc-2.0-over-websocket
const bitflyerMapper = {
canHandle: (message) => {
return message.method === 'subscribe';
},
map: (message) => {
const availableChannels = ['lightning_board_snapshot', 'lightning_board', 'lightning_ticker', 'lightning_executions'];
const inputChannel = message.params.channel;
const channel = availableChannels.find(c => inputChannel.startsWith(c));
const symbol = inputChannel.slice(channel.length + 1);
return [
{
channel,
symbols: [symbol]
}
];
}
};
// https://docs.gemini.com/websocket-api/#market-data-version-2
const geminiMapper = {
canHandle: (message) => {
return message.type === 'subscribe';
},
map: (message) => {
const finalChannels = [];
const channelMappings = {
l2: ['trade', 'l2_updates', 'auction_open', 'auction_indicative', 'auction_result']
};
message.subscriptions.forEach((sub) => {
const matchingChannels = channelMappings[sub.name];
matchingChannels.forEach((channel) => {
finalChannels.push({
channel,
symbols: sub.symbols
});
});
});
return finalChannels;
}
};
exports.subscriptionsMappers = {

@@ -131,4 +193,7 @@ bitmex: bitmexMapper,

okex: okexMapper,
ftx: ftxMapper
ftx: ftxMapper,
kraken: krakenMapper,
bitflyer: bitflyerMapper,
gemini: geminiMapper
};
//# sourceMappingURL=mappers.js.map

@@ -222,2 +222,3 @@ "use strict";

catch (e) {
console.error('_convertSubscribeRequestToFilter Error', e);
debug('Ignored websocket message %s, error %o', message, e);

@@ -224,0 +225,0 @@ }

4

package.json
{
"name": "tardis-machine",
"version": "1.3.4",
"version": "1.3.5",
"engines": {

@@ -48,3 +48,3 @@ "node": ">=12"

"is-docker": "^2.0.0",
"tardis-client": "^1.2.1",
"tardis-client": "^1.2.4",
"yargs": "^13.2.4",

@@ -51,0 +51,0 @@ "ws": "^7.0.0"

@@ -24,8 +24,8 @@ # tardis-machine

| name | type | default value | description |
| -------------------- | ------------------------------------------------------------------------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `exchange` | `string` | - | requested exchange name. Check out [allowed echanges](https://github.com/tardis-dev/node-client/blob/master/src/consts.ts) |
| `from` | `string` | - | replay period start date (UTC) - eg: `2019-04-05` or `2019-05-05T00:00:00.000Z` |
| `to` | `string` | - | replay period end date (UTC) - eg: `2019-04-05` or `2019-05-05T00:00:00.000Z` |
| `filters` (optional) | `Url encoded JSON string with {channel:string, symbols?: string[]}[] structure` | undefined | optional filters of requested data feed. Use [/exchanges/:/exchange](https://docs.tardis.dev/api#exchanges-exchange) API call to get allowed channel names and symbols for requested exchange |
| name | type | default value | description |
| -------------------- | ------------------------------------------------------------------------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `exchange` | `string` | - | requested exchange name. Check out [allowed echanges](https://github.com/tardis-dev/node-client/blob/master/src/consts.ts) |
| `from` | `string` | - | replay period start date (UTC) - eg: `2019-04-05` or `2019-05-05T00:00:00.000Z` |
| `to` | `string` | - | replay period end date (UTC) - eg: `2019-04-05` or `2019-05-05T00:00:00.000Z` |
| `filters` (optional) | `Url encoded JSON string with {channel:string, symbols?: string[]}[] structure` | undefined | optional filters of requested data feed. Use [/exchanges/:/exchange](https://docs.tardis.dev/api#exchanges-exchange) API call to get allowed channel names and symbols for requested exchange |

@@ -52,3 +52,3 @@ #### Example response snippet:

Accessible via **`/ws-replay/?exchange=<EXCHANGE>&from=<FROM_DATE>&to=<TO_DATE>`**
Accessible via **`/ws-replay?exchange=<EXCHANGE>&from=<FROM_DATE>&to=<TO_DATE>`**

@@ -115,7 +115,7 @@ Exchanges & various 3rd party data providers WebSocket APIs allows subscribing only to real-time data feeds and there is no way to subscribe to and **"replay"** market from any point in the past. By using `tardis-machine` that is now possible.

| name | type | default value | description |
| ---------- | -------- | ------------- | ----------------------------------------------------------------------------------------------------------- |
| `exchange` | `string` | - | requested exchange name. Currently supported: `bitmex, coinbase, deribit, cryptofacilities, bitstamp, okex` |
| `from` | `string` | - | replay period start date (UTC) - eg: `2019-04-05` or `2019-05-05T00:00:00.000Z` |
| `to` | `string` | - | replay period start date (UTC) - eg: `2019-04-05` or `2019-05-05T00:00:00.000Z` |
| name | type | default value | description |
| ---------- | -------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `exchange` | `string` | - | requested exchange name. Currently supported: `bitmex, coinbase, deribit, cryptofacilities, bitstamp, okex, ftx, kraken, bitflyer, gemini` |
| `from` | `string` | - | replay period start date (UTC) - eg: `2019-04-05` or `2019-05-05T00:00:00.000Z` |
| `to` | `string` | - | replay period start date (UTC) - eg: `2019-04-05` or `2019-05-05T00:00:00.000Z` |

@@ -193,2 +193,3 @@ ## Installation

#### Where can I find more details about tardis.dev API?
Check out [API docs](https://docs.tardis.dev/api).

@@ -195,0 +196,0 @@

@@ -35,15 +35,25 @@ import { Filter, Exchange } from 'tardis-client'

const topLevelSymbols = message.product_ids
const finalChannels: Filter<any>[] = []
return message.channels.map((channel: any) => {
if (typeof channel == 'string') {
return {
const channelMappings = {
full: ['received', 'open', 'done', 'match', 'change'],
level2: ['snapshot', 'l2update'],
match: ['match', 'last_match'],
ticker: ['ticker']
}
message.channels.forEach((channel: any) => {
const channelName = typeof channel == 'string' ? channel : channel.name
const symbols = typeof channel == 'string' ? topLevelSymbols : channel.product_ids
const mappedChannels = (channelMappings as any)[channelName]
mappedChannels.forEach((channel: string) => {
finalChannels.push({
channel,
symbols: topLevelSymbols
}
}
return {
channel: channel.name,
symbols: channel.product_ids
}
symbols
})
})
})
return finalChannels
}

@@ -123,3 +133,3 @@ }

}
// https://docs.ftx.com/#request-format
const ftxMapper: SubscriptionMapper = {

@@ -140,2 +150,66 @@ canHandle: (message: any) => {

// https://www.kraken.com/features/websocket-api#message-subscribe
const krakenMapper: SubscriptionMapper = {
canHandle: (message: any) => {
return message.event === 'subscribe'
},
map: (message: any) => {
return [
{
channel: message.subscription.name,
symbols: message.pair
}
]
}
}
// https://lightning.bitflyer.com/docs?lang=en#json-rpc-2.0-over-websocket
const bitflyerMapper: SubscriptionMapper = {
canHandle: (message: any) => {
return message.method === 'subscribe'
},
map: (message: any) => {
const availableChannels = ['lightning_board_snapshot', 'lightning_board', 'lightning_ticker', 'lightning_executions']
const inputChannel = message.params.channel as string
const channel = availableChannels.find(c => inputChannel.startsWith(c))!
const symbol = inputChannel.slice(channel.length + 1)
return [
{
channel,
symbols: [symbol]
}
]
}
}
// https://docs.gemini.com/websocket-api/#market-data-version-2
const geminiMapper: SubscriptionMapper = {
canHandle: (message: any) => {
return message.type === 'subscribe'
},
map: (message: any) => {
const finalChannels: Filter<any>[] = []
const channelMappings = {
l2: ['trade', 'l2_updates', 'auction_open', 'auction_indicative', 'auction_result']
}
message.subscriptions.forEach((sub: any) => {
const matchingChannels = (channelMappings as any)[sub.name]
matchingChannels.forEach((channel: string) => {
finalChannels.push({
channel,
symbols: sub.symbols
})
})
})
return finalChannels
}
}
export const subscriptionsMappers: { [key in Exchange]?: SubscriptionMapper } = {

@@ -148,3 +222,6 @@ bitmex: bitmexMapper,

okex: okexMapper,
ftx: ftxMapper
ftx: ftxMapper,
kraken: krakenMapper,
bitflyer: bitflyerMapper,
gemini: geminiMapper
}

@@ -151,0 +228,0 @@

@@ -265,2 +265,3 @@ import { ParsedUrlQuery } from 'querystring'

} catch (e) {
console.error('_convertSubscribeRequestToFilter Error', e)
debug('Ignored websocket message %s, error %o', message, e)

@@ -267,0 +268,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc