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

tardis-dev

Package Overview
Dependencies
Maintainers
1
Versions
272
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tardis-dev - npm Package Compare versions

Comparing version 10.1.7 to 10.1.8

3

dist/consts.js

@@ -112,3 +112,4 @@ "use strict";

'option/summary',
'option/instruments'
'option/instruments',
'index/ticker'
];

@@ -115,0 +116,0 @@ const COINFLEX_CHANNELS = ['OrderOpened', 'OrderModified', 'OrdersMatched', 'OrderClosed', 'TickerChanged'];

@@ -1,2 +0,2 @@

import { BookChange, DerivativeTicker, Trade } from '../types';
import { BookChange, DerivativeTicker, Trade, OptionSummary } from '../types';
import { Mapper } from './mapper';

@@ -14,2 +14,10 @@ export declare const deribitTradesMapper: Mapper<'deribit', Trade>;

}
export declare class DeribitOptionSummaryMapper implements Mapper<'deribit', OptionSummary> {
getFilters(symbols?: string[]): {
readonly channel: "ticker";
readonly symbols: string[] | undefined;
}[];
canHandle(message: any): boolean;
map(message: DeribitOptionTickerMessage, localTimestamp: Date): Generator<OptionSummary, void, unknown>;
}
declare type DeribitMessage = {

@@ -25,3 +33,3 @@ params: {

open_interest: number;
last_price: number;
last_price: number | null;
mark_price: number;

@@ -35,3 +43,30 @@ instrument_name: string;

};
declare type DeribitOptionTickerMessage = DeribitMessage & {
params: {
data: {
underlying_price: number;
underlying_index: string;
timestamp: number;
open_interest: number;
mark_price: number;
mark_iv: number;
last_price: number | null;
instrument_name: string;
greeks: {
vega: number;
theta: number;
rho: number;
gamma: number;
delta: number;
};
bid_iv: number | undefined;
best_bid_price: number | undefined;
best_bid_amount: number | undefined;
best_ask_price: number | undefined;
best_ask_amount: number | undefined;
ask_iv: number | undefined;
};
};
};
export {};
//# sourceMappingURL=deribit.d.ts.map

@@ -83,3 +83,4 @@ "use strict";

}
return channel.startsWith('ticker');
// exclude options tickers
return channel.startsWith('ticker') && message.params.data.greeks === undefined;
}

@@ -109,2 +110,58 @@ getFilters(symbols) {

exports.DeribitDerivativeTickerMapper = DeribitDerivativeTickerMapper;
class DeribitOptionSummaryMapper {
getFilters(symbols) {
return [
{
channel: 'ticker',
symbols
}
];
}
canHandle(message) {
const channel = message.params && message.params.channel;
if (channel === undefined) {
return false;
}
// options ticker has greeks
return channel.startsWith('ticker') && message.params.data.greeks !== undefined;
}
*map(message, localTimestamp) {
const optionInfo = message.params.data;
//e.g., BTC-8JUN20-8750-P
const symbolParts = optionInfo.instrument_name.split('-');
const isPut = symbolParts[3] === 'P';
const strikePrice = Number(symbolParts[2]);
const expirationDate = new Date(symbolParts[1] + 'Z');
expirationDate.setUTCHours(8);
const optionSummary = {
type: 'option_summary',
symbol: optionInfo.instrument_name,
exchange: 'deribit',
optionType: isPut ? 'put' : 'call',
strikePrice,
expirationDate,
bestBidPrice: optionInfo.best_bid_price === 0 ? undefined : optionInfo.best_bid_price,
bestBidAmount: optionInfo.best_bid_amount === 0 ? undefined : optionInfo.best_bid_amount,
bestBidIV: optionInfo.bid_iv === 0 ? undefined : optionInfo.bid_iv,
bestAskPrice: optionInfo.best_ask_price === 0 ? undefined : optionInfo.best_ask_price,
bestAskAmount: optionInfo.best_ask_amount === 0 ? undefined : optionInfo.best_ask_amount,
bestAskIV: optionInfo.ask_iv === 0 ? undefined : optionInfo.ask_iv,
lastPrice: optionInfo.last_price !== null ? optionInfo.last_price : undefined,
openInterest: optionInfo.open_interest,
markPrice: optionInfo.mark_price,
markIV: optionInfo.mark_iv,
delta: optionInfo.greeks.delta,
gamma: optionInfo.greeks.gamma,
vega: optionInfo.greeks.vega,
theta: optionInfo.greeks.theta,
rho: optionInfo.greeks.rho,
underlyingPrice: optionInfo.underlying_price,
underlyingIndex: optionInfo.underlying_index,
timestamp: new Date(optionInfo.timestamp),
localTimestamp: localTimestamp
};
yield optionSummary;
}
}
exports.DeribitOptionSummaryMapper = DeribitOptionSummaryMapper;
//# sourceMappingURL=deribit.js.map

@@ -1,2 +0,2 @@

import { BookChange, DerivativeTicker, Trade } from '../types';
import { BookChange, DerivativeTicker, Trade, OptionSummary } from '../types';
import { Mapper } from './mapper';

@@ -7,2 +7,3 @@ export * from './mapper';

export declare const normalizeDerivativeTickers: <T extends "bitmex" | "deribit" | "binance-futures" | "ftx" | "okex-futures" | "okex-swap" | "bitfinex-derivatives" | "cryptofacilities" | "bybit" | "phemex">(exchange: T, _localTimestamp: Date) => Mapper<T, DerivativeTicker>;
export declare const normalizeOptionsSummary: <T extends "deribit" | "okex-options">(exchange: T, _localTimestamp: Date) => Mapper<T, OptionSummary>;
//# sourceMappingURL=index.d.ts.map

@@ -101,2 +101,6 @@ "use strict";

};
const optionsSummaryMappers = {
deribit: () => new deribit_1.DeribitOptionSummaryMapper(),
'okex-options': () => new okex_1.OkexOptionSummaryMapper()
};
exports.normalizeTrades = (exchange, _localTimestamp) => {

@@ -123,2 +127,9 @@ const createTradesMapper = tradesMappers[exchange];

};
exports.normalizeOptionsSummary = (exchange, _localTimestamp) => {
const createOptionSummaryMapper = optionsSummaryMappers[exchange];
if (createOptionSummaryMapper === undefined) {
throw new Error(`normalizeOptionsSummary: ${exchange} not supported`);
}
return createOptionSummaryMapper();
};
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import { BookChange, DerivativeTicker, Exchange, FilterForExchange, Trade } from '../types';
import { BookChange, DerivativeTicker, Exchange, Trade, OptionSummary } from '../types';
import { Mapper } from './mapper';

@@ -40,4 +40,19 @@ export declare class OkexTradesMapper implements Mapper<OKEX_EXCHANGES, Trade> {

}
export declare class OkexOptionSummaryMapper implements Mapper<'okex-options', OptionSummary> {
private readonly _indexPrices;
private readonly expiration_regex;
canHandle(message: OkexDataMessage): boolean;
getFilters(symbols?: string[]): ({
readonly channel: "option/summary";
readonly symbols: string[] | undefined;
readonly indexes?: undefined;
} | {
readonly channel: "index/ticker";
readonly indexes: string[] | undefined;
readonly symbols?: undefined;
})[];
map(message: OkexOptionSummaryData | OkexIndexData, localTimestamp: Date): IterableIterator<OptionSummary> | undefined;
}
declare type OkexDataMessage = {
table: FilterForExchange['okex']['channel'];
table: string;
};

@@ -93,3 +108,34 @@ declare type OKexTradesDataMessage = {

declare type OKEX_MARKETS = 'spot' | 'swap' | 'futures' | 'option';
declare type OkexIndexData = {
table: 'index/ticker';
data: [{
last: number;
instrument_id: string;
}];
};
declare type OkexOptionSummaryData = {
table: 'option/summary';
data: [{
instrument_id: string;
underlying: string;
best_ask: string;
best_bid: string;
best_ask_size: string;
best_bid_size: string;
change_rate: string;
delta: string;
gamma: string;
bid_vol: string;
ask_vol: string;
mark_vol: string;
last: string;
leverage: string;
mark_price: string;
theta: string;
vega: string;
open_interest: string;
timestamp: string;
}];
};
export {};
//# sourceMappingURL=okex.d.ts.map

@@ -151,2 +151,77 @@ "use strict";

exports.OkexDerivativeTickerMapper = OkexDerivativeTickerMapper;
class OkexOptionSummaryMapper {
constructor() {
this._indexPrices = new Map();
this.expiration_regex = /(\d{2})(\d{2})(\d{2})/;
}
canHandle(message) {
return message.table === 'index/ticker' || message.table === 'option/summary';
}
getFilters(symbols) {
const indexes = symbols !== undefined
? symbols.map((s) => {
const symbolParts = s.split('-');
return `${symbolParts[0]}-${symbolParts[1]}`;
})
: undefined;
return [
{
channel: `option/summary`,
symbols
},
{
channel: `index/ticker`,
indexes
}
];
}
*map(message, localTimestamp) {
if (message.table === 'index/ticker') {
for (const index of message.data) {
const lastIndexPrice = Number(index.last);
if (lastIndexPrice > 0) {
this._indexPrices.set(index.instrument_id, lastIndexPrice);
}
}
return;
}
for (const summary of message.data) {
const symbolParts = summary.instrument_id.split('-');
const isPut = symbolParts[4] === 'P';
const strikePrice = Number(symbolParts[3]);
var dateArray = this.expiration_regex.exec(symbolParts[2]);
const expirationDate = new Date(Date.UTC(+('20' + dateArray[1]), +dateArray[2] - 1, +dateArray[3], 8, 0, 0, 0));
const lastUnderlyingPrice = this._indexPrices.get(summary.underlying);
const optionSummary = {
type: 'option_summary',
symbol: summary.instrument_id,
exchange: 'okex-options',
optionType: isPut ? 'put' : 'call',
strikePrice,
expirationDate,
bestBidPrice: Number(summary.best_bid) === 0 ? undefined : Number(summary.best_bid),
bestBidAmount: Number(summary.best_bid_size) === 0 ? undefined : Number(summary.best_bid_size),
bestBidIV: Number(summary.bid_vol) === 0 ? undefined : Number(summary.bid_vol),
bestAskPrice: Number(summary.best_ask) === 0 ? undefined : Number(summary.best_ask),
bestAskAmount: Number(summary.best_ask_size) === 0 ? undefined : Number(summary.best_ask_size),
bestAskIV: Number(summary.ask_vol) === 0 ? undefined : Number(summary.ask_vol),
lastPrice: Number(summary.last) === 0 ? undefined : Number(summary.last),
openInterest: Number(summary.open_interest),
markPrice: Number(summary.mark_price),
markIV: Number(summary.mark_vol),
delta: Number(summary.delta),
gamma: Number(summary.gamma),
vega: Number(summary.vega),
theta: Number(summary.theta),
rho: undefined,
underlyingPrice: lastUnderlyingPrice,
underlyingIndex: summary.underlying,
timestamp: new Date(summary.timestamp),
localTimestamp: localTimestamp
};
yield optionSummary;
}
}
}
exports.OkexOptionSummaryMapper = OkexOptionSummaryMapper;
//# sourceMappingURL=okex.js.map

@@ -60,2 +60,25 @@ import { EXCHANGES, EXCHANGE_CHANNELS_INFO } from './consts';

};
export declare type OptionSummary = NormalizedData & {
type: 'option_summary';
optionType: 'put' | 'call';
strikePrice: number;
expirationDate: Date;
bestBidPrice: number | undefined;
bestBidAmount: number | undefined;
bestBidIV: number | undefined;
bestAskPrice: number | undefined;
bestAskAmount: number | undefined;
bestAskIV: number | undefined;
lastPrice: number | undefined;
openInterest: number;
markPrice: number;
markIV: number;
delta: number;
gamma: number;
vega: number;
theta: number;
rho: number | undefined;
underlyingPrice: number | undefined;
underlyingIndex: string;
};
export declare type Disconnect = {

@@ -62,0 +85,0 @@ readonly type: 'disconnect';

{
"name": "tardis-dev",
"version": "10.1.7",
"version": "10.1.8",
"engines": {

@@ -5,0 +5,0 @@ "node": ">=12"

@@ -121,3 +121,4 @@ export const EXCHANGES = [

'option/summary',
'option/instruments'
'option/instruments',
'index/ticker'
]

@@ -124,0 +125,0 @@

@@ -1,2 +0,2 @@

import { BookChange, DerivativeTicker, Trade } from '../types'
import { BookChange, DerivativeTicker, Trade, OptionSummary } from '../types'
import { Mapper, PendingTickerInfoHelper } from './mapper'

@@ -95,3 +95,4 @@

return channel.startsWith('ticker')
// exclude options tickers
return channel.startsWith('ticker') && message.params.data.greeks === undefined
}

@@ -125,2 +126,73 @@

export class DeribitOptionSummaryMapper implements Mapper<'deribit', OptionSummary> {
getFilters(symbols?: string[]) {
return [
{
channel: 'ticker',
symbols
} as const
]
}
canHandle(message: any) {
const channel = message.params && message.params.channel
if (channel === undefined) {
return false
}
// options ticker has greeks
return channel.startsWith('ticker') && message.params.data.greeks !== undefined
}
*map(message: DeribitOptionTickerMessage, localTimestamp: Date) {
const optionInfo = message.params.data
//e.g., BTC-8JUN20-8750-P
const symbolParts = optionInfo.instrument_name.split('-')
const isPut = symbolParts[3] === 'P'
const strikePrice = Number(symbolParts[2])
const expirationDate = new Date(symbolParts[1] + 'Z')
expirationDate.setUTCHours(8)
const optionSummary: OptionSummary = {
type: 'option_summary',
symbol: optionInfo.instrument_name,
exchange: 'deribit',
optionType: isPut ? 'put' : 'call',
strikePrice,
expirationDate,
bestBidPrice: optionInfo.best_bid_price === 0 ? undefined : optionInfo.best_bid_price,
bestBidAmount: optionInfo.best_bid_amount === 0 ? undefined : optionInfo.best_bid_amount,
bestBidIV: optionInfo.bid_iv === 0 ? undefined : optionInfo.bid_iv,
bestAskPrice: optionInfo.best_ask_price === 0 ? undefined : optionInfo.best_ask_price,
bestAskAmount: optionInfo.best_ask_amount === 0 ? undefined : optionInfo.best_ask_amount,
bestAskIV: optionInfo.ask_iv === 0 ? undefined : optionInfo.ask_iv,
lastPrice: optionInfo.last_price !== null ? optionInfo.last_price : undefined,
openInterest: optionInfo.open_interest,
markPrice: optionInfo.mark_price,
markIV: optionInfo.mark_iv,
delta: optionInfo.greeks.delta,
gamma: optionInfo.greeks.gamma,
vega: optionInfo.greeks.vega,
theta: optionInfo.greeks.theta,
rho: optionInfo.greeks.rho,
underlyingPrice: optionInfo.underlying_price,
underlyingIndex: optionInfo.underlying_index,
timestamp: new Date(optionInfo.timestamp),
localTimestamp: localTimestamp
}
yield optionSummary
}
}
type DeribitMessage = {

@@ -165,3 +237,3 @@ params: {

open_interest: number
last_price: number
last_price: number | null
mark_price: number

@@ -175,1 +247,25 @@ instrument_name: string

}
type DeribitOptionTickerMessage = DeribitMessage & {
params: {
data: {
underlying_price: number
underlying_index: string
timestamp: number
open_interest: number
mark_price: number
mark_iv: number
last_price: number | null
instrument_name: string
greeks: { vega: number; theta: number; rho: number; gamma: number; delta: number }
bid_iv: number | undefined
best_bid_price: number | undefined
best_bid_amount: number | undefined
best_ask_price: number | undefined
best_ask_amount: number | undefined
ask_iv: number | undefined
}
}
}
import { ONE_SEC_IN_MS } from '../handy'
import { BookChange, DerivativeTicker, Trade } from '../types'
import { BookChange, DerivativeTicker, Trade, OptionSummary } from '../types'
import {

@@ -17,3 +17,3 @@ BinanceBookChangeMapper,

import { cryptofacilitiesBookChangeMapper, CryptofacilitiesDerivativeTickerMapper, cryptofacilitiesTradesMapper } from './cryptofacilities'
import { deribitBookChangeMapper, DeribitDerivativeTickerMapper, deribitTradesMapper } from './deribit'
import { deribitBookChangeMapper, DeribitDerivativeTickerMapper, deribitTradesMapper, DeribitOptionSummaryMapper } from './deribit'
import { ftxBookChangeMapper, ftxTradesMapper, FTXDerivativeTickerMapper } from './ftx'

@@ -25,3 +25,3 @@ import { geminiBookChangeMapper, geminiTradesMapper } from './gemini'

import { Mapper } from './mapper'
import { OkexBookChangeMapper, OkexDerivativeTickerMapper, OkexTradesMapper } from './okex'
import { OkexBookChangeMapper, OkexDerivativeTickerMapper, OkexTradesMapper, OkexOptionSummaryMapper } from './okex'
import { phemexTradesMapper, phemexBookChangeMapper, PhemexDerivativeTickerMapper } from './phemex'

@@ -117,2 +117,7 @@

const optionsSummaryMappers = {
deribit: () => new DeribitOptionSummaryMapper(),
'okex-options': () => new OkexOptionSummaryMapper()
}
export const normalizeTrades = <T extends keyof typeof tradesMappers>(exchange: T, _localTimestamp: Date): Mapper<T, Trade> => {

@@ -153,1 +158,14 @@ const createTradesMapper = tradesMappers[exchange]

}
export const normalizeOptionsSummary = <T extends keyof typeof optionsSummaryMappers>(
exchange: T,
_localTimestamp: Date
): Mapper<T, OptionSummary> => {
const createOptionSummaryMapper = optionsSummaryMappers[exchange]
if (createOptionSummaryMapper === undefined) {
throw new Error(`normalizeOptionsSummary: ${exchange} not supported`)
}
return createOptionSummaryMapper() as any
}

@@ -1,2 +0,2 @@

import { BookChange, DerivativeTicker, Exchange, FilterForExchange, Trade } from '../types'
import { BookChange, DerivativeTicker, Exchange, FilterForExchange, Trade, OptionSummary } from '../types'
import { Mapper, PendingTickerInfoHelper } from './mapper'

@@ -171,4 +171,94 @@

export class OkexOptionSummaryMapper implements Mapper<'okex-options', OptionSummary> {
private readonly _indexPrices = new Map<string, number>()
private readonly expiration_regex = /(\d{2})(\d{2})(\d{2})/
canHandle(message: OkexDataMessage) {
return message.table === 'index/ticker' || message.table === 'option/summary'
}
getFilters(symbols?: string[]) {
const indexes =
symbols !== undefined
? symbols.map((s) => {
const symbolParts = s.split('-')
return `${symbolParts[0]}-${symbolParts[1]}`
})
: undefined
return [
{
channel: `option/summary`,
symbols
} as const,
{
channel: `index/ticker`,
indexes
} as const
]
}
*map(message: OkexOptionSummaryData | OkexIndexData, localTimestamp: Date): IterableIterator<OptionSummary> | undefined {
if (message.table === 'index/ticker') {
for (const index of message.data) {
const lastIndexPrice = Number(index.last)
if (lastIndexPrice > 0) {
this._indexPrices.set(index.instrument_id, lastIndexPrice)
}
}
return
}
for (const summary of message.data) {
const symbolParts = summary.instrument_id.split('-')
const isPut = symbolParts[4] === 'P'
const strikePrice = Number(symbolParts[3])
var dateArray = this.expiration_regex.exec(symbolParts[2])!
const expirationDate = new Date(Date.UTC(+('20' + dateArray[1]), +dateArray[2] - 1, +dateArray[3], 8, 0, 0, 0))
const lastUnderlyingPrice = this._indexPrices.get(summary.underlying)
const optionSummary: OptionSummary = {
type: 'option_summary',
symbol: summary.instrument_id,
exchange: 'okex-options',
optionType: isPut ? 'put' : 'call',
strikePrice,
expirationDate,
bestBidPrice: Number(summary.best_bid) === 0 ? undefined : Number(summary.best_bid),
bestBidAmount: Number(summary.best_bid_size) === 0 ? undefined : Number(summary.best_bid_size),
bestBidIV: Number(summary.bid_vol) === 0 ? undefined : Number(summary.bid_vol),
bestAskPrice: Number(summary.best_ask) === 0 ? undefined : Number(summary.best_ask),
bestAskAmount: Number(summary.best_ask_size) === 0 ? undefined : Number(summary.best_ask_size),
bestAskIV: Number(summary.ask_vol) === 0 ? undefined : Number(summary.ask_vol),
lastPrice: Number(summary.last) === 0 ? undefined : Number(summary.last),
openInterest: Number(summary.open_interest),
markPrice: Number(summary.mark_price),
markIV: Number(summary.mark_vol),
delta: Number(summary.delta),
gamma: Number(summary.gamma),
vega: Number(summary.vega),
theta: Number(summary.theta),
rho: undefined,
underlyingPrice: lastUnderlyingPrice,
underlyingIndex: summary.underlying,
timestamp: new Date(summary.timestamp),
localTimestamp: localTimestamp
}
yield optionSummary
}
}
}
type OkexDataMessage = {
table: FilterForExchange['okex']['channel']
table: string
}

@@ -232,1 +322,38 @@

type OKEX_MARKETS = 'spot' | 'swap' | 'futures' | 'option'
type OkexIndexData = {
table: 'index/ticker'
data: [
{
last: number
instrument_id: string
}
]
}
type OkexOptionSummaryData = {
table: 'option/summary'
data: [
{
instrument_id: string
underlying: string
best_ask: string
best_bid: string
best_ask_size: string
best_bid_size: string
change_rate: string
delta: string
gamma: string
bid_vol: string
ask_vol: string
mark_vol: string
last: string
leverage: string
mark_price: string
theta: string
vega: string
open_interest: string
timestamp: string
}
]
}

@@ -68,2 +68,33 @@ import { EXCHANGES, EXCHANGE_CHANNELS_INFO } from './consts'

export type OptionSummary = NormalizedData & {
type: 'option_summary'
optionType: 'put' | 'call'
strikePrice: number
expirationDate: Date
bestBidPrice: number | undefined
bestBidAmount: number | undefined
bestBidIV: number | undefined
bestAskPrice: number | undefined
bestAskAmount: number | undefined
bestAskIV: number | undefined
lastPrice: number | undefined
openInterest: number
markPrice: number
markIV: number
delta: number
gamma: number
vega: number
theta: number
rho: number | undefined
underlyingPrice: number | undefined
underlyingIndex: string
}
export type Disconnect = {

@@ -70,0 +101,0 @@ readonly type: 'disconnect'

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

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

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