npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ttech-pub/invest-sdk-node

v1.59.0

Published

T-Tech Invest SDK for Node.JS applications

Readme

sdk-node

Эта библиотека создана с помощью Nx.

Сборка

Чтобы собрать библиотеку, выполните nx build sdk-node.

Конвертация цены фьючерса

FuturesPriceConverter поддерживает как отдельные коэффициенты из Future, так и объект FutureResponse. Формулы описаны в справке Т-Банка о стоимости шага цены фьючерса. Ниже приведены примеры с фиксированными значениями. Замените их значениями из ответа API и перед ручной передачей коэффициентов проверяйте, что они заданы.

import { FuturesPriceConverter } from '@ttech-pub/invest-sdk-node';
import { Decimal } from '@ttech-pub/invest-core';
import type { Future, FutureResponse, Quotation } from '@ttech-pub/grpc-node-client';

const quotation = (units: number, nano = 0): Quotation => ({ units, nano });

const futureFixture = (minPriceIncrement: Quotation, minPriceIncrementAmount: Quotation): Future =>
  ({ minPriceIncrement, minPriceIncrementAmount } as Future);

Перевод валюты в пункты с отдельными коэффициентами (25 * 0.5 / 2.5 = 5):

const future = futureFixture(quotation(0, 500000000), quotation(2, 500000000));

if (!future.minPriceIncrement || !future.minPriceIncrementAmount) {
  throw new Error('Не заданы коэффициенты фьючерса');
}

FuturesPriceConverter.currencyToPoints(
  new Decimal('25'),
  future.minPriceIncrement,
  future.minPriceIncrementAmount,
).toString(); // '5'

Перевод валюты в пункты с типизированным FutureResponse:

const response: FutureResponse = {
  instrument: futureFixture(quotation(0, 500000000), quotation(2, 500000000)),
};

FuturesPriceConverter.currencyToPoints(new Decimal('25'), response).toString(); // '5'

Перевод пунктов в валюту с отдельными коэффициентами (125 * 12.5 / 10 = 156.25):

const future = futureFixture(quotation(10), quotation(12, 500000000));

if (!future.minPriceIncrement || !future.minPriceIncrementAmount) {
  throw new Error('Не заданы коэффициенты фьючерса');
}

FuturesPriceConverter.pointsToCurrency(
  new Decimal('125'),
  future.minPriceIncrement,
  future.minPriceIncrementAmount,
).toString(); // '156.25'

Перевод пунктов в валюту с типизированным FutureResponse:

const response: FutureResponse = {
  instrument: futureFixture(quotation(10), quotation(12, 500000000)),
};

FuturesPriceConverter.pointsToCurrency(new Decimal('125'), response).toString(); // '156.25'

Конвертация цены облигации

Пункты цены облигации — это процент от номинала. Формулы:

  • цена в пунктах = цена в валюте × 100 / номинал;
  • цена в валюте = цена в пунктах / 100 × номинал.

Описание цен облигаций и фьючерсов приведено в справке Т-Банка о ценах облигаций и фьючерсов. Помощник не выполняет конвертацию валют, если валюта цены и валюта номинала различаются; такой пересчёт выполняется отдельно.

import { BondsPriceConverter } from '@ttech-pub/invest-sdk-node';
import { Decimal } from '@ttech-pub/invest-core';
import type { Bond, BondResponse, MoneyValue } from '@ttech-pub/grpc-node-client';

const nominal: MoneyValue = { currency: 'rub', units: 1000, nano: 0 };
const bond: Bond = { nominal } as Bond;
const response: BondResponse = { instrument: bond };

Перевод пунктов в валюту с ручным MoneyValue (95.5 / 100 × 1000 = 955):

BondsPriceConverter.pointsToCurrency(new Decimal('95.5'), nominal).toString(); // '955'

Перевод пунктов в валюту с типизированным BondResponse:

BondsPriceConverter.pointsToCurrency(new Decimal('95.5'), response).toString(); // '955'

Перевод валюты в пункты с ручным MoneyValue (955 × 100 / 1000 = 95.5):

BondsPriceConverter.currencyToPoints(new Decimal('955'), nominal).toString(); // '95.5'

Перевод валюты в пункты с типизированным BondResponse:

BondsPriceConverter.currencyToPoints(new Decimal('955'), response).toString(); // '95.5'

Порядок тестирования

Запускайте команды по порядку:

npx nx test sdk-node
npx nx build sdk-node
npx nx lint sdk-node

Тест-кейсы

  • Ручной MoneyValue: перевод пунктов в валюту (95.5 → 955) и валюты в пункты (955 → 95.5).
  • Типизированный BondResponse: те же оба направления.
  • Номинал с nano: точный обратный перевод без потери точности.
  • Отсутствуют instrument, nominal или ручной номинал: TypeError.
  • Некорректный номинал: выбрасывается Error при создании Decimal.
  • Нулевой номинал: currencyToPoints выбрасывает DivisionByZeroDecimalError, pointsToCurrency возвращает 0.
  • Ручные Quotation: перевод валюты в пункты (25 → 5) и пунктов в валюту (125 → 156.25).
  • Типизированный FutureResponse: те же оба направления.
  • Коэффициенты с nano: точная конвертация без округления и потери точности.
  • Отсутствуют instrument, minPriceIncrement или minPriceIncrementAmount, а также ручные коэффициенты: TypeError.
  • Некорректные ручные коэффициенты: выбрасывается Error при создании Decimal.
  • Нулевой minPriceIncrementAmount в currencyToPoints и нулевой minPriceIncrement в pointsToCurrency: DivisionByZeroDecimalError.