Skip to content

A module which helps you deal with your investment homework easily.

License

Notifications You must be signed in to change notification settings

tommyxu97/Investment-PythonModule

Repository files navigation

Investment-Python Module

Build Status

A Python Module which helps you deal with your investment homework with ease. You can use this module to build your asset portfolio by index model or Markowitz model.

Setup

Now the code has not been uploaded to pip. So please download it and add to your project's root directory. Later you can get it easier with pip:

# pip install investment (This is not avaible now)

Dependence

This module is developed under Python 3.6.1, so it may not work with Python 2.X.

The four modules that mainly used in Investment are:

  • Tushare
  • Pandas
  • Numpy
  • Matplotlib and Sklearn(Till now this module isn't being used)

Usage

Download the Investment.py in this repo and put it in you root directory.

Import

Import this module with the following code in your python:

import investment as iv

Func __init__()

If you want use this module, the very first thing you should do is to initialize a object with function __init__. You can do this with the following code:

stock_list = []
ratio_input = []
start_input = '2017-05-01'
end_input = '2017-06-15'
stock_model = iv.assetPortfolio(stock_list, ratio_input, start_input, end_input)

Note: stock_input is a string list of stock code, you can input it like this: ['000001', '600237']; ratio_input is a float list like [0.25, 0.21]. start_input (and end_input) is a str varible like '2017-05-23'

Func allocate()

Allocate money to your portfolio(It will allocate by the ratio you input or that generated by the model in this module):

total_money_input = 1000
# This variable can be int or float
stock_model.allocate(total_money_input)

Func profile()

Get the profile by your portfolio:

stock_model.profile()

Note: The profile given by the program won't be the percentage.

Func data_to_csv()

This function allows you to out put the data file to your disk, you can use it like this:

path = '/Users/xuhaotian/Documents/data.csv'
# The expression of path may be different under different operating systems. 
# And don't forget to add the filename 'x.csv' at the end of your path.
stock_model.data_to_csv(path)

Documents of other functions will be added.

Author

TommyXu

HomeSite Blog

Email:i@xht97.cn

logo

What's More

If you have more ideas about this module, please feel free to leave a message in the issuse block, or directly send an email to me!

About

A module which helps you deal with your investment homework easily.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages