tksbrokerapi.TKSEnums
Module contains a lot of constants from enums sections of Tinkoff Open API documentation used by TKSBrokerAPI module.
- TKSBrokerAPI module documentation: https://tim55667757.github.io/TKSBrokerAPI/docs/tksbrokerapi/TKSBrokerAPI.html
- TKSBrokerAPI CLI examples: https://github.com/Tim55667757/TKSBrokerAPI/blob/master/README_EN.md
- About Tinkoff Invest API: https://tinkoff.github.io/investAPI/
- Tinkoff Invest API documentation: https://tinkoff.github.io/investAPI/swagger-ui/
- Open account for trading: http://tinkoff.ru/sl/AaX1Et1omnH
1# -*- coding: utf-8 -*- 2# Author: Timur Gilmullin 3 4""" 5Module contains a lot of constants from enums sections of Tinkoff Open API documentation used by TKSBrokerAPI module. 6 7- **TKSBrokerAPI module documentation:** https://tim55667757.github.io/TKSBrokerAPI/docs/tksbrokerapi/TKSBrokerAPI.html 8- **TKSBrokerAPI CLI examples:** https://github.com/Tim55667757/TKSBrokerAPI/blob/master/README_EN.md 9- **About Tinkoff Invest API:** https://tinkoff.github.io/investAPI/ 10- **Tinkoff Invest API documentation:** https://tinkoff.github.io/investAPI/swagger-ui/ 11- **Open account for trading:** http://tinkoff.ru/sl/AaX1Et1omnH 12""" 13 14# Copyright (c) 2022 Gilmillin Timur Mansurovich 15# 16# Licensed under the Apache License, Version 2.0 (the "License"); 17# you may not use this file except in compliance with the License. 18# You may obtain a copy of the License at 19# 20# http://www.apache.org/licenses/LICENSE-2.0 21# 22# Unless required by applicable law or agreed to in writing, software 23# distributed under the License is distributed on an "AS IS" BASIS, 24# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25# See the License for the specific language governing permissions and 26# limitations under the License. 27 28 29TKS_DATE_TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ" 30"""Date and time string format used by Tinkoff Open API. Default: `"%Y-%m-%dT%H:%M:%SZ"`.""" 31 32TKS_DATE_TIME_FORMAT_EXT = "%Y-%m-%dT%H:%M:%S.%fZ" 33"""Extended date and time string format used by Tinkoff Open API. Default: `"%Y-%m-%dT%H:%M:%S.%fZ"`.""" 34 35TKS_DATE_FORMAT = "%Y-%m-%d" 36"""Date string format for some methods. Default: `"%Y-%m-%d"`.""" 37 38TKS_PRINT_DATE_TIME_FORMAT = "%Y-%m-%d %H:%M:%S" 39"""Human-readable format of date and time string. Default: `"%Y-%m-%d %H:%M:%S"`.""" 40 41TKS_INSTRUMENTS = ["Currencies", "Shares", "Bonds", "Etfs", "Futures"] 42"""Type of instrument for trade methods must be only one of supported types, listed in this constant. Default: `["Currencies", "Shares", "Bonds", "Etfs", "Futures"]`""" 43 44TKS_TICKER_ALIASES = { 45 "USD": "USD000UTSTOM", # FIGI: BBG0013HGFT4 46 "EUR": "EUR_RUB__TOM", # FIGI: BBG0013HJJ31 47 "GBP": "GBPRUB_TOM", # FIGI: BBG0013HQ5F0 48 "CHF": "CHFRUB_TOM", # FIGI: BBG0013HQ5K4 49 "CNY": "CNYRUB_TOM", # FIGI: BBG0013HRTL0 50 "HKD": "HKDRUB_TOM", # FIGI: BBG0013HSW87 51 "TRY": "TRYRUB_TOM", # FIGI: BBG0013J12N1 52} 53"""Some aliases instead official tickers for using in CLI. For example, you can use `"USD"` instead of `"USD000UTSTOM"`.""" 54 55# some tickers or FIGIs raised exception earlier when it sends to server, that is why we exclude there: 56TKS_TICKERS_OR_FIGI_EXCLUDED = [ 57 "ISSUANCEBRUS", 58] 59 60TKS_CANDLE_INTERVALS = { # List values: 1st - Tinkoff API parameter, 2nd - minutes count, 3rd - max candles in block 61 "Undefined": ["CANDLE_INTERVAL_UNSPECIFIED", 0, 0], 62 "1min": ["CANDLE_INTERVAL_1_MIN", 1, 1438], # max count in API request block: 1 day (1440 min) and -2 minute 63 "5min": ["CANDLE_INTERVAL_5_MIN", 5, 287], # max count in API request block: 1 day (288 by 5 min) and -5 minute 64 "15min": ["CANDLE_INTERVAL_15_MIN", 15, 95], # max count in API request block: 1 day (96 by 15 min) and -15 minute 65 "hour": ["CANDLE_INTERVAL_HOUR", 60, 167], # max count in API request block: 1 week (168 hours) and -1 hour 66 "day": ["CANDLE_INTERVAL_DAY", 1440, 364], # max count in API request block: 1 year (365 days) and -1 day 67} 68"""Candles interval for requesting history data with Tinkoff API. Current available keys are `"1min"`, `"5min"`, `"15min"`, `"hour"`, `"day"`. 69See more: https://tinkoff.github.io/investAPI/swagger-ui/#/MarketDataService/MarketDataService_GetCandles 70""" 71 72TKS_ACCOUNT_STATUSES = { 73 "ACCOUNT_STATUS_UNSPECIFIED": "Account status undefined", 74 "ACCOUNT_STATUS_NEW": "New, open in progress...", 75 "ACCOUNT_STATUS_OPEN": "Opened and active account", 76 "ACCOUNT_STATUS_CLOSED": "Closed account", 77} 78"""Account status, enums: https://tinkoff.github.io/investAPI/users/#accountstatus""" 79 80TKS_ACCOUNT_TYPES = { 81 "ACCOUNT_TYPE_UNSPECIFIED": "Account type undefined", 82 "ACCOUNT_TYPE_TINKOFF": "Tinkoff brokerage account", 83 "ACCOUNT_TYPE_TINKOFF_IIS": "IIS account", 84 "ACCOUNT_TYPE_INVEST_BOX": "Investment \"piggy bank\"", 85} 86"""Account type, enums: https://tinkoff.github.io/investAPI/users/#accounttype""" 87 88TKS_ACCESS_LEVELS = { 89 "ACCOUNT_ACCESS_LEVEL_UNSPECIFIED": "Access level undefined", 90 "ACCOUNT_ACCESS_LEVEL_FULL_ACCESS": "Full access", 91 "ACCOUNT_ACCESS_LEVEL_READ_ONLY": "Read-only access", 92 "ACCOUNT_ACCESS_LEVEL_NO_ACCESS": "No access", 93} 94"""Access level, enums: https://tinkoff.github.io/investAPI/users/#accesslevel""" 95 96TKS_QUALIFIED_TYPES = { 97 "derivative": "Futures and Options", 98 "structured_bonds": "Structured bonds", 99 "closed_fund": "Closed-ended funds", 100 "bond": "Bonds with low rating", 101 "structured_income_bonds": "Structured income bonds", 102 "foreign_shares": "Foreign shares not included in the exchange quotation lists", 103 "foreign_etf": "Foreign ETF", 104 "foreign_bond": "Euro-bonds", 105 "russian_shares": "Russian shares not included in quotation lists", 106 "leverage": "Margin trading, unsecured leveraged trades", 107 "repo": "REPO agreements", 108} 109"""Values of `qualified_for_work_with`, field: https://tinkoff.github.io/investAPI/faq_users/#qualified_for_work_with""" 110 111TKS_TRADING_STATUSES = { 112 "SECURITY_TRADING_STATUS_UNSPECIFIED": "Trading status undefined", 113 "SECURITY_TRADING_STATUS_NOT_AVAILABLE_FOR_TRADING": "Not available for trading", 114 "SECURITY_TRADING_STATUS_OPENING_PERIOD": "Trade opening period", 115 "SECURITY_TRADING_STATUS_CLOSING_PERIOD": "Trade closing period", 116 "SECURITY_TRADING_STATUS_BREAK_IN_TRADING": "Break in trading", 117 "SECURITY_TRADING_STATUS_NORMAL_TRADING": "Normal trading", 118 "SECURITY_TRADING_STATUS_CLOSING_AUCTION": "Closing auction", 119 "SECURITY_TRADING_STATUS_DARK_POOL_AUCTION": "Large package auction", 120 "SECURITY_TRADING_STATUS_DISCRETE_AUCTION": "Discrete auction", 121 "SECURITY_TRADING_STATUS_OPENING_AUCTION_PERIOD": "Opening auction", 122 "SECURITY_TRADING_STATUS_TRADING_AT_CLOSING_AUCTION_PRICE": "Trading period at the closing auction price", 123 "SECURITY_TRADING_STATUS_SESSION_ASSIGNED": "Session assigned", 124 "SECURITY_TRADING_STATUS_SESSION_CLOSE": "Session closed", 125 "SECURITY_TRADING_STATUS_SESSION_OPEN": "Session is open", 126 "SECURITY_TRADING_STATUS_DEALER_NORMAL_TRADING": "Broker's internal liquidity mode trading", 127 "SECURITY_TRADING_STATUS_DEALER_BREAK_IN_TRADING": "Break in trading in the broker's internal liquidity mode", 128 "SECURITY_TRADING_STATUS_DEALER_NOT_AVAILABLE_FOR_TRADING": "Broker's internal liquidity mode is not available", 129} 130"""Security Trading Status, enums: https://tinkoff.github.io/investAPI/orders/#securitytradingstatus""" 131 132TKS_OPERATION_TYPES = { 133 "OPERATION_TYPE_UNSPECIFIED": "The operation type is not defined", 134 "OPERATION_TYPE_INPUT": "Deposit on broker account", 135 "OPERATION_TYPE_BOND_TAX": "Withholding personal income tax on bond coupons", 136 "OPERATION_TYPE_OUTPUT_SECURITIES": "Securities output", 137 "OPERATION_TYPE_OVERNIGHT": "Overnight REPO income", 138 "OPERATION_TYPE_TAX": "Tax withholding", 139 "OPERATION_TYPE_BOND_REPAYMENT_FULL": "Full bond redemption", 140 "OPERATION_TYPE_SELL_CARD": "Sell securities from the card", 141 "OPERATION_TYPE_DIVIDEND_TAX": "Withholding tax on dividends", 142 "OPERATION_TYPE_OUTPUT": "Withdrawals", 143 "OPERATION_TYPE_BOND_REPAYMENT": "Bonds partial redemption", 144 "OPERATION_TYPE_TAX_CORRECTION": "Tax correction", 145 "OPERATION_TYPE_SERVICE_FEE": "Brokerage account maintenance fee deduction", 146 "OPERATION_TYPE_BENEFIT_TAX": "Withholding tax for material benefits", 147 "OPERATION_TYPE_MARGIN_FEE": "Withholding commission for an uncovered position", 148 "OPERATION_TYPE_BUY": "Buy securities", 149 "OPERATION_TYPE_BUY_CARD": "Buy securities from a card", 150 "OPERATION_TYPE_INPUT_SECURITIES": "Transfer securities from another depository", 151 "OPERATION_TYPE_SELL_MARGIN": "Sell (by margin call)", 152 "OPERATION_TYPE_BROKER_FEE": "Operation fee deduction", 153 "OPERATION_TYPE_BUY_MARGIN": "Buy (by margin call)", 154 "OPERATION_TYPE_DIVIDEND": "Dividends income", 155 "OPERATION_TYPE_SELL": "Sell securities", 156 "OPERATION_TYPE_COUPON": "Coupons income", 157 "OPERATION_TYPE_SUCCESS_FEE": "Success fee deduction", 158 "OPERATION_TYPE_DIVIDEND_TRANSFER": "Transfer of dividend income", 159 "OPERATION_TYPE_ACCRUING_VARMARGIN": "Variation margin crediting", 160 "OPERATION_TYPE_WRITING_OFF_VARMARGIN": "Withholding variation margin", 161 "OPERATION_TYPE_DELIVERY_BUY": "Buy (futures contract expired)", 162 "OPERATION_TYPE_DELIVERY_SELL": "Sell (futures contract expired)", 163 "OPERATION_TYPE_TRACK_MFEE": "Autotrack account management fee", 164 "OPERATION_TYPE_TRACK_PFEE": "Pay per result on auto follow score", 165 "OPERATION_TYPE_TAX_PROGRESSIVE": "Tax withholding at the rate of 15%", 166 "OPERATION_TYPE_BOND_TAX_PROGRESSIVE": "Withholding tax on coupons at the rate of 15%", 167 "OPERATION_TYPE_DIVIDEND_TAX_PROGRESSIVE": "Withholding tax on dividends at the rate of 15%", 168 "OPERATION_TYPE_BENEFIT_TAX_PROGRESSIVE": "Withholding tax for material benefits at the rate of 15%", 169 "OPERATION_TYPE_TAX_CORRECTION_PROGRESSIVE": "Tax correction at the rate of 15%", 170 "OPERATION_TYPE_TAX_REPO_PROGRESSIVE": "Withholding tax on refunds on REPO transactions at the rate of 15%", 171 "OPERATION_TYPE_TAX_REPO": "Tax withholding on REPO trade refunds", 172 "OPERATION_TYPE_TAX_REPO_HOLD": "Tax hold on REPO transactions", 173 "OPERATION_TYPE_TAX_REPO_REFUND": "Tax refund on REPO transactions", 174 "OPERATION_TYPE_TAX_REPO_HOLD_PROGRESSIVE": "Withholding tax on REPO transactions at the rate of 15%", 175 "OPERATION_TYPE_TAX_REPO_REFUND_PROGRESSIVE": "Tax refund on REPO transactions at the rate of 15%", 176 "OPERATION_TYPE_DIV_EXT": "Payout dividends to the card", 177 "OPERATION_TYPE_TAX_CORRECTION_COUPON": "Coupon tax correction", 178} 179"""Operation type, enums: https://tinkoff.github.io/investAPI/operations/#operationtype""" 180 181TKS_OPERATION_STATES = { 182 "OPERATION_STATE_UNSPECIFIED": "! Unknown", 183 "OPERATION_STATE_EXECUTED": "√ Executed", 184 "OPERATION_STATE_CANCELED": "× Canceled", 185} 186"""Operation state, enums: https://tinkoff.github.io/investAPI/operations/#operationstate""" 187 188TKS_ORDER_DIRECTIONS = { 189 "ORDER_DIRECTION_UNSPECIFIED": "Undefined", 190 "ORDER_DIRECTION_BUY": "↑ Buy", 191 "ORDER_DIRECTION_SELL": "↓ Sell", 192} 193"""Order direction, enums: https://tinkoff.github.io/investAPI/orders/#orderdirection""" 194 195TKS_STOP_ORDER_DIRECTIONS = { 196 "STOP_ORDER_DIRECTION_UNSPECIFIED": "Undefined", 197 "STOP_ORDER_DIRECTION_BUY": "↑ Buy", 198 "STOP_ORDER_DIRECTION_SELL": "↓ Sell", 199} 200"""Stop-order direction, enums: https://tinkoff.github.io/investAPI/stoporders/#stoporderdirection""" 201 202TKS_ORDER_TYPES = { 203 "ORDER_TYPE_UNSPECIFIED": "Undefined", 204 "ORDER_TYPE_LIMIT": "Limit", 205 "ORDER_TYPE_MARKET": "Market", 206} 207"""Order type, enums: https://tinkoff.github.io/investAPI/orders/#ordertype""" 208 209TKS_STOP_ORDER_TYPES = { 210 "STOP_ORDER_TYPE_UNSPECIFIED": "Undefined", 211 "STOP_ORDER_TYPE_TAKE_PROFIT": "Take profit", 212 "STOP_ORDER_TYPE_STOP_LOSS": "Stop loss", 213 "STOP_ORDER_TYPE_STOP_LIMIT": "Stop limit", 214} 215"""Stop-order type, enums: https://tinkoff.github.io/investAPI/stoporders/#stopordertype""" 216 217TKS_ORDER_STATES = { 218 "EXECUTION_REPORT_STATUS_UNSPECIFIED": "! Unknown", 219 "EXECUTION_REPORT_STATUS_FILL": "Performed", 220 "EXECUTION_REPORT_STATUS_REJECTED": "Rejected", 221 "EXECUTION_REPORT_STATUS_CANCELLED": "Cancelled", 222 "EXECUTION_REPORT_STATUS_NEW": "New order", 223 "EXECUTION_REPORT_STATUS_PARTIALLYFILL": "Partially filled", 224} 225"""Order status, enums: https://tinkoff.github.io/investAPI/orders/#orderexecutionreportstatus""" 226 227TKS_STOP_ORDER_EXPIRATION_TYPES = { 228 "STOP_ORDER_EXPIRATION_TYPE_UNSPECIFIED": "Undefined", 229 "STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_CANCEL": "Until cancel", 230 "STOP_ORDER_EXPIRATION_TYPE_GOOD_TILL_DATE": "Until date", 231} 232"""Expiration type of stop-orders, enums: https://tinkoff.github.io/investAPI/stoporders/#stoporderexpirationtype""" 233 234TKS_COUPON_TYPES = { 235 "COUPON_TYPE_UNSPECIFIED": "Undefined", 236 "COUPON_TYPE_CONSTANT": "Constant", 237 "COUPON_TYPE_FLOATING": "Floating", 238 "COUPON_TYPE_DISCOUNT": "Discount", 239 "COUPON_TYPE_MORTGAGE": "Mortgage", 240 "COUPON_TYPE_FIX": "Fixed", 241 "COUPON_TYPE_VARIABLE": "Variable", 242 "COUPON_TYPE_OTHER": "Other", 243} 244"""Coupon type of bonds, enums: https://tinkoff.github.io/investAPI/instruments/#coupontype""" 245 246TKS_REAL_EXCHANGES = { 247 "REAL_EXCHANGE_UNSPECIFIED": "Undefined", 248 "REAL_EXCHANGE_MOEX": "MOEX", 249 "REAL_EXCHANGE_RTS": "SPBEX", 250 "REAL_EXCHANGE_OTC": "OTC", 251} 252"""The real exchange for the execution of trades, enums: https://tinkoff.github.io/investAPI/instruments/#realexchange""" 253 254TKS_SHARE_TYPES = { 255 "SHARE_TYPE_UNSPECIFIED": "Undefined", 256 "SHARE_TYPE_COMMON": "Ordinary", 257 "SHARE_TYPE_PREFERRED": "Privileged", 258 "SHARE_TYPE_ADR": "American Depositary Receipts (ADR)", 259 "SHARE_TYPE_GDR": "Global Depositary Receipts (GDR)", 260 "SHARE_TYPE_MLP": "Master Limited Partnership (MLP)", 261 "SHARE_TYPE_NY_REG_SHRS": "New York registered shares", 262 "SHARE_TYPE_CLOSED_END_FUND": "Closed investment fund", 263 "SHARE_TYPE_REIT": "Real estate trust", 264} 265"""Share type, enums: https://tinkoff.github.io/investAPI/instruments/#sharetype"""
Date and time string format used by Tinkoff Open API. Default: "%Y-%m-%dT%H:%M:%SZ"
.
Extended date and time string format used by Tinkoff Open API. Default: "%Y-%m-%dT%H:%M:%S.%fZ"
.
Date string format for some methods. Default: "%Y-%m-%d"
.
Human-readable format of date and time string. Default: "%Y-%m-%d %H:%M:%S"
.
Type of instrument for trade methods must be only one of supported types, listed in this constant. Default: ["Currencies", "Shares", "Bonds", "Etfs", "Futures"]
Some aliases instead official tickers for using in CLI. For example, you can use "USD"
instead of "USD000UTSTOM"
.
Candles interval for requesting history data with Tinkoff API. Current available keys are "1min"
, "5min"
, "15min"
, "hour"
, "day"
.
See more: https://tinkoff.github.io/investAPI/swagger-ui/#/MarketDataService/MarketDataService_GetCandles
Account status, enums: https://tinkoff.github.io/investAPI/users/#accountstatus
Account type, enums: https://tinkoff.github.io/investAPI/users/#accounttype
Access level, enums: https://tinkoff.github.io/investAPI/users/#accesslevel
Values of qualified_for_work_with
, field: https://tinkoff.github.io/investAPI/faq_users/#qualified_for_work_with
Security Trading Status, enums: https://tinkoff.github.io/investAPI/orders/#securitytradingstatus
Operation type, enums: https://tinkoff.github.io/investAPI/operations/#operationtype
Operation state, enums: https://tinkoff.github.io/investAPI/operations/#operationstate
Order direction, enums: https://tinkoff.github.io/investAPI/orders/#orderdirection
Stop-order direction, enums: https://tinkoff.github.io/investAPI/stoporders/#stoporderdirection
Order type, enums: https://tinkoff.github.io/investAPI/orders/#ordertype
Stop-order type, enums: https://tinkoff.github.io/investAPI/stoporders/#stopordertype
Order status, enums: https://tinkoff.github.io/investAPI/orders/#orderexecutionreportstatus
Expiration type of stop-orders, enums: https://tinkoff.github.io/investAPI/stoporders/#stoporderexpirationtype
Coupon type of bonds, enums: https://tinkoff.github.io/investAPI/instruments/#coupontype
The real exchange for the execution of trades, enums: https://tinkoff.github.io/investAPI/instruments/#realexchange
Share type, enums: https://tinkoff.github.io/investAPI/instruments/#sharetype