Skip to main content

Random stock quotes generator based on real data distribution

Project description

test codecov

rndqts

Random stock market quotes

Installation

from package

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

# Install from PyPI
pip install rndqts

from source

cd my-project
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.330002   99.599998  17608800

[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      0.992071  1.012590  0.974892  0.985990         3
1      1.280855  1.315453  1.028866  1.187199         9
2      1.202997  1.202997  1.160224  1.166542        11
3      1.171458  1.171458  1.153635  1.165728        25
4      1.168232  1.179163  1.162539  1.165955        27
...         ...       ...       ...       ...       ...
34073  1.082212  1.082212  1.054314  1.058348  90423759
34074  1.050895  1.067432  1.050895  1.060755  90423761
34075  1.064736  1.064736  1.035878  1.035878  90423763
34076  1.031813  1.031813  0.984578  0.989224  81846530
34077  1.000000  1.000000  1.000000  1.000000  81846532

[34078 rows x 5 columns]

"""
"""

"""

Saving as a CSV file

from rndqts.quotes import Quotes

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


"""

"""

Fetching from Yahoo

from rndqts.quotes import Quotes

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

"""

"""

![Output as a browser window.](examples/plotvale3.png?raw=true)

Features / TODO

  • Fetch from yahoo
  • Automatic local caching
  • Slicing
  • Plot candle sticks
  • Random quotes * [x] Ticker 'pseudo' is an option to generate data without real quotes dependence (good for tests) * [ ] Explicit real quotes to sample from ('rnd-MSFT,APPL') * [ ] 'n' argument fecthes lazily within date interval

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.9.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

rndqts-0.2101.9-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: rndqts-0.2101.9.tar.gz
  • Upload date:
  • Size: 3.9 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.9.tar.gz
Algorithm Hash digest
SHA256 d9653f967ffabd2b1abb409c49c17fc8237859084acca60d84e6e6a498d5f9da
MD5 47f936baac7e49bf3d4cdb3188456b74
BLAKE2b-256 fc03ba5352f835562f2bf1ccb54785fa50a073fad70df33e2edf3beb85020f1b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: rndqts-0.2101.9-py3-none-any.whl
  • Upload date:
  • Size: 14.9 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.9-py3-none-any.whl
Algorithm Hash digest
SHA256 8076199087dcc4ff4b19370a671d32f78f4fa14bd3fae35999140b44c7d6cabb
MD5 0978a25c5bb8cab2d871920274b079c8
BLAKE2b-256 61609a965aec6258859b1cdf3e1d328edb3b931943340d17eab38e9a92585584

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