Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 | 24x 24x 1x 1x 1x 2x 1x 1x 1x 1x 1x 1x 1x 3x 1x 1x | import { Common, MoneyValue, GetOperationsByCursorRequest, GetOperationsByCursorResponse, OperationsRequest, OperationsResponse, PortfolioRequest, PortfolioResponse, PositionsRequest, PositionsResponse, WithdrawLimitsRequest, WithdrawLimitsResponse, CancelOrderRequest, CancelOrderResponse, GetOrderStateRequest, GetOrdersRequest, GetOrdersResponse, OrderState, PostOrderRequest, PostOrderResponse, ReplaceOrderRequest, GetAccountsRequest, GetAccountsResponse } from './' /** * Запрос открытия счёта в песочнице * @see https://tinkoff.github.io/investAPI/sandbox/#opensandboxaccountrequest */ export interface OpenSandboxAccountRequest {} /** * Номер открытого счёта в песочнице * @see https://tinkoff.github.io/investAPI/sandbox/#opensandboxaccountresponse */ export interface OpenSandboxAccountResponse { /** Номер счёта */ accountId: string } /** * Запрос закрытия счёта в песочнице * @see https://tinkoff.github.io/investAPI/sandbox/#closesandboxaccountrequest */ export interface CloseSandboxAccountRequest { /** Номер счёта */ accountId: string } /** * Результат закрытия счёта в песочнице * @see https://tinkoff.github.io/investAPI/sandbox/#closesandboxaccountresponse */ export interface CloseSandboxAccountResponse {} /** * Запрос пополнения счёта в песочнице * @see https://tinkoff.github.io/investAPI/sandbox/#sandboxpayinrequest */ export interface SandboxPayInRequest { /** Номер счёта */ accountId: string /** Сумма пополнения счёта в рублях */ amount: MoneyValue } /** * Результат пополнения счёта, текущий баланс * @see https://tinkoff.github.io/investAPI/sandbox/#sandboxpayinresponse */ export interface SandboxPayInResponse { /** Текущий баланс счёта */ balance: MoneyValue } /** * Сервис для работы с песочницей TINKOFF INVEST API * @see https://tinkoff.github.io/investAPI/sandbox/#sandboxservice */ export class SandboxService extends Common { /** * Метод регистрации счёта в песочнице * ```js * import { SandboxService } from '@tomasevich/tinkoff' * * const sandboxService = new SandboxService('<TOKEN>', true) * const result = await sandboxService.OpenSandboxAccount({}) * * console.log(result) * ``` * @see https://tinkoff.github.io/investAPI/sandbox/#opensandboxaccount */ public OpenSandboxAccount( body: OpenSandboxAccountRequest ): Promise<OpenSandboxAccountResponse> { return this.request('SandboxService', 'OpenSandboxAccount', body) } /** * Метод получения счетов в песочнице * ```js * import { SandboxService } from '@tomasevich/tinkoff' * * const sandboxService = new SandboxService('<TOKEN>', true) * const { accounts } = await sandboxService.GetSandboxAccounts({}) * * console.log(accounts) * ``` * @see https://tinkoff.github.io/investAPI/sandbox/#getsandboxaccounts */ public GetSandboxAccounts( body: GetAccountsRequest ): Promise<GetAccountsResponse> { return this.request('SandboxService', 'GetSandboxAccounts', body) } /** * Метод закрытия счёта в песочнице * ```js * import { SandboxService } from '@tomasevich/tinkoff' * * const sandboxService = new SandboxService('<TOKEN>', true) * const result = await sandboxService.OpenSandboxAccount({ * accountId: 'ad49188f-6d97-4493-8a68-c9adcd15db42' * }) * * console.log(result) * ``` * @see https://tinkoff.github.io/investAPI/sandbox/#closesandboxaccount */ public CloseSandboxAccount( body: CloseSandboxAccountRequest ): Promise<CloseSandboxAccountResponse> { return this.request('SandboxService', 'CloseSandboxAccount', body) } /** * Метод выставления торгового поручения в песочнице * ```js * import { SandboxService, OrderDirection, OrderType } from '@tomasevich/tinkoff' * * const sandboxService = new SandboxService('<TOKEN>', true) * const result = await sandboxService.PostSandboxOrder({ * quantity: '1', * price: SandboxService.StringToQuotation('1.0'), * direction: OrderDirection.ORDER_DIRECTION_BUY, * accountId: '<ACCOUNT_ID>', * orderType: OrderType.ORDER_TYPE_MARKET, * orderId: '', * instrumentId: '6afa6f80-03a7-4d83-9cf0-c19d7d021f76' * }) * * console.log(result) * ``` * @see https://tinkoff.github.io/investAPI/sandbox/#postsandboxorder */ public PostSandboxOrder(body: PostOrderRequest): Promise<PostOrderResponse> { return this.request('SandboxService', 'PostSandboxOrder', body) } /** * Метод изменения выставленной заявки * ```js * import { SandboxService, PriceType } from '@tomasevich/tinkoff' * * const sandboxService = new SandboxService('<TOKEN>', true) * const result = await sandboxService.ReplaceSandboxOrder({ * quantity: '1', * price: SandboxService.StringToQuotation('1.0'), * accountId: '<ACCOUNT_ID>', * orderId: '', * idempotencyKey: '', * priceType: PriceType.PRICE_TYPE_CURRENCY * }) * * console.log(result) * ``` * @see https://tinkoff.github.io/investAPI/sandbox/#replacesandboxorder */ public ReplaceSandboxOrder( body: ReplaceOrderRequest ): Promise<PostOrderResponse> { return this.request('SandboxService', 'ReplaceSandboxOrder', body) } /** * Метод получения списка активных заявок по счёту в песочнице * ```js * import { SandboxService } from '@tomasevich/tinkoff' * * const sandboxService = new SandboxService('<TOKEN>', true) * const { orders } = await sandboxService.GetSandboxOrders({ * accountId: '<ACCOUNT_ID>' * }) * * console.log(orders) * ``` * @see https://tinkoff.github.io/investAPI/sandbox/#getsandboxorders */ public GetSandboxOrders(body: GetOrdersRequest): Promise<GetOrdersResponse> { return this.request('SandboxService', 'GetSandboxOrders', body) } /** * Метод отмены торгового поручения в песочнице * ```js * import { SandboxService } from '@tomasevich/tinkoff' * * const sandboxService = new SandboxService('<TOKEN>', true) * const { orders } = await sandboxService.CancelSandboxOrder({ * accountId: '<ACCOUNT_ID>', * orderId: '<ORDER_ID>' * }) * * console.log(orders) * ``` * @see https://tinkoff.github.io/investAPI/sandbox/#cancelsandboxorder */ public CancelSandboxOrder( body: CancelOrderRequest ): Promise<CancelOrderResponse> { return this.request('SandboxService', 'CancelSandboxOrder', body) } /** * Метод получения статуса заявки в песочнице * ```js * import { SandboxService } from '@tomasevich/tinkoff' * * const sandboxService = new SandboxService('<TOKEN>', true) * const { orders } = await sandboxService.GetSandboxOrderState({ * accountId: '<ACCOUNT_ID>', * orderId: '<ORDER_ID>' * }) * * console.log(orders) * ``` * @description Заявки хранятся в таблице 7 дней * @see https://tinkoff.github.io/investAPI/sandbox/#getsandboxorderstate */ public GetSandboxOrderState(body: GetOrderStateRequest): Promise<OrderState> { return this.request('SandboxService', 'GetSandboxOrderState', body) } /** * Метод получения позиций по виртуальному счёту * ```js * import { SandboxService } from '@tomasevich/tinkoff' * * const sandboxService = new SandboxService('<TOKEN>', true) * const sandboxPositions = await sandboxService.GetSandboxPositions({ * accountId: '<ACCOUNT_ID>' * }) * * console.log(sandboxPositions) * ``` * @see https://tinkoff.github.io/investAPI/sandbox/#getsandboxpositions */ public GetSandboxPositions( body: PositionsRequest ): Promise<PositionsResponse> { return this.request('SandboxService', 'GetSandboxPositions', body) } /** * Метод получения операций в песочнице по номеру счёта * ```js * import { SandboxService, OperationState } from '@tomasevich/tinkoff' * * const sandboxService = new SandboxService('<TOKEN>', true) * const { operations } = await sandboxService.GetSandboxOperations({ * accountId: '<ACCOUNT_ID>', * from: '2023-07-18T00:00:00:000Z', * to: '2023-08-19T00:00:00:000Z', * state: OperationState.OPERATION_STATE_EXECUTED * }) * * console.log(operations) * ``` * @see https://tinkoff.github.io/investAPI/sandbox/#getsandboxoperations */ public GetSandboxOperations( body: OperationsRequest ): Promise<OperationsResponse> { return this.request('SandboxService', 'GetSandboxOperations', body) } /** * Метод получения операций в песочнице по номеру счета с пагинацией * ```js * import { SandboxService, OperationState, OperationType } from '@tomasevich/tinkoff' * * const sandboxService = new SandboxService('<TOKEN>', true) * const operationsByCursor = await sandboxService.GetSandboxOperationsByCursor({ * accountId: '<ACCOUNT_ID>', * instrumentId: '6afa6f80-03a7-4d83-9cf0-c19d7d021f76', * from: '2023-07-18T00:00:00:000Z', * to: '2023-08-19T00:00:00:000Z', * cursor: '', * limit: 10, * state: OperationState.OPERATION_STATE_CANCELED, * operationTypes: [ * OperationType.OPERATION_TYPE_BUY, * OperationType.OPERATION_TYPE_SELL * ], * withoutCommissions: false, * withoutTrades: false, * withoutOvernights: false * }) * * console.log(operationsByCursor) * ``` * @see https://tinkoff.github.io/investAPI/sandbox/#getsandboxoperationsbycursor */ public GetSandboxOperationsByCursor( body: GetOperationsByCursorRequest ): Promise<GetOperationsByCursorResponse> { return this.request('SandboxService', 'GetSandboxOperationsByCursor', body) } /** * Метод получения портфолио в песочнице * ```js * import { SandboxService, PortfolioRequestCurrencyRequest } from '@tomasevich/tinkoff' * * const sandboxService = new SandboxService('<TOKEN>', true) * const portfolio = await sandboxService.GetPortfolio({ * accountId: '<ACCOUNT_ID>', * currency: PortfolioRequestCurrencyRequest.RUB * }) * * console.log(portfolio) * ``` * @see https://tinkoff.github.io/investAPI/sandbox/#getsandboxportfolio */ public GetSandboxPortfolio( body: PortfolioRequest ): Promise<PortfolioResponse> { return this.request('SandboxService', 'GetSandboxPortfolio', body) } /** * Метод пополнения счёта в песочнице * ```js * import { SandboxService } from '@tomasevich/tinkoff' * * const sandboxService = new SandboxService('<TOKEN>', true) * const { orders } = await sandboxService.SandboxPayIn({ * accountId: '<ACCOUNT_ID>', * amount: SandboxService.StringToMoneyValue('114,25 rub') * }) * * console.log(orders) * ``` * @see https://tinkoff.github.io/investAPI/sandbox/#sandboxpayin */ public SandboxPayIn( body: SandboxPayInRequest ): Promise<SandboxPayInResponse> { return this.request('SandboxService', 'SandboxPayIn', body) } /** * Метод получения доступного остатка для вывода средств в песочнице * ```js * import { SandboxService } from '@tomasevich/tinkoff' * * const sandboxService = new SandboxService('<TOKEN>', true) * const withdrawLimits = await sandboxService.GetWithdrawLimits({ * accountId: '<ACCOUNT_ID>' * }) * * console.log(withdrawLimits) * ``` * @see https://tinkoff.github.io/investAPI/sandbox/#getsandboxwithdrawlimits */ public GetSandboxWithdrawLimits( body: WithdrawLimitsRequest ): Promise<WithdrawLimitsResponse> { return this.request('SandboxService', 'GetSandboxWithdrawLimits', body) } } |