reticker
reticker is a Python 3.8 package to extract what look like stock tickers from the given text. It uses a configurably created regular expression. It does not however validate or use a whitelist of tickers.
Examples
>>> import reticker
>>> reticker.TickerExtractor().extract("Comparing FNGU vs $WEBL vs SOXL- who wins? And what about $cldl vs $Skyu? BTW, will the $w+Z pair still grow? IMHO, SOXL is king! [V]isa is A-okay!")
["FNGU", "WEBL", "SOXL", "CLDL", "SKYU", "W", "Z", "V", "A"]
>>> reticker.TickerExtractor().extract("Which of BTC-USD, $ETH-USD and $ada-usd is best?\nWhat about $Brk.a and $Brk.B? Compare futures MGC=F and SIL=F.")
['BTC-USD', 'ETH-USD', 'ADA-USD', 'BRK.A', 'BRK.B', 'MGC=F', 'SIL=F']
Features
- Optional matching of prefixed uppercase (e.g.
$SPY), unprefixed uppercase (e.g.SPY), prefixed lowercase (e.g.$spy), and prefixed titlecase tickers (e.g.$Spy) is enabled by default, but can individually be disabled. At least one of the four must be enabled. - Two-part tickers are also matched using a customizable set of separator characters.
- The results are in the order they are first found.
- By default, the results are deduplicated, although this can be disabled.
- A configurable blacklist of common false-positives is used.
- A configurable remapping of tickers is supported.
- For lower level use, a configurably created compiled regular expression can be accessed.
Links
| Caption | Link |
|---|---|
| Repo | https://github.com/impredicative/reticker/ |
| Changelog | https://github.com/impredicative/reticker/releases |
| Package | https://pypi.org/project/reticker/ |
Installation
Python ≥3.8 is required. To install, run:
pip install reticker
No additional third-party packages are required or installed.
Usage
Default usage
>>> import reticker
>>> extractor = reticker.TickerExtractor()
>>> type(extractor.pattern)
<class 're.Pattern'>
>>> extractor.extract("Has $GLD/IAU bottomed yet? What's the prospect for gold miners like $nugt? Maybe check gold futures MGC=F!")
['GLD', 'IAU', 'NUGT', 'MGC=F']
Customized usage
>>> import reticker
# Custom config:
>>> ticker_match_config = reticker.TickerMatchConfig(prefixed_uppercase=True, unprefixed_uppercase=False, prefixed_lowercase=False, prefixed_titlecase=False)
>>> extractor = reticker.TickerExtractor(deduplicate=False, match_config=ticker_match_config)
>>> extractor.extract("Which is better - $LTC or $ADA? $doge and ETH are already so high.")
['LTC', 'ADA']
# Separators:
>>> reticker.TickerExtractor(match_config=reticker.TickerMatchConfig(separators="-=")).extract("BTC-USD")
['BTC-USD']
>>> reticker.TickerExtractor(match_config=reticker.TickerMatchConfig(separators="")).extract("BTC-USD")
['BTC', 'USD']
# Blacklist:
>>> reticker.config.BLACKLIST.add("EUR")
>>> reticker.config.BLACKLIST.remove("I")
>>> reticker.TickerExtractor().extract("I see that EUR isn't a ticker, but URE is one.")
['I', 'URE']
# Mapping:
>>> reticker.config.MAPPING["BTC"] = "BTC-USD"
>>> reticker.TickerExtractor().extract("What is the Yahoo Finance symbol for BTC?")
['BTC-USD']
>>> reticker.config.MAPPING["COMP"] = ["COMP", "COMP-USD"]
>>> reticker.TickerExtractor().extract('Is COMP for the equity named "Compass" or for the crypto named "Compound"? I want both!')
['COMP', 'COMP-USD']
Metadata
Release files for reticker 3.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| reticker-3.1.6.tar.gz | 17.8 kB | Without provenance | Details for reticker-3.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| reticker-3.1.6-py3-none-any.whl | Python 3 | none | any | Details for reticker-3.1.6-py3-none-any.whl |
Total release size: 35.4 kB
Release files / reticker-3.1.6.tar.gz
| Download URL | reticker-3.1.6.tar.gz |
|---|---|
| Size | 17.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b23bc5bf98ad881312b19718b4c315a46c0881056c0d931876119125b1c86e7b
|
|
BLAKE2b-256 checksum How to use checksums |
a84f24ff5e1f962866af2048fee530ccf2435ced60113115472581001c7a5032
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Release files / reticker-3.1.6-py3-none-any.whl
| Download URL | reticker-3.1.6-py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0762751b6db53d0cb572ec1402a657dd6fd52cafb2d1fcd084fe7c211026ce70
|
|
BLAKE2b-256 checksum How to use checksums |
2181e5ebe921437165840f3ae93e6447a17d60c0d2cf4b4e2582055eb3f1e9b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|
Security for reticker 3.1.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.