Skip to main content

read and write daily stock data

Project description

This is for reading and writing stock data

Data storage

-path
--files
    filename_20180102.csv
    filename_20180103.csv
    .
    .
    .
    filename_20181231.csv

This new version package (still under construction) would also support data stored like below

-path
--files
    filename_A.csv
    filename_B.csv
    .
    .
    .

Read csv with different structures

  • example1

ticker1,value1
ticker2,value2
ticker3,value3
ticker4,value4

to read this type of csv file, use

read_df(path='path',file_pattern='filename')
  • example2

stkid,open,high,low,close
ticker1,o1,h1,l1,c1
ticker2,o2,h2,l2,c2
ticker3,o3,h3,l3,c3

to read open, use

Open=read_df(path='path',file_pattern='filename',dat_col='open')

to read open and close, use

Open,Close=read_df(path='path',file_pattern='filename',dat_col=['open','close'])

to return a multi index dataframe, use

Price=read_mdf(path='path',file_pattern='filename',dat_col=['open','close'])

Write

  • dataframe example

            ticker1     ticker2     ticker3
20180101     10.32       20.22        12.35
20180102      NaN        20.10        13.31
20180105      NaN        20.10        12.12

use write_df to write data of each date to one csv file

  • dictionary example

each value in the dictionary should be a dataframe and be like the example showed above

write_factors(path='path',file_pattern='filename',**dictionary)

Notice

Default reading trading calendar is Chinese market trading calendar, to change the calendar use dt_range option to input all dates.

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

RNWS-0.2.1.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

RNWS-0.2.1-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file RNWS-0.2.1.tar.gz.

File metadata

  • Download URL: RNWS-0.2.1.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.14.2 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.5.5

File hashes

Hashes for RNWS-0.2.1.tar.gz
Algorithm Hash digest
SHA256 c25268a8d004dc67f636a5c0f2c495b0ed6f0b88b421b45396998aa1800ae4c3
MD5 fc7e1634a3e2696524f86bff701741c5
BLAKE2b-256 652e3478c644194e5604525f1ad5ad8395a04a73e7285a149418c1cd9ae7d38e

See more details on using hashes here.

File details

Details for the file RNWS-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: RNWS-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.14.2 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.5.5

File hashes

Hashes for RNWS-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3516c3f82499eb093da358db592cedee828872a1fd62f9cef5f28a365da31284
MD5 2d13de9cf3a561248b1a687800ccf4ff
BLAKE2b-256 a0ebd17504508718c4f5e100314d1a285911929e421adc724d02a58152cb5167

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