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 --upgrade pip
pip install -U 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 --upgrade pip
pip install -e ../rndqts

Examples

Fetching from Yahoo

from rndqts import Real

print(Real("VALE3.sa").data)
"""
Fetching VALE3.sa ...

[*********************100%***********************]  1 of 1 completed
                  Open        High        Low       Close    Volume
Date                                                               
2021-01-04   89.349998   91.480003  88.849998   91.459999  37865500
2021-01-05   91.459999   93.000000  90.519997   93.000000  34300300
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.980003  99.699997  101.980003  29267000
2021-01-12  102.500000  102.620003  99.180000   99.190002  28598500
2021-01-13   98.870003   98.919998  95.739998   96.220001  31658800
2021-01-14   97.220001   98.860001  96.699997   97.800003  20809900
2021-01-15   96.580002   97.199997  93.199997   93.550003  31712400
"""

Random stock quotes

from rndqts import Realistic
from rndqts import Real

# Real quotes to fetch from Yahoo.
r1 = Real("PETR4.sa")
r2 = Real("CSNA3.sa")
r3 = Real("VALE3.sa")
r4 = Real("USIM5.sa")

# Generating random quotes.
print(Realistic([r1, r2, r3, r4]).data)
"""
Fetching PETR4.sa ...

[*********************100%***********************]  1 of 1 completed
Fetching CSNA3.sa ...

[*********************100%***********************]  1 of 1 completed
Fetching USIM5.sa ...

[*********************100%***********************]  1 of 1 completed
        Open    High     Low   Close  Volume
Date                                        
0      98.26   99.28   91.50   91.90   12499
1      90.76   93.85   90.24   90.26   13400
2      89.66   94.05   89.36   91.20   16749
3      90.48   93.31   89.88   90.86   13468
4      90.00   95.08   88.92   92.01   15087
...      ...     ...     ...     ...     ...
67    116.65  121.32  115.36  119.70     799
68    119.63  121.19  112.72  116.76     395
69    115.84  116.76  109.17  111.38     307
70    110.73  110.73  104.34  104.55     222
71    103.25  103.91   99.63  100.01     278

[72 rows x 5 columns]
"""

Saving as a CSV file

from rndqts import Real

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

Plotting

from rndqts import Real

Real("VALE3.sa").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)
  • Distinct kinds of quotes: Real, Realistic random, Synthetic Random

    • Cacheable and identified by hash of args

    • Real (market quotes)

    • Realistic (realistic random quotes, .i.e, it is based on real quotes)

    • Synthetic (quotes based interily on Gaussian distributions from pseudo random number generator)

      • Lazy/Infinite
  • News fetching

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.27.tar.gz (12.8 kB view hashes)

Uploaded Source

Built Distribution

rndqts-0.2101.27-py3-none-any.whl (29.8 kB view hashes)

Uploaded Python 3

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