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.

Files for RNWS, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size RNWS-0.2.1-py3-none-any.whl (17.9 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size RNWS-0.2.1.tar.gz (16.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page