Skip to content

Commit c964200

Browse files
authored
Merge pull request #194 from s4w3d0ff/dev
v0.5
2 parents 1a00f43 + ca033e3 commit c964200

File tree

15 files changed

+571
-658
lines changed

15 files changed

+571
-658
lines changed

.travis.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
language: python
22
python:
33
- '2.7'
4-
- '3.3'
5-
- '3.4'
64
- '3.5'
75
- '3.6'
86
install: python setup.py install
97
script: python test.py
8+
deploy:
9+
provider: pypi
10+
user: s4w3d0ff
11+
password:
12+
secure: "wQaQITU9IZBpBkspCPof2W7qDXQkQdMfSmkhdzCqaHEYxdXcIOBekVmG+yME912Hh6UUuDi58Uz55sXo5fe4UctV91kzrbq5VpcaQ7ko+Q7TizZ6EMiHKvaX2570EEKdVkG7iz65Mg0TMPtAHR3xOKNBCFhI7sy85ixYPsHEEHr64gm8Ygtv2nfgQ2ptD0tp7+dORuaxSyYZckb6glsde81T9+9AO/4L08D13pquy1GtEp1PkUGnr/lLXqo6Pbz4/mwURkw30KmgIxGgZUmgOtBp2SyIGpWmcfL7opYlCPwI3fbNkAYBt1pF8aDRN5SxbaGK/I3+bHJrYZtQEZ9HUFkrdte9DxJMuzXU+eIskMkone+gtGMTvkQd614/rWP0IHiRhE+oQHeuNqIC0g015ocTqA8+V74CiGETGDonVfRcyCDdne6rPbVX/lmFoD0kIUb7rJuhsX3Lk8GFkYkUTzphqT6I33aLP66IbOfyve0MeFXVntfsZ8ZiS6kd+aTYgIw6cVIT4LVG4i6Jwjm2/LZN7CqvWHI2RQ15pV9OehXEK1otWFh5FRKy3331kAKGnWNQRbuOvpNnNGMsS/niXL/wALd5hPQuzAALk5XgShoKsN3LwacLaWAm1ZtCcBeKsiQIDU9h0QOyUlbYCeNGV5V7K92ft7EhERZxR5BRzoE="
13+
on:
14+
tags: true
15+
skip_existing: true

README.md

Lines changed: 89 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,117 @@
1-
[![python](https://img.shields.io/badge/python-2.7%20%26%203-blue.svg)![licence](https://img.shields.io/badge/licence-GPL%20v2-blue.svg)](https://github.com/s4w3d0ff/python-poloniex/blob/master/LICENSE) [![release](https://img.shields.io/github/release/s4w3d0ff/python-poloniex.svg)![release build](https://travis-ci.org/s4w3d0ff/python-poloniex.svg?branch=v0.4.7)](https://github.com/s4w3d0ff/python-poloniex/releases)
1+
[![python](https://img.shields.io/badge/python-2.7%20%26%203-blue.svg)![licence](https://img.shields.io/badge/licence-GPL%20v2-blue.svg)](https://github.com/s4w3d0ff/python-poloniex/blob/master/LICENSE) [![release](https://img.shields.io/github/release/s4w3d0ff/python-poloniex.svg)![release build](https://travis-ci.org/s4w3d0ff/python-poloniex.svg?branch=v0.5.4)](https://github.com/s4w3d0ff/python-poloniex/releases)
22
[![master](https://img.shields.io/badge/branch-master-blue.svg)![master build](https://api.travis-ci.org/s4w3d0ff/python-poloniex.svg?branch=master)](https://github.com/s4w3d0ff/python-poloniex/tree/master) [![dev](https://img.shields.io/badge/branch-dev-blue.svg)![dev build](https://api.travis-ci.org/s4w3d0ff/python-poloniex.svg?branch=dev)](https://github.com/s4w3d0ff/python-poloniex/tree/dev)
33
Inspired by [this](http://pastebin.com/8fBVpjaj) wrapper written by 'oipminer'
4-
> I (s4w3d0ff) am not affiliated with, nor paid by [Poloniex](https://poloniex.com). I have been an active trader there since 2014 and love python. I found the linked python wrapper on the poloniex support page to be incomplete and buggy so I decided to write this wrapper and create this git repository. If you wish to contribute to this repository please read [CONTRIBUTING.md](https://github.com/s4w3d0ff/python-poloniex/blob/master/CONTRIBUTING.md). All and any help is appreciated.
5-
## Install latest release:
6-
Python 2:
7-
```
8-
pip install https://github.com/s4w3d0ff/python-poloniex/archive/v0.4.7.zip
9-
```
4+
> I (s4w3d0ff) am not affiliated with, nor paid by [Poloniex](https://poloniex.com). I found the linked python wrapper on the poloniex support page to be incomplete and buggy so I decided to write this wrapper and create a git repository. If you wish to contribute to the repository please read [CONTRIBUTING.md](https://github.com/s4w3d0ff/python-poloniex/blob/master/CONTRIBUTING.md). All and any help is appreciated.
5+
#### Features:
6+
- [x] Python 2.7 and 3.5+
7+
- [x] Pypi
8+
- [x] Travis
9+
- [x] Websocket api support
10+
- [x] Minimal amount of dependencies
11+
- [x] Internal checks to reduce external api errors
12+
- [x] Rate limiter to keep from going over call limits
13+
- [x] Retries failed api calls during connection issues
1014

11-
Python 3:
15+
### Install:
1216
```
13-
pip3 install https://github.com/s4w3d0ff/python-poloniex/archive/v0.4.7.zip
17+
pip install --upgrade poloniexapi
1418
```
1519

16-
## Usage:
20+
### Usage:
1721
See the [wiki](https://github.com/s4w3d0ff/python-poloniex/wiki) or `help(poloniex)` for more.
18-
#### Basic Public Setup (no api Key/Secret):
22+
23+
All api calls are done through an instance of `poloniex.Poloniex`. You can use the instance as follows:
1924
```python
25+
# import this package
2026
from poloniex import Poloniex
27+
# make an instance of poloniex.Poloniex
2128
polo = Poloniex()
29+
# show the ticker
30+
print(polo('returnTicker'))
2231
```
23-
Ticker
32+
Using the instances `__call__` method (shown above) you can pass the command string as the first argument to make an api call. The `poloniex.Poloniex` class also has 'helper' methods for each command that will help 'sanitize' the commands arguments. For example, `Poloniex.returnChartData('USDT_BTC', period=777)` will raise `PoloniexError("777 invalid candle period")`.
33+
2434
```python
25-
print(polo('returnTicker')['BTC_ETH'])
26-
# or
27-
print(polo.returnTicker()['BTC_ETH'])
28-
```
29-
**Public** trade history:
30-
```python
31-
print(polo.marketTradeHist('BTC_ETH'))
35+
# using a 'helper' method
36+
print(polo.returnChartData(currencyPair='BTC_LTC', period=900))
37+
# bypassing 'helper'
38+
print(polo(command='returnChartData', args={'currencyPair': 'BTC_LTC',
39+
'period': 900}))
3240
```
41+
Almost every api command can be called this way. This wrapper also checks that the command you pass to the `command` arg is a valid command to send to poloniex, this helps reduce api errors due to typos.
42+
43+
#### Private Commands:
44+
To use the private api commands you first need an api key and secret (supplied by poloniex). When creating the instance of `poloniex.Poloniex` you can pass your api key and secret to the object like so:
3345

34-
#### Basic Private Setup (Api key/secret required):
3546
```python
3647
import poloniex
37-
polo = poloniex.Poloniex('your-Api-Key-Here-xxxx','yourSecretKeyHere123456789')
38-
# or
48+
polo = poloniex.Poloniex(key='your-Api-Key-Here-xxxx', secret='yourSecretKeyHere123456789')
49+
# or this works
3950
polo.key = 'your-Api-Key-Here-xxxx'
4051
polo.secret = 'yourSecretKeyHere123456789'
41-
```
42-
Get all your balances
43-
```python
52+
# get your balances
4453
balance = polo.returnBalances()
4554
print("I have %s ETH!" % balance['ETH'])
4655
# or
4756
balance = polo('returnBalances')
4857
print("I have %s BTC!" % balance['BTC'])
4958
```
59+
#### Trade History:
60+
Poloniex has two api commands with the same name `returnTradeHistory`. To work around this without splitting up the commands or having to specify 'public' or 'private' we use the helper method `Poloniex.marketTradeHist` for public trade history and `Poloniex.returnTradeHistory` for private trades. If you try to bypass the helper method using `Poloniex.__call__`, it will call the private command.
61+
62+
**Public** trade history:
63+
```python
64+
print(polo.marketTradeHist('BTC_ETH'))
65+
```
5066
**Private** trade history:
5167
```python
5268
print(polo.returnTradeHistory('BTC_ETH'))
5369
```
54-
**Examples of WAMP applications using the websocket push API can be found [here](https://github.com/s4w3d0ff/python-poloniex/tree/master/examples).**
70+
71+
#### Websocket Usage:
72+
Right now, the easiest way to use the websocket api is making a child class like so:
73+
```python
74+
import logging
75+
76+
logging.basicConfig()
77+
78+
class MySocket(poloniex.Poloniex):
79+
80+
def on_heartbeat(self, msg):
81+
"""
82+
Triggers whenever we get a heartbeat message
83+
"""
84+
print(msg)
85+
86+
def on_volume(self, msg):
87+
"""
88+
Triggers whenever we get a ticker message
89+
"""
90+
print(msg)
91+
92+
def on_ticker(self, msg):
93+
"""
94+
Triggers whenever we get a 24hvolume message
95+
"""
96+
print(msg)
97+
98+
def on_market(self, msg):
99+
"""
100+
Triggers whenever we get a market ('currencyPair') message
101+
"""
102+
print(msg)
103+
104+
def on_account(self, msg):
105+
"""
106+
Triggers whenever we get an account message
107+
"""
108+
print(msg)
109+
110+
sock = MySocket()
111+
# helps show what is going on
112+
sock.logger.setLevel(logging.DEBUG)
113+
# start the websocket thread and subsribe to '24hvolume'
114+
sock.startws(subscribe=['24hvolume'])
115+
```
116+
117+
**More examples of how to use websocket push API can be found [here](https://github.com/s4w3d0ff/python-poloniex/tree/master/examples).**

examples/README.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
# Examples
2+
#### _Examples require [this poloniex module](https://github.com/s4w3d0ff/python-poloniex) to be installed._
23

3-
#### _Most examples require this poloniex module and/or autobahn installed._
4-
5-
## WAMP Push Api Setup
6-
See http://autobahn.ws/python/installation.html for more details on other systems.
7-
### From fresh Ubuntu install (14.04, 16.04):
8-
##### Python 2.7
9-
```
10-
sudo apt-get install build-essential libssl-dev python-pip python-dev libffi-dev git
11-
sudo bash -c 'apt-get update && apt-get upgrade'
12-
pip install service_identity
13-
pip install autobahn[twisted]
14-
```
15-
##### Python 3
4+
## Chart:
5+
Saves chart data in a mongodb collection and returns a pandas dataframe with basic indicators.
6+
### Requirements:
7+
pip:
168
```
17-
sudo apt-get install build-essential libssl-dev python3-pip python3-dev libffi-dev git
18-
sudo bash -c 'apt-get update && apt-get upgrade'
19-
pip3 install service_identity
20-
pip3 install autobahn[twisted]
9+
pandas
10+
numpy
11+
pymongo
2112
```
13+
Chart examples require [mongod](https://www.mongodb.com/) running locally.
14+
15+
## Loanbot:
16+
Helps your loan offers get filled and keeps them from going 'stale'
17+
### Requirements:
18+
Just [this git repository](https://github.com/s4w3d0ff/python-poloniex).
19+
2220

23-
>NOTE: There is also another wonderful api wrapper that wraps the WAMP polo api using asyncio:
24-
>[https://github.com/absortium/poloniex-api](https://github.com/absortium/poloniex-api)
21+
## Websocket:
22+
Examples of how to use the websocket api to create tickers, stoplimits, etc.
23+
### Requirements:
24+
Just [this git repository](https://github.com/s4w3d0ff/python-poloniex) v0.5+.
25+
`mongoTicker.py` requires pymongo and mongod running.

examples/ticker/README.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

examples/ticker/dumbTicker.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

examples/ticker/mongoTicker.py

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)