Coder Social home page Coder Social logo

Comments (4)

Tim55667757 avatar Tim55667757 commented on September 20, 2024

Versions 1.2.* make more duplicated request when mixed FIGIs and tickers, for example:

$ tksbrokerapi % python3 TKSBrokerAPI.py -v 10 --prices POSI TGLD UNKNOWN BBG222222222 TCS00A103X66 POSI TGLD POSI TGLD GAZP EUR BBG0013HJJ31 BBG0013HJJ31
TKSBrokerAPI.py     L:3109 DEBUG   [2022-09-05 21:17:52,585] TKSBrokerAPI module started at: [2022-09-05 18:17:52] UTC, it is [2022-09-05 21:17:52] local time
TKSBrokerAPI.py     L:207  DEBUG   [2022-09-05 21:17:52,585] Bearer token for Tinkoff OpenApi set up from environment variable `TKS_API_TOKEN`. See https://tinkoff.github.io/investAPI/token/
TKSBrokerAPI.py     L:219  DEBUG   [2022-09-05 21:17:52,585] String with user's numeric account ID in Tinkoff Broker set up from environment variable `TKS_ACCOUNT_ID`
TKSBrokerAPI.py     L:249  DEBUG   [2022-09-05 21:17:52,585] Broker API server: https://invest-public-api.tinkoff.ru/rest
TKSBrokerAPI.py     L:310  DEBUG   [2022-09-05 21:17:52,609] Local cache with raw instruments data is used: [dump.json]
TKSBrokerAPI.py     L:311  DEBUG   [2022-09-05 21:17:52,609] Dump file was last modified [2022-09-05 17:44:28] UTC
TKSBrokerAPI.py     L:1091 DEBUG   [2022-09-05 21:17:52,609] Requesting current prices of list of instruments from Tinkoff Broker server...
TKSBrokerAPI.py     L:1104 DEBUG   [2022-09-05 21:17:52,609] Ordered input list of instruments without duplicates of names: ['POSI', 'TGLD', 'UNKNOWN', 'BBG222222222', 'TCS00A103X66', 'GAZP', 'EUR_RUB__TOM', 'BBG0013HJJ31']
TKSBrokerAPI.py     L:864  DEBUG   [2022-09-05 21:17:52,609] Requesting current prices for instrument with ticker [POSI] and FIGI [TCS00A103X66]...
TKSBrokerAPI.py     L:864  DEBUG   [2022-09-05 21:17:52,718] Requesting current prices for instrument with ticker [TGLD] and FIGI [BBG222222222]...
TKSBrokerAPI.py     L:1119 WARNING [2022-09-05 21:17:52,816] Instrument [UNKNOWN] not in list of available instruments for current token!
TKSBrokerAPI.py     L:864  DEBUG   [2022-09-05 21:17:52,817] Requesting current prices for instrument with ticker [TGLD] and FIGI [BBG222222222]...
TKSBrokerAPI.py     L:864  DEBUG   [2022-09-05 21:17:52,902] Requesting current prices for instrument with ticker [POSI] and FIGI [TCS00A103X66]...
TKSBrokerAPI.py     L:864  DEBUG   [2022-09-05 21:17:52,993] Requesting current prices for instrument with ticker [GAZP] and FIGI [BBG004730RP0]...
TKSBrokerAPI.py     L:864  DEBUG   [2022-09-05 21:17:53,081] Requesting current prices for instrument with ticker [EUR_RUB__TOM] and FIGI [BBG0013HJJ31]...
TKSBrokerAPI.py     L:864  DEBUG   [2022-09-05 21:17:53,173] Requesting current prices for instrument with ticker [EUR_RUB__TOM] and FIGI [BBG0013HJJ31]...
TKSBrokerAPI.py     L:1160 INFO    [2022-09-05 21:17:53,444] Only unique instruments are shown:
# Actual prices at: [2022-09-05 18:17 UTC]

| Ticker       | FIGI         | Type       | Prev. close | Last price  | Chg. %   | Day limits min/max  | Actual sell / buy   | Curr.
|--------------|--------------|------------|-------------|-------------|----------|---------------------|---------------------|------
| POSI         | TCS00A103X66 | Shares     |     1273.00 |     1273.00 |    0.00% |      875.2 / 1559.6 |           N/A / N/A | rub
| TGLD         | BBG222222222 | Etfs       |        0.07 |        0.07 |   +0.14% | 0.0636 / 0.07780000000000001 |           N/A / N/A | usd
| GAZP         | BBG004730RP0 | Shares     |      250.00 |      250.00 |    0.00% |       225.0 / 275.0 |           N/A / N/A | rub
| EUR_RUB__TOM | BBG0013HJJ31 | Currencies |       60.84 |       60.12 |   -1.17% |     55.73 / 65.9125 |           N/A / N/A | rub

TKSBrokerAPI.py     L:1166 INFO    [2022-09-05 21:17:53,446] Price list for all instruments saved to file: [prices.md]
TKSBrokerAPI.py     L:3361 DEBUG   [2022-09-05 21:17:53,446] All operations with Tinkoff Server using Open API are finished success (summary code is 0).
TKSBrokerAPI.py     L:3368 DEBUG   [2022-09-05 21:17:53,446] TKSBrokerAPI module work duration: [0:00:00.860501]
TKSBrokerAPI.py     L:3369 DEBUG   [2022-09-05 21:17:53,446] TKSBrokerAPI module finished: [2022-09-05 18:17:53] UTC, it is [2022-09-05 21:17:53] local time

from tksbrokerapi.

Tim55667757 avatar Tim55667757 commented on September 20, 2024

Fixed in versions 1.3.*
Now TKSBrokerAPI not request prices for duplicated instruments and saving working time (see example below and strings in logs with Requesting current prices for instrument with... and work duration):

$ tksbrokerapi % python3 TKSBrokerAPI.py -v 10 --prices POSI TGLD UNKNOWN BBG222222222 TCS00A103X66 POSI TGLD POSI TGLD GAZP EUR BBG0013HJJ31 BBG0013HJJ31
TKSBrokerAPI.py     L:3108 DEBUG   [2022-09-05 21:53:41,431] TKSBrokerAPI module started at: [2022-09-05 18:53:41] UTC, it is [2022-09-05 21:53:41] local time
TKSBrokerAPI.py     L:207  DEBUG   [2022-09-05 21:53:41,431] Bearer token for Tinkoff OpenApi set up from environment variable `TKS_API_TOKEN`. See https://tinkoff.github.io/investAPI/token/
TKSBrokerAPI.py     L:219  DEBUG   [2022-09-05 21:53:41,431] String with user's numeric account ID in Tinkoff Broker set up from environment variable `TKS_ACCOUNT_ID`
TKSBrokerAPI.py     L:249  DEBUG   [2022-09-05 21:53:41,431] Broker API server: https://invest-public-api.tinkoff.ru/rest
TKSBrokerAPI.py     L:310  DEBUG   [2022-09-05 21:53:41,462] Local cache with raw instruments data is used: [dump.json]
TKSBrokerAPI.py     L:311  DEBUG   [2022-09-05 21:53:41,462] Dump file was last modified [2022-09-05 17:44:28] UTC
TKSBrokerAPI.py     L:1102 DEBUG   [2022-09-05 21:53:41,462] Requested instruments without duplicates of tickers and FIGIs: ['POSI', 'TGLD', 'UNKNOWN', 'BBG222222222', 'TCS00A103X66', 'GAZP', 'EUR_RUB__TOM', 'BBG0013HJJ31']
TKSBrokerAPI.py     L:1117 WARNING [2022-09-05 21:53:41,463] Instrument [UNKNOWN] not in list of available instruments for current token!
TKSBrokerAPI.py     L:1122 DEBUG   [2022-09-05 21:53:41,464] Unique list of FIGIs: ['TCS00A103X66', 'BBG222222222', 'BBG004730RP0', 'BBG0013HJJ31']
TKSBrokerAPI.py     L:1123 DEBUG   [2022-09-05 21:53:41,464] Requesting current prices from Tinkoff Broker server...
TKSBrokerAPI.py     L:864  DEBUG   [2022-09-05 21:53:41,464] Requesting current prices for instrument with ticker [POSI] and FIGI [TCS00A103X66]...
TKSBrokerAPI.py     L:864  DEBUG   [2022-09-05 21:53:41,562] Requesting current prices for instrument with ticker [TGLD] and FIGI [BBG222222222]...
TKSBrokerAPI.py     L:864  DEBUG   [2022-09-05 21:53:41,639] Requesting current prices for instrument with ticker [GAZP] and FIGI [BBG004730RP0]...
TKSBrokerAPI.py     L:864  DEBUG   [2022-09-05 21:53:41,736] Requesting current prices for instrument with ticker [EUR_RUB__TOM] and FIGI [BBG0013HJJ31]...
TKSBrokerAPI.py     L:1159 INFO    [2022-09-05 21:53:41,820] Only unique instruments are shown:
# Actual prices at: [2022-09-05 18:53 UTC]

| Ticker       | FIGI         | Type       | Prev. close | Last price  | Chg. %   | Day limits min/max  | Actual sell / buy   | Curr.
|--------------|--------------|------------|-------------|-------------|----------|---------------------|---------------------|------
| POSI         | TCS00A103X66 | Shares     |     1273.00 |     1273.00 |    0.00% |      875.2 / 1559.6 |           N/A / N/A | rub
| TGLD         | BBG222222222 | Etfs       |        0.07 |        0.07 |   +0.14% | 0.0636 / 0.07780000000000001 |           N/A / N/A | usd
| GAZP         | BBG004730RP0 | Shares     |      250.00 |      250.00 |    0.00% |       225.0 / 275.0 |           N/A / N/A | rub
| EUR_RUB__TOM | BBG0013HJJ31 | Currencies |       60.84 |       60.12 |   -1.17% |     55.73 / 65.9125 |           N/A / N/A | rub

TKSBrokerAPI.py     L:1165 INFO    [2022-09-05 21:53:41,822] Price list for all instruments saved to file: [prices.md]
TKSBrokerAPI.py     L:3360 DEBUG   [2022-09-05 21:53:41,822] All operations with Tinkoff Server using Open API are finished success (summary code is 0).
TKSBrokerAPI.py     L:3367 DEBUG   [2022-09-05 21:53:41,822] TKSBrokerAPI module work duration: [0:00:00.391130]
TKSBrokerAPI.py     L:3368 DEBUG   [2022-09-05 21:53:41,823] TKSBrokerAPI module finished: [2022-09-05 18:53:41] UTC, it is [2022-09-05 21:53:41] local time

from tksbrokerapi.

Tim55667757 avatar Tim55667757 commented on September 20, 2024

Also fixed in Overview() method

from tksbrokerapi.

Tim55667757 avatar Tim55667757 commented on September 20, 2024

Debug build for this task: tksbrokerapi 1.3.dev67.
PyPI: https://pypi.org/project/tksbrokerapi/1.3.dev67/

from tksbrokerapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.