Unoffical Python API for Sharesies NZ
pip install git+ssh://git@github.com/jontymorris/Sharesies-API.git
import sharesies
client = sharesies.Client()
if client.login('you@example.com', 'password123'):
print('Login succeeded')
else:
print('Login failed')
profile = client.get_profile()
user_id = profile['user']['id']
portfolio = profile['portfolio']
companies = client.get_companies()
if client.buy(companies[0], 10):
print('Bought $10 worth of shares')
else:
print('Something went wrong')
companies = client.get_companies()
if client.sell(companies[0], 1):
print('Sold 1 share')
else:
print('Something went wrong')
companies = client.get_companies()
client.get_price_history(companies[0])
{
"2014-06-25": "1.110000",
"2014-06-30": "1.050000",
"2014-07-07": "1.050000",
"2014-07-10": "1.100000",
...
}
# get your portfolio
profile = client.get_profile()
portfolio = profile['portfolio']
# loop through your portfolio
for item in portfolio:
fund_id = item['fund_id']
order_history = client.get_order_history(fund_id)
'''
each item has:
type: buy/sell
contribution: amount buy/sold
order_unit_price: price at time
created: Unix timestamp
'''
To setup a development environment you can install the package in development mode.
git clone https://github.com/jontymorris/Sharesies-API.git
cd Sharesies-API
python3 -m pip install -e .