finam-export
Python client library to download data from finam.ru
Capabilities
- Contracts lookup by market categories, id, code, name or their combinations using a rich set of mathching options
- Downloads data of any timeframe available on finam.ru ranging from ticks to monthly resolution
- Allows to download data for arbitrarily long intervals
Installation
pip install finam-export
Samples provided
samples/listing.py- simply lists some contracts from every supported marketsamples/download.py- downloads some data and prints it outsamples/lookups.py- shows how you can leverage lookup capabilities
Utility scripts
scripts/finam-download.py- feature-rich standalone script to download finam's datascripts/finam-lookup.py- to quickly check what's availble on finam
Show me something working!
Here's the output
*** Current Russian ruble exchange rates ***
INFO:finam.export:Fetching https://www.finam.ru/profile/moex-akcii/gazprom/export/
INFO:finam.export:Fetching https://www.finam.ru/cache/N72Hgd54/icharts/icharts.js
INFO:finam.export:Fetching http://export.finam.ru/table.csv?d=d&f=table&e=.csv&dtf=1&tmf=3&MSOR=0&mstime=on&mstimever=1&sep=3&sep2=1&at=1&p=8&em=182456&market=45&df=1&mf=0&yf=2007&dt=12&mt=8&yt=2020&cn=USD000000TOD&code=USD000000TOD&datf=5
<DATE> <TIME> <OPEN> <HIGH> <LOW> <CLOSE> <VOL>
2163 20200911 00:00:00 75.19 75.19 74.72 74.95 765709000
*** Current Brent Oil price ***
INFO:finam.export:Fetching http://export.finam.ru/table.csv?d=d&f=table&e=.csv&dtf=1&tmf=3&MSOR=0&mstime=on&mstimever=1&sep=3&sep2=1&at=1&p=8&em=19473&market=24&df=1&mf=0&yf=2007&dt=12&mt=8&yt=2020&cn=BZ&code=BZ&datf=5
<DATE> <TIME> <OPEN> <HIGH> <LOW> <CLOSE> <VOL>
4206 20200911 00:00:00 39.96 40.34 39.38 39.92 114897
and here's the code producing this output:
import logging
from finam import Exporter, Market, LookupComparator
"""
Full-on example displaying up-to-date values of some important indicators
"""
def main():
exporter = Exporter()
print('*** Current Russian ruble exchange rates ***')
rub = exporter.lookup(name='USDRUB_TOD', market=Market.CURRENCIES)
assert len(rub) == 1
data = exporter.download(rub.index[0], market=Market.CURRENCIES)
print(data.tail(1))
print('*** Current Brent Oil price ***')
oil = exporter.lookup(name='Brent', market=Market.COMMODITIES,
name_comparator=LookupComparator.EQUALS)
assert len(oil) == 1
data = exporter.download(oil.index[0], market=Market.COMMODITIES)
print(data.tail(1))
if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
main()
Playing samples
If you have cloned it from github:
pip install -r ./requirements.txt
PYTHONPATH=. ./samples/listing.py
Technical details
- Targeted to Linux/Mac
- Uses pandas inside, all data returned is pandas DataFrames
- Tested with python3.7+
- Good tests coverage
- Detailed logging of what's going on
Development
- clone the repo
pip install -r ./requirements.txt- run tests to ensure all is fine
nosetests- go ahead and enhance it!
- don't forget to cover your changes with tests
Metadata
Release files for finam-export 5.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| finam-export-5.1.1.tar.gz | 10.2 kB | Without provenance | Details |
Release files / finam-export-5.1.1.tar.gz
| Download URL | finam-export-5.1.1.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
283f31d66da329ae07f004cec2faf8edd9d84549144c45b812fb7edb74c6af02
|
|
BLAKE2b-256 checksum How to use checksums |
1dcd58f74679db07203d395657070da709c63b22e6cff1b0d72bac9a82a2be91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1
|
Security for finam-export 5.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.