reticker


Namereticker JSON
Version 3.1.6 PyPI version JSON
download
home_pagehttps://github.com/impredicative/reticker/
SummaryUse a regular expression to extract possible stock tickers from text
upload_time2022-12-20 13:58:57
maintainer
docs_urlNone
authorOuroboros Chrysopoeia
requires_python>=3.8
license
keywords regex regexp stock text ticker
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

[![cicd badge](https://github.com/impredicative/reticker/workflows/cicd/badge.svg?branch=master)](https://github.com/impredicative/reticker/actions?query=workflow%3Acicd+branch%3Amaster)

## Examples
```python
>>> 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
```python
>>> 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
```python
>>> 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']
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/impredicative/reticker/",
    "name": "reticker",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "regex regexp stock text ticker",
    "author": "Ouroboros Chrysopoeia",
    "author_email": "impredicative@users.noreply.github.com",
    "download_url": "https://files.pythonhosted.org/packages/a8/4f/24ff5e1f962866af2048fee530ccf2435ced60113115472581001c7a5032/reticker-3.1.6.tar.gz",
    "platform": null,
    "description": "# reticker\n**reticker** is a Python 3.8 package to extract what look like stock tickers from the given text.\nIt uses a configurably created regular expression. It does not however validate or use a whitelist of tickers.\n\n[![cicd badge](https://github.com/impredicative/reticker/workflows/cicd/badge.svg?branch=master)](https://github.com/impredicative/reticker/actions?query=workflow%3Acicd+branch%3Amaster)\n\n## Examples\n```python\n>>> import reticker\n\n>>> 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!\")\n[\"FNGU\", \"WEBL\", \"SOXL\", \"CLDL\", \"SKYU\", \"W\", \"Z\", \"V\", \"A\"]\n\n>>> 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.\")\n['BTC-USD', 'ETH-USD', 'ADA-USD', 'BRK.A', 'BRK.B', 'MGC=F', 'SIL=F']\n```\n\n## Features\n* 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.\n  At least one of the four must be enabled.\n* Two-part tickers are also matched using a customizable set of separator characters.  \n* The results are in the order they are first found.\n* By default, the results are deduplicated, although this can be disabled.\n* A configurable blacklist of common false-positives is used.\n* A configurable remapping of tickers is supported.\n* For lower level use, a configurably created compiled regular expression can be accessed.\n\n## Links\n| Caption   | Link                                               |\n|-----------|----------------------------------------------------|\n| Repo      | https://github.com/impredicative/reticker/         |\n| Changelog | https://github.com/impredicative/reticker/releases |\n| Package   | https://pypi.org/project/reticker/                 |\n\n## Installation\nPython \u22653.8 is required. To install, run:\n\n    pip install reticker\n\nNo additional third-party packages are required or installed.\n\n## Usage\n\n### Default usage\n```python\n>>> import reticker\n\n>>> extractor = reticker.TickerExtractor()\n>>> type(extractor.pattern)\n<class 're.Pattern'>\n\n>>> extractor.extract(\"Has $GLD/IAU bottomed yet? What's the prospect for gold miners like $nugt? Maybe check gold futures MGC=F!\")\n['GLD', 'IAU', 'NUGT', 'MGC=F']\n```\n\n### Customized usage\n```python\n>>> import reticker\n\n# Custom config:\n>>> ticker_match_config = reticker.TickerMatchConfig(prefixed_uppercase=True, unprefixed_uppercase=False, prefixed_lowercase=False, prefixed_titlecase=False)\n>>> extractor = reticker.TickerExtractor(deduplicate=False, match_config=ticker_match_config)\n>>> extractor.extract(\"Which is better - $LTC or $ADA? $doge and ETH are already so high.\")\n['LTC', 'ADA']\n\n# Separators:\n>>> reticker.TickerExtractor(match_config=reticker.TickerMatchConfig(separators=\"-=\")).extract(\"BTC-USD\")\n['BTC-USD']\n>>> reticker.TickerExtractor(match_config=reticker.TickerMatchConfig(separators=\"\")).extract(\"BTC-USD\")\n['BTC', 'USD']\n\n# Blacklist:\n>>> reticker.config.BLACKLIST.add(\"EUR\")\n>>> reticker.config.BLACKLIST.remove(\"I\")\n>>> reticker.TickerExtractor().extract(\"I see that EUR isn't a ticker, but URE is one.\")\n['I', 'URE']\n\n# Mapping:\n>>> reticker.config.MAPPING[\"BTC\"] = \"BTC-USD\"\n>>> reticker.TickerExtractor().extract(\"What is the Yahoo Finance symbol for BTC?\")\n['BTC-USD']\n>>> reticker.config.MAPPING[\"COMP\"] = [\"COMP\", \"COMP-USD\"]\n>>> reticker.TickerExtractor().extract('Is COMP for the equity named \"Compass\" or for the crypto named \"Compound\"? I want both!')\n['COMP', 'COMP-USD']\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Use a regular expression to extract possible stock tickers from text",
    "version": "3.1.6",
    "split_keywords": [
        "regex",
        "regexp",
        "stock",
        "text",
        "ticker"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "d36e071915f0d24b9aa3a33b2ce65767",
                "sha256": "0762751b6db53d0cb572ec1402a657dd6fd52cafb2d1fcd084fe7c211026ce70"
            },
            "downloads": -1,
            "filename": "reticker-3.1.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d36e071915f0d24b9aa3a33b2ce65767",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 17631,
            "upload_time": "2022-12-20T13:58:56",
            "upload_time_iso_8601": "2022-12-20T13:58:56.662130Z",
            "url": "https://files.pythonhosted.org/packages/21/81/e5ebe921437165840f3ae93e6447a17d60c0d2cf4b4e2582055eb3f1e9b4/reticker-3.1.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "16c612fb47779ef57062d0c6aae7d8c4",
                "sha256": "b23bc5bf98ad881312b19718b4c315a46c0881056c0d931876119125b1c86e7b"
            },
            "downloads": -1,
            "filename": "reticker-3.1.6.tar.gz",
            "has_sig": false,
            "md5_digest": "16c612fb47779ef57062d0c6aae7d8c4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 17767,
            "upload_time": "2022-12-20T13:58:57",
            "upload_time_iso_8601": "2022-12-20T13:58:57.952612Z",
            "url": "https://files.pythonhosted.org/packages/a8/4f/24ff5e1f962866af2048fee530ccf2435ced60113115472581001c7a5032/reticker-3.1.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-20 13:58:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "impredicative",
    "github_project": "reticker",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "reticker"
}
        
Elapsed time: 0.33198s