-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1405715
Showing
38 changed files
with
28,397 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
Oops, something went wrong.