Skip to content

Commit 0562897

Browse files
committed
Add initial pass at library
0 parents  commit 0562897

29 files changed

+2444
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
docs/_build

.travis.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
language: python
2+
3+
python:
4+
- "2.7"
5+
- "3.3"
6+
- "3.4"
7+
- "3.5"
8+
- "3.6"
9+
10+
install:
11+
- pip install -r test-requirements.txt
12+
- pip install -r requirements.txt
13+
- pip install tox-travis
14+
15+
script:
16+
- tox
17+
18+
after_success:
19+
- coveralls

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 sammchardy
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.rst

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
===============================
2+
Welcome to python-kucoin v0.1.0
3+
===============================
4+
5+
.. image:: https://img.shields.io/pypi/v/python-kucoin.svg
6+
:target: https://pypi.python.org/pypi/python-kucoin
7+
8+
.. image:: https://img.shields.io/pypi/l/python-kucoin.svg
9+
:target: https://pypi.python.org/pypi/python-kucoin
10+
11+
.. image:: https://img.shields.io/travis/sammchardy/python-kucoin.svg
12+
:target: https://travis-ci.org/sammchardy/python-kucoin
13+
14+
.. image:: https://img.shields.io/coveralls/sammchardy/python-kucoin.svg
15+
:target: https://coveralls.io/github/sammchardy/python-kucoin
16+
17+
.. image:: https://img.shields.io/pypi/wheel/python-kucoin.svg
18+
:target: https://pypi.python.org/pypi/python-kucoin
19+
20+
.. image:: https://img.shields.io/pypi/pyversions/python-kucoin.svg
21+
:target: https://pypi.python.org/pypi/python-kucoin
22+
23+
This is an unofficial Python wrapper for the `Kucoin exchanges REST API v1 <https://kucoinapidocs.docs.apiary.io/>`_. I am in no way affiliated with Kucoin, use at your own risk.
24+
25+
Source code
26+
https://github.com/sammchardy/python-kucoin
27+
28+
Documentation
29+
https://python-kucoin.readthedocs.io/en/latest/
30+
31+
32+
Features
33+
--------
34+
35+
- Implementation of all REST endpoints.
36+
- Simple handling of authentication
37+
- Response exception handling
38+
- Simple buy and sell order functions
39+
40+
Quick Start
41+
-----------
42+
43+
Register an account with `Kucoin <https://www.kucoin.com/#/?r=E42cWB>`_.
44+
45+
`Generate an API Key <https://www.kucoin.com/#/user/setting/api>`_ and enable it.
46+
47+
.. code:: bash
48+
49+
pip install python-kucoin
50+
51+
52+
.. code:: python
53+
54+
from kucoin.client import Client
55+
client = Client(api_key, api_secret)
56+
57+
# get currencies
58+
currencies = client.get_currencies()
59+
60+
# get market depth
61+
depth = client.get_order_book('KCS-BTC', limit=50)
62+
63+
# get symbol klines
64+
from_time = 1507479171
65+
to_time = 1510278278
66+
klines = client.get_kline_data_tv(
67+
'KCS-BTC',
68+
Client.RESOLUTION_1MINUTE,
69+
from_time,
70+
to_time
71+
)
72+
73+
# place a buy order
74+
transaction = client.create_buy_order('KCS-BTC', '0.01', '1000')
75+
76+
# get list of active orders
77+
orders = client.get_active_orders('KCS-BTC')
78+
79+
For more `check out the documentation <https://python-kucoin.readthedocs.io/en/latest/>`_.
80+
81+
Donate
82+
------
83+
84+
If this library helped you out feel free to donate.
85+
86+
- ETH: 0xD7a7fDdCfA687073d7cC93E9E51829a727f9fE70
87+
- NEO: AVJB4ZgN7VgSUtArCt94y7ZYT6d5NDfpBo
88+
- BTC: 1Dknp6L6oRZrHDECRedihPzx2sSfmvEBys
89+
90+
Other Exchanges
91+
---------------
92+
93+
If you use Binance check out my `python-binance <https://github.com/sammchardy/python-binance>`_ library.
94+
If you use Quoinex or Qryptos check out my `python-quoine <https://github.com/sammchardy/python-quoine>`_ library.

docs/Makefile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = python -msphinx
7+
SPHINXPROJ = python-kucoin
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21+
22+
rst:
23+
sphinx-apidoc -f -o ./ ../

docs/assets.rst

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Asset Operation Endpoints
2+
=========================
3+
4+
.. autoclass:: kucoin.client.Client
5+
:members: get_deposit_address, create_withdrawal, cancel_withdrawal, get_deposits, get_withdrawals, get_coin_balance, get_all_balances
6+
:noindex:

docs/conf.py

+185
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
#
4+
# python-kucoin documentation build configuration file, created by
5+
# sphinx-quickstart on Thu Sep 21 20:24:54 2017.
6+
#
7+
# This file is execfile()d with the current directory set to its
8+
# containing dir.
9+
#
10+
# Note that not all possible configuration values are present in this
11+
# autogenerated file.
12+
#
13+
# All configuration values have a default; values that are commented out
14+
# serve to show the default.
15+
16+
# If extensions (or modules to document with autodoc) are in another directory,
17+
# add these directories to sys.path here. If the directory is relative to the
18+
# documentation root, use os.path.abspath to make it absolute, like shown here.
19+
#
20+
import os
21+
import sys
22+
sys.path.insert(0, os.path.abspath('..'))
23+
24+
25+
# -- General configuration ------------------------------------------------
26+
27+
# If your documentation needs a minimal Sphinx version, state it here.
28+
#
29+
# needs_sphinx = '1.0'
30+
31+
# Add any Sphinx extension module names here, as strings. They can be
32+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
33+
# ones.
34+
extensions = ['sphinx.ext.autodoc',
35+
'sphinx.ext.imgmath',
36+
'sphinx.ext.viewcode',
37+
'sphinx.ext.githubpages']
38+
39+
# Add any paths that contain templates here, relative to this directory.
40+
templates_path = ['_templates']
41+
42+
# The suffix(es) of source filenames.
43+
# You can specify multiple suffix as a list of string:
44+
#
45+
# source_suffix = ['.rst', '.md']
46+
source_suffix = '.rst'
47+
48+
# The master toctree document.
49+
master_doc = 'index'
50+
51+
# General information about the project.
52+
project = 'python-kucoin'
53+
copyright = '2017, Sam McHardy'
54+
author = 'Sam McHardy'
55+
56+
# The version info for the project you're documenting, acts as replacement for
57+
# |version| and |release|, also used in various other places throughout the
58+
# built documents.
59+
#
60+
# The short X.Y version.
61+
version = '0.2.0'
62+
# The full version, including alpha/beta/rc tags.
63+
release = '0.2.0'
64+
65+
# The language for content autogenerated by Sphinx. Refer to documentation
66+
# for a list of supported languages.
67+
#
68+
# This is also used if you do content translation via gettext catalogs.
69+
# Usually you set "language" from the command line for these cases.
70+
language = None
71+
72+
# List of patterns, relative to source directory, that match files and
73+
# directories to ignore when looking for source files.
74+
# This patterns also effect to html_static_path and html_extra_path
75+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
76+
77+
# The name of the Pygments (syntax highlighting) style to use.
78+
pygments_style = 'sphinx'
79+
80+
# If true, `todo` and `todoList` produce output, else they produce nothing.
81+
todo_include_todos = False
82+
83+
84+
# -- Options for HTML output ----------------------------------------------
85+
86+
# The theme to use for HTML and HTML Help pages. See the documentation for
87+
# a list of builtin themes.
88+
#
89+
#html_theme = 'alabaster'
90+
html_theme = 'sphinx_rtd_theme'
91+
92+
# Theme options are theme-specific and customize the look and feel of a theme
93+
# further. For a list of options available for each theme, see the
94+
# documentation.
95+
#
96+
# html_theme_options = {}
97+
98+
# Add any paths that contain custom static files (such as style sheets) here,
99+
# relative to this directory. They are copied after the builtin static files,
100+
# so a file named "default.css" will overwrite the builtin "default.css".
101+
html_static_path = ['_static']
102+
103+
# Custom sidebar templates, must be a dictionary that maps document names
104+
# to template names.
105+
#
106+
# This is required for the alabaster theme
107+
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
108+
html_sidebars = {
109+
'**': [
110+
'about.html',
111+
'navigation.html',
112+
'relations.html', # needs 'show_related': True theme option to display
113+
'searchbox.html',
114+
'donate.html',
115+
]
116+
}
117+
118+
119+
# -- Options for HTMLHelp output ------------------------------------------
120+
121+
# Output file base name for HTML help builder.
122+
htmlhelp_basename = 'python-kucoindoc'
123+
124+
125+
# -- Options for LaTeX output ---------------------------------------------
126+
127+
latex_elements = {
128+
# The paper size ('letterpaper' or 'a4paper').
129+
#
130+
# 'papersize': 'letterpaper',
131+
132+
# The font size ('10pt', '11pt' or '12pt').
133+
#
134+
# 'pointsize': '10pt',
135+
136+
# Additional stuff for the LaTeX preamble.
137+
#
138+
# 'preamble': '',
139+
140+
# Latex figure (float) alignment
141+
#
142+
# 'figure_align': 'htbp',
143+
}
144+
145+
# Grouping the document tree into LaTeX files. List of tuples
146+
# (source start file, target name, title,
147+
# author, documentclass [howto, manual, or own class]).
148+
latex_documents = [
149+
(master_doc, 'python-kucoin.tex', 'python-kucoin Documentation',
150+
'Sam McHardy', 'manual'),
151+
]
152+
153+
154+
# -- Options for manual page output ---------------------------------------
155+
156+
# One entry per manual page. List of tuples
157+
# (source start file, name, description, authors, manual section).
158+
man_pages = [
159+
(master_doc, 'python-kucoin', 'python-kucoin Documentation',
160+
[author], 1)
161+
]
162+
163+
164+
# -- Options for Texinfo output -------------------------------------------
165+
166+
# Grouping the document tree into Texinfo files. List of tuples
167+
# (source start file, target name, title, author,
168+
# dir menu entry, description, category)
169+
texinfo_documents = [
170+
(master_doc, 'python-kucoin', 'python-kucoin Documentation',
171+
author, 'python-kucoin', 'One line description of project.',
172+
'Miscellaneous'),
173+
]
174+
175+
176+
def skip(app, what, name, obj, skip, options):
177+
# Ensure that the __init__ method gets documented.
178+
if name == "__init__":
179+
return False
180+
return skip
181+
182+
183+
def setup(app):
184+
app.connect("autodoc-skip-member", skip)
185+

docs/constants.rst

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
Constants
2+
=========
3+
4+
Kucoin defines constants for Redord Types, Order Side, Order Status and Resolution. These are accessible from the Client class.
5+
6+
.. code:: python
7+
8+
RECORD_WITHDRAWAL = 'WITHDRAW'
9+
RECORD_DEPOSIT = 'DEPOSIT'
10+
11+
SIDE_BUY = 'BUY'
12+
SIDE_SELL = 'SELL'
13+
14+
ORDER_STATUS_CANCELLED = 'CANCEL'
15+
16+
# Kucoin has 2 kline endpoint and they have been setup to take the below values
17+
18+
RESOLUTION_1MINUTE = '1'
19+
RESOLUTION_5MINUTES = '5'
20+
RESOLUTION_15MINUTES = '15'
21+
RESOLUTION_30MINUTES = '30'
22+
RESOLUTION_1HOUR = '60'
23+
RESOLUTION_8HOURS = '480'
24+
RESOLUTION_1DAY = 'D'
25+
RESOLUTION_1WEEK = 'W'
26+
27+
Use in your code like below.
28+
29+
.. code:: python
30+
31+
from kucoin.client import Client
32+
33+
order_side = Client.SIDE_BUY

docs/currencies.rst

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Currency Endpoints
2+
==================
3+
4+
.. autoclass:: kucoin.client.Client
5+
:members: get_currencies
6+
:noindex:

0 commit comments

Comments
 (0)