Coder Social home page Coder Social logo

Comments (1)

Tim55667757 avatar Tim55667757 commented on September 20, 2024 1

Added the ability to search for an instrument by part of the name, ticker or FIGI with--search key (or -s). A method for searching SearchInstruments() has been implemented, to which a search pattern can be passed as input: part of a word or a string with a regular expression. As a result, the method returns a dictionary of dictionaries, similar to variable iList, but containing only found instruments.

Find an instrument

To work with exchange instruments, receive information on them, request prices and make deals, you usually need to specify a ticker (key --ticker) or FIGI (key --figi). But there are hardly many people who know them by heart. Most often, there is only an assumption about a part of the ticker or the name of the company. In this case, you can use the search by pattern: part of the name, ticker or FIGI, or by specifying a regular expression. The search is performed by the standard python module re, case-insensitive.

Starting with TKSBrokerAPI v1.2.*, the --search key has been added, after which you need to specify the pattern. For example, you want to find all the instruments of the Russian Sber group of companies, then you can try to specify a part of the word: tksbrokerapi --search "sber". Or you want to know all the instruments of companies whose names contain the word "United" with "medical" or "rent". In this case, you can try to specify a regular expression: tksbrokerapi --search "(United.*).*(?:.*medical|rent)".

In addition to the --search key, you can specify the --output key and define the file name where to save the search results. By default, full search results are stored in search-results.md. Only the first 5 found instruments of each type are shown in the console.

After the desired instrument has been found and its ticker and FIGI have become known, you can view more detailed information with the command tksbrokerapi -t TICKER --info or tksbrokerapi -f FIGI --info (more).

Command to search for an instrument by part of its name
$ tksbrokerapi --search "sber"

TKSBrokerAPI.py     L:1067 INFO    [2022-08-11 23:42:54,569] # Search results

* **Search pattern:** [sber]
* **Found instruments:** [7]

**Note:** you can view info about found instruments with key `--info`, e.g.: `tksbrokerapi -t TICKER --info` or `tksbrokerapi -f FIGI --info`.

### Shares: [3]

| Type       | Ticker       | Full name                                                      | FIGI         |
|------------|--------------|----------------------------------------------------------------|--------------|
| Shares     | SBER         | Сбер Банк                                                      | BBG004730N88 |
| Shares     | SBERP        | Сбер Банк - привилегированные акции                            | BBG0047315Y7 |
| Shares     | SBER@GS      | Sberbank of Russia PJSC                                        | BBG001VBZR00 |

### Bonds: [4]

| Type       | Ticker       | Full name                                                      | FIGI         |
|------------|--------------|----------------------------------------------------------------|--------------|
| Bonds      | RU000A102CU4 | Сбер Банк 001P-SBER19                                          | BBG00Y9B45C2 |
| Bonds      | RU000A102RS6 | Сбер Банк 001P-SBER24                                          | BBG00ZZ927H8 |
| Bonds      | RU000A101C89 | Сбер Банк 001P-SBER15                                          | BBG00RKBQ4D2 |
| Bonds      | RU000A103G75 | Сбер Банк 001P-SBER32                                          | BBG0122KNFZ0 |

TKSBrokerAPI.py     L:1068 INFO    [2022-08-11 23:42:54,569] You can view info about found instruments with key `--info`, e.g.: `tksbrokerapi -t IBM --info` or `tksbrokerapi -f BBG000BLNNH6 --info`
TKSBrokerAPI.py     L:1074 INFO    [2022-08-11 23:42:54,569] Full search results were saved to file: [search-results.md]
Command to search for an instrument by regular expression
$ tksbrokerapi --search "(United.*).*(?:.*medical|rent)"

TKSBrokerAPI.py     L:1067 INFO    [2022-08-12 00:08:08,944] # Search results

* **Search pattern:** [(United.*).*(?:.*medical|rent)]
* **Found instruments:** [2]

**Note:** you can view info about found instruments with key `--info`, e.g.: `tksbrokerapi -t TICKER --info` or `tksbrokerapi -f FIGI --info`.

### Shares: [2]

| Type       | Ticker       | Full name                                                      | FIGI         |
|------------|--------------|----------------------------------------------------------------|--------------|
| Shares     | GEMC         | United medical group                                           | BBG011MCM288 |
| Shares     | URI          | United Rentals                                                 | BBG000BXMFC3 |

TKSBrokerAPI.py     L:1068 INFO    [2022-08-12 00:08:08,944] You can view info about found instruments with key `--info`, e.g.: `tksbrokerapi -t IBM --info` or `tksbrokerapi -f BBG000BLNNH6 --info`
TKSBrokerAPI.py     L:1074 INFO    [2022-08-12 00:08:08,945] Full search results were saved to file: [search-results.md]

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.