Random stock quotes generator based on real data distribution
Project description
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)
"""
Fetching VALE3.sa ...
[*********************100%***********************] 1 of 1 completed
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.550003 19832500
[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)
"""
Fetching PETR4.sa ...
Fetching CSNA3.sa ...
Fetching USIM5.sa ...
Open High Low Close Volume
Date
0 1.200021 1.226008 1.196326 1.202129 5
1 1.031286 1.338619 0.969459 1.117780 13
2 1.318694 1.386048 1.054407 1.076145 29
3 1.161271 1.337793 0.985241 1.333848 61
4 1.397219 1.412562 1.391739 1.408030 125
... ... ... ... ... ...
3995 1.148051 1.161673 1.061298 1.124327 88315543
3996 1.226079 1.253347 1.194810 1.215101 77630090
3997 1.130570 1.137203 1.116103 1.130779 56259184
3998 1.041856 1.105484 0.924760 0.996029 13517372
3999 1.007603 1.008232 0.999234 1.000000 27034747
[4000 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
"""
"""
"""
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
Release history Release notifications | RSS feed
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.10.tar.gz
(4.0 kB
view details)
Built Distribution
File details
Details for the file rndqts-0.2101.10.tar.gz
.
File metadata
- Download URL: rndqts-0.2101.10.tar.gz
- Upload date:
- Size: 4.0 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a7d10d2def5e2a63673292bb2040103ec202e0f98ab4a4ca5fb3353767c4eb2 |
|
MD5 | 58162a822ca7215f17fca9fe1c49b696 |
|
BLAKE2b-256 | e6c062076ad8b773ea7e86a511adea714b40f96035019c4de4de62ced58823d9 |
File details
Details for the file rndqts-0.2101.10-py3-none-any.whl
.
File metadata
- Download URL: rndqts-0.2101.10-py3-none-any.whl
- Upload date:
- Size: 15.0 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fe8cb923ee198e9fd1f5300e3ed0c3f67bc0f54a0fee0be8c1ce1efcc019673 |
|
MD5 | ad31b750470aff2d2696b0adb7770396 |
|
BLAKE2b-256 | 5be8f603f9dc480c87721389b6abb48c7c4906089c7ad91a0b711f1f64a24922 |