-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.md.jinja2
175 lines (126 loc) · 5.44 KB
/
README.md.jinja2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# Prosper API client for Python
Python trading library for Prosper.com
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/grahamtt/prosper-api/build-and-release.yml?logo=github)](https://github.com/grahamtt/prosper-api)
[![PyPI - Version](https://img.shields.io/pypi/v/prosper-api?label=prosper-api)](https://pypi.org/project/prosper-api/)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/prosper-api)
![PyPI - License](https://img.shields.io/pypi/l/prosper-api)
[![Code Climate coverage](https://img.shields.io/codeclimate/coverage/grahamtt/prosper-api?logo=codeclimate)](https://codeclimate.com/github/grahamtt/prosper-api)
[![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability-percentage/grahamtt/prosper-api?logo=codeclimate)](https://codeclimate.com/github/grahamtt/prosper-api)
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8063/badge)](https://www.bestpractices.dev/projects/8063)
![GitHub commit activity (branch)](https://img.shields.io/github/commit-activity/m/grahamtt/prosper-api?logo=github)
![GitHub issues](https://img.shields.io/github/issues-raw/grahamtt/prosper-api?logo=github)
## Installation
### With Pip
```bash
pip install prosper-api
```
#### Optional `keyring` support
```bash
pip install 'prosper-api[secure]'
```
### With Poetry
```bash
poetry add prosper-api
```
#### Optional `keyring` support
```bash
poetry add 'prosper-api[secure]'
```
## Setup
> ℹ️ The library currently only supports personal use, where the client id and credentials are from the same account. Support
> for multi-account mode is [planned](https://github.com/grahamtt/prosper-api/issues/3).
### Config file location
- Linux/Unix: `$HOME/.config/prosper-api/config.toml`
- Windows: `%HOMEDIR%%HOMEPATH\AppData\Local\prosper-api\prosper-api\config.toml`
- MacOs: `$HOME/Library/Application Support/prosper-api/config.toml`
### Default
Create a config file with the following contents:
```toml
[credentials]
client-id = "0123456789abcdef0123456789abcdef"
client-secret = "fedcba9876543210fedcba9876543210"
username = "PROBABLY_YOUR_EMAIL_ADDRESS"
password = "AWESOME_PASSWORD"
```
### More secure
> ℹ️ You must have installed `keyring` or used the '\[secure\]' mode when installing the library.
Remove the `client-secret` and `password` portions of the config:
```toml
[credentials]
client-id = "0123456789abcdef0123456789abcdef"
username = "PROBABLY_YOUR_EMAIL_ADDRESS"
```
Run the following to store your credentials securely in your OS credentials storage, e.g. Keychain for MacOS, etc.
For each command, you will be prompted to enter the corresponding secret. For 'CLIENT_ID', enter the client secret. For
'USERNAME' enter the corresponding password.
```bash
keyring set prosper-api '{CLIENT_ID}'
keyring set prosper-api '{USERNAME}'
```
## Use
See [a sample bot](https://github.com/grahamtt/prosper-auto-invest) for concrete usage.
### Get account details
The following will get the details of your account, including available cash and investment allocations.
```python
from prosper_api.client import Client
from prosper_api.models import Account
client = Client()
account: Account = client.get_account_info()
```
### Search listings
The following will get all the current listings you haven't invested in.
```python
from prosper_api.client import Client
from prosper_api.models import Listing, SearchListingsRequest, SearchListingsResponse
from typing import List
PAGE_SIZE=25
client = Client()
listings: List[Listing] = []
offset = 0
while True:
result: SearchListingsResponse = client.search_listings(SearchListingsRequest(invested=False, biddable=True, limit=PAGE_SIZE, offset=offset))
listings += result.result
offset += PAGE_SIZE
if len(listings) >= result.total_count or len(result.result) < PAGE_SIZE:
break
```
> ℹ️ The full set of filters listed in the [Prosper API docs](https://developers.prosper.com/docs/investor/listings-api/)
> are available
### Place order
The following will place an order, given a listing id.
```python
from prosper_api.client import Client
from prosper_api.models import Order
client = Client()
listing_id: int = 12341234
order_dollar_amount: float = 25
order_result: Order = client.order(listing_id, order_dollar_amount)
```
### List notes
The following will list all the notes in your account. The same pattern can be used to list orders, loans, and payments.
```python
from prosper_api.client import Client
from prosper_api.models import Note, ListNotesRequest, ListNotesResponse
from typing import List
client = Client()
notes: List[Note] = []
PAGE_SIZE = 25
offset = 0
while True:
result: ListNotesResponse = client.list_notes(ListNotesRequest(limit=PAGE_SIZE, offset=offset, sort_by="age_in_months", sort_dir="asc"))
notes += result.result
offset += PAGE_SIZE
if len(notes) >= result.total_count or len(result.result) < PAGE_SIZE:
break
```
## Configuration
Available config values:
```yaml
{{config_options}}
```
## Feedback
This project uses [GitHub issues](https://github.com/grahamtt/prosper-api/issues) for feature requests and bug reports.
## Contributing
This project uses [Poetry](https://python-poetry.org/docs/) to manage dependencies and building. Follow the instructions
to install it. Then use `poetry install --all-extras` to install the project dependencies. Then run `poetry run autohooks activate`
to set up the pre-commit hooks. Please ensure the hooks pass before submitting a pull request.