Skip to content

Commit

Permalink
release/01.000.01
Browse files Browse the repository at this point in the history
  • Loading branch information
mtvkand committed Apr 12, 2022
0 parents commit 1405715
Show file tree
Hide file tree
Showing 38 changed files with 28,397 additions and 0 deletions.
14 changes: 14 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"parser": "@typescript-eslint/parser",
"extends": ["plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
"parserOptions": { "ecmaVersion": 2018, "sourceType": "module" },
"rules": {
"@typescript-eslint/interface-name-prefix": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error"
}
}
37 changes: 37 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.env*

# compiled output
/dist
/node_modules

# Logs
logs
*.log
.npmrc
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# OS
.DS_Store

# Tests
/coverage
/.nyc_output

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json!
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"semi": true,
"trailingComma": "all",
"singleQuote": true,
"printWidth": 120,
"tabWidth": 2,
"arrowParens": "avoid"
}
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# НЕОФИЦИАЛЬНОЕ Tinkoff Invest APIv2 - Typescript NodeJS SDK

## Документация

Доступна по [ссылке](https://tinkoff.github.io/investAPI/)

## Пример

Примеры для каждого метода есть в папке [examples](./src/examples)

```typescript
import { createSdk } from '../sdk';
import { CandleInterval } from '../generated/marketdata';

!(async function example() {
const { marketData } = createSdk('YOUR_TOKEN');

const candles = await marketData.getCandles({
figi: 'BBG0047315Y7',
from: new Date('2022-04-04T11:00:00Z'),
to: new Date('2022-04-04T11:20:59Z'),
interval: CandleInterval.CANDLE_INTERVAL_5_MIN,
});

const lastPrice = await marketData.getLastPrices({
figi: ['BBG0047315Y7'],
});

const orderBook = await marketData.getOrderBook({
figi: 'BBG0047315Y7',
depth: 5,
});

const tradingStatus = await marketData.getTradingStatus({
figi: 'BBG0047315Y7',
});

console.log('Запрос исторических свечей по инструменту: ', candles);
console.log('Запрос последних цен по инструментам: ', lastPrice);
console.log('Получение стакана по инструменту: ', orderBook);
console.log('Запрос статуса торгов по инструментам: ', tradingStatus);
})();
```

## Sandbox

Для использования _Sandbox_ необходимо передать токен для песочницы.

## Преимущества

- Написано на _Typescript_ для Typescript
- Используются Promise и Async Generators
- Логирование и обработка ошибок с подробным описанием
- Автоматическая генерация proto-файлов
- Возможность добавлять свои middleware для работы с данными перед отправкой или после. (Пока только через Pull Request)
```typescript
type CallOptions = {
/**
* Request metadata.
*/
metadata?: Metadata;
/**
* Signal that cancels the call once aborted.
*/
signal?: AbortSignal;
/**
* Called when header is received.
*/
onHeader?(header: Metadata): void;
/**
* Called when trailer is received.
*/
onTrailer?(trailer: Metadata): void;
};
```
## Сообщество

[Telegram-чат](https://t.me/joinchat/VaW05CDzcSdsPULM)
23 changes: 23 additions & 0 deletions generateProto.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

npm_version=$(npm -v)

echo "Generating types from proto file started"

npm i

rm -rf ./src/generated/

mkdir ./src/generated/

chmod 755 ./src/generated

./node_modules/.bin/grpc_tools_node_protoc --plugin=protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./src/generated --ts_proto_opt=outputServices=generic-definitions,useExactTypes=false -I ./protos/ ./protos/*.proto

if [ $? -eq 0 ]
then
echo "Successfully generated types"
else
echo "Could not generate types" >&2
fi

Loading

0 comments on commit 1405715

Please sign in to comment.