Skip to main content

A python library for the marketstack API

Project description

Pymarketstack

Pymarket is a simple python library for the Marketstack API. It’s a requirement to have a valid API token, the free version or a payed alternative, see Pricing. Needless to say, this is not an official library.

Available features

The different features marketstack supports can be found on marketstack’s documentation.

End of Data

Gets the stock data after the market has closed. Supports 3 alternatives:

  • All: Downloads all data.
  • Latest: Downloads the data corresponding to the last date.
  • Date: Downloads a specific range of data.

Intraday data

Not yet implemented.

Splits data

Not yet implemented.

Dividends data

Not yet implemented.

Tickers

Not yet implemented.

Exchanges

Not yet implemented.

Currencies

Not yet implemented.

Timezones

Not yet implemented.

Usage

query = EndOfDay.query(token="your api token")
data, failed = download(query, "AAPL", "XEL", ...)

Here the first line will just create a request URL with the appropirate fields, the download function will return a tuple with a Response object and a list of strings corresponding to failed tickers. The query function has several options such as the usage of HTTPS, etc.

An end of data request will return 2 things, a pagination object and a list of data objects. These are defined in responses.py alongside a Response object that wraps both of these. Namely

Responses

class Response:
    pagination: Pagination
    data: List[Data]

The data field is overall the most interesting one and contains a single date of data for each ticker. The fields include things like date, symbol, open, close, high, low, among others. All of the fields are listed in the documentation.

In case of an error the library will raise a corresponding exception, these are defined in exceptions.py and corresponds to the common API error codes.

An example API reponse could be:

{
    "pagination": {
        "limit": 100,
        "offset": 0,
        "count": 100,
        "total": 9944
    },
    "data": [
        {
            "open": 129.8,
            "high": 133.04,
            "low": 129.47,
            "close": 132.995,
            "volume": 106686703.0,
            "adj_high": 133.04,
            "adj_low": 129.47,
            "adj_close": 132.995,
            "adj_open": 129.8,
            "adj_volume": 106686703.0,
            "split_factor": 1.0,
            "dividend": 0.0,
            "symbol": "AAPL",
            "exchange": "XNAS",
            "date": "2021-04-09T00:00:00+0000"
            },
            [...]
    ]
}

which would be equivalent to

Response(
    pagination = Pagination(limit=100, offset=0, count=100, total=9944),
    data = [
        Data(
            open=129.8,
            high=133.04,
            low=129.47,
            close=132.995,
            volume=106686703.0,
            adj_high=133.04,
            adj_low=129.47,
            adj_close=132.995,
            adj_open=129.8,
            adj_volume=106686703.0,
            split_factor=1.0,
            dividend=0.0,
            symbol="AAPL",
            exchange="XNAS",
            date=datetime.datetime(2021, 4, 29)
        ),
        ...
    ]
)

due to the usage of dataclasses-json, Response, Pagination, and Data are serializable to/from dicts and json strings.

Dependencies

The depenencies used are listed in the requirements.txt package file but the main ones are:

License

Apache 2.0, see the LICENSE file for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymarketstack-0.0.2.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymarketstack-0.0.2-py3-none-any.whl (11.6 kB view details)

Uploaded Python 3

File details

Details for the file pymarketstack-0.0.2.tar.gz.

File metadata

  • Download URL: pymarketstack-0.0.2.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for pymarketstack-0.0.2.tar.gz
Algorithm Hash digest
SHA256 ae9e23bbddd7a89162171c5c7c756abf8e9b778128a21613d369c4cea551b9a6
MD5 77142b1d96b41d88e972cfd3aee356f0
BLAKE2b-256 9b38419a880b0f9fee1d69f2a799916792768ab3cd83c6ef93fba3af1d6a3c26

See more details on using hashes here.

File details

Details for the file pymarketstack-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pymarketstack-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for pymarketstack-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a294d66443dfdb1e42caf926843806f2e7b08fb90ab2565d80a542b44f1c7dd2
MD5 0a33aa7a3ce570f8a6ef24508c979ff6
BLAKE2b-256 1fcd84f9958d653d369d301cd04a9bd12842844f18d597c07ca0aa396d0c0d93

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page