Skip to main content

Random stock quotes generator based on real data distribution

Project description

test codecov

rndqts

Random stock market quotes

Latest version

Installation

as a standalone lib.

# Set up a virtualenv. 
python3 -m venv venv
source venv/bin/activate

# Install from PyPI...
pip install rndqts

# ...or, install from updated source code.
pip install git+https://github.com/davips/rndqts

as an editable lib inside your project.

cd your-project
source venv/bin/activate
git clone https://github.com/davips/rndqts ../rndqts
pip install -e ../rndqts

Examples

Fetching from Yahoo

from rndqts.quotes import Quotes

print(Quotes("VALE3.sa").data)
"""
                  Open        High        Low       Close    Volume
Date                                                               
2000-01-03    2.175114    2.201526   2.175114    2.175114    585600
2000-01-04    2.154401    2.159062   2.123328    2.123328    782400
2000-01-05    2.097431    2.123328   2.097431    2.123328   1876800
2000-01-06    2.123328    2.175114   2.123328    2.123328    792000
2000-01-07    2.149217    2.211886   2.149217    2.201010   5347200
...                ...         ...        ...         ...       ...
2021-01-06   94.980003   96.349998  94.400002   96.050003  53722500
2021-01-07   96.610001  102.529999  96.610001  102.320000  74541400
2021-01-08  103.010002  103.349998  98.199997  101.260002  43879400
2021-01-11  100.250000  101.959999  99.699997  101.800003  18259400
2021-01-12  102.500000  102.620003  99.180000   99.540001  24770000

[5259 rows x 5 columns]

"""

Random stock quotes

from rndqts.quotes import Quotes

# Caching real quotes from Yahoo.
Quotes("PETR4.sa", progress=False).data
Quotes("VALE3.sa", progress=False).data
Quotes("CSNA3.sa", progress=False).data
Quotes("USIM5.sa", progress=False).data

# Generating random quotes.
print(Quotes("rnd", seed=42).data)
"""
           Open      High       Low     Close    Volume
Date                                                   
0      1.006622  1.030463  0.997351  1.001324         3
1      1.002955  1.024479  0.990693  1.020405         9
2      1.041271  1.076896  1.036691  1.062901        11
3      1.069317  1.082148  1.056485  1.073594        13
4      1.060106  1.107408  1.049558  1.095902        29
...         ...       ...       ...       ...       ...
45785  0.796538  0.829050  0.796538  0.821401  31357368
45786  0.986282  1.018537  0.969475  1.001639  62714739
45787  0.997002  1.040349  0.993323  1.031381  74688614
45788  1.040943  1.048913  0.988340  0.996310  50376232
45789  1.003717  1.022727  0.996310  1.000000   1751468

[45790 rows x 5 columns]

"""
"""

"""

Saving as a CSV file

from rndqts.quotes import Quotes

Quotes("VALE3.sa").data.to_csv("/tmp/myfile.csv")


"""

"""

Plotting

from rndqts.quotes import Quotes

Quotes("VALE3.sa")[1000:1060].plot()
"""
Fetching VALE3.sa ...
[*********************100%***********************]  1 of 1 completed
"""

"""

"""

Output as a browser window

Features / TODO

  • Fetch from yahoo

  • Automatic local caching

  • Slicing

  • Plot candle sticks

  • Realistic random quotes

    • Ticker 'pseudo' generates (not so realistic) data without real quotes dependence (good for tests)
  • Separate classes: Real, Random, Pseudo

    • Cacheable and identified by hash of args

    • Real (market quotes)

      • Args: ticker, start/end dates, slice1
        • Default dates interval: 2020-01-01 - 2020-12-31
    • Random (realistic random quotes, .i.e, it is based on real quotes)

      • Args: rndqts objects, seed, slice1
    • Pseudo (pseudo random quotes)

      • Args: seed, slice1
      • Lazy
  • News fetching

1Slicing is intended to be done via squared brackets syntax, e.g., quotes[3:40], not directly.

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

rndqts-0.2101.13.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

rndqts-0.2101.13-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file rndqts-0.2101.13.tar.gz.

File metadata

  • Download URL: rndqts-0.2101.13.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for rndqts-0.2101.13.tar.gz
Algorithm Hash digest
SHA256 161f1b1830307a182255e21feb738c4ca82bd5ab00ed8e155b3ed5bf14658591
MD5 0da1b9a73d7eb3584c10fc21dc7ecf0f
BLAKE2b-256 eb9b9d4fcf03b400e65002c0681e69145a47251ae3f7648bbfc321dcb532a55d

See more details on using hashes here.

File details

Details for the file rndqts-0.2101.13-py3-none-any.whl.

File metadata

  • Download URL: rndqts-0.2101.13-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.1

File hashes

Hashes for rndqts-0.2101.13-py3-none-any.whl
Algorithm Hash digest
SHA256 11500b3f7dc0dae09c557981872dd507de5e05cb1815cf4d7d52b106d02b8874
MD5 c9ab1fae360119ff71a8e1eff9eea4ab
BLAKE2b-256 fa39b830104b9a3f6e38e830dedd50c09b23e9321560fd30b27025dbf6178854

See more details on using hashes here.

Supported by

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