Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
Commit with all source code and documentation.
  • Loading branch information
malja committed Dec 27, 2017
0 parents commit c7ceb23
Show file tree
Hide file tree
Showing 58 changed files with 17,615 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Auto detect text files and perform LF normalization
* text=auto

# Custom for Visual Studio
*.cs diff=csharp

# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Compiled python modules.
*.pyc

# Setuptools distribution folder.
/dist/

# IDE directory
.idea

# Python egg metadata, regenerated from source files by setuptools.
/*.egg-info

# For google-drive desktop.ini
*.ini
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Jan Malčák

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

# ziwia
Ziwia is an API client for Kraken cryptocurrency exchange website. Is supports the version 0 of the API as described on https://www.kraken.com/help/api.

## Prerequisites

As of version 0.2, ziwia requires ``requests`` library.

```
> pip install requests
```

## Installation

See [Documentation](http://readthedocs.io).

## Examples

Following code connects to your Kraken Account and returns your balance held in ZCASH.

```python
import ziwia

# Add your public and private keys
api = ziwia.Api("public-key", "private-key")
# Edit currency you use
balance = ziwia.private("Balance")["result"]["XZEC"]
# See all $ you have :)
print(balance)
```

Alternatively you can use new method introduced in version 0.2:

```python
import ziwia

# Create API client
api = ziwia.Api("public-key", "private-key")
# Get your account balance
balance = api.balance()
print(balance)
```
68 changes: 68 additions & 0 deletions doc/basic_usage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
.. _basic_usage:

===========
Basic Usage
===========

Install ziwia package as described in :ref:`installation`.

After successful installation, import ziwia into your project.

.. code-block:: python
import ziwia
api = ziwia.Api()
server_time = api.time()
print( server_time["unixtime"] )
This example shows simple API call to public Kraken API. Public API means, you do not have to authorize yourself with
private and public API key. Data accessible in public API is mostly about server.

We create an API class instance. You will always start API calls with this line. Next, we call :py:meth:`ziwia.Api.time`
which connects to Kraken API and returns server time in two formats. First one is `Unix timestamp <https://en.wikipedia.org/wiki/Unix_time>`_
and the second one is `RFC 1123 <http://freesoft.org/CIE/RFC/1945/14.htm>`_.

Last line just prints out server time as unix timestamp.

**Note:** Beside :py:meth:`ziwia.Api.time`, every API address Kraken exposes has its corresponding method in ziwia. For example address
*/0/public/Ticker* is mapped to :py:meth:`ziwia.Api.ticker` method.
As you can see, method name is made up of the part after last slash in address. Name is all lower-case and if address contains more than
one word, words are separated by underscore. For example */0/public/AssetPairs* translates as :py:meth:`ziwia.Api.asset_pairs`.

Private and public
------------------

Kraken API is divided into two sections - public and private. Public API is accessible without any authorization and
limits.

For accessing private API, you have to provide your private and public API keys. They should be passed as parameters to :py:class:`ziwia.Api` constructor.

.. code-block:: python
import ziwia
api = ziwia.Api( "public_key", "private_key" )
print( api.balance() )
This code retrives your account balance. To use it, change ``public_key`` and ``private_key`` to keys from your Kraken
Account settings.

Timeout and proxy
-----------------

Since version 0.2, ziwia supports proxy settings. All you have to do is to pass HTTP and HTTPS specific settings to
fourth parameter of :py:class:`ziwia.Api` constructor.

.. code-block:: python
import ziwia
proxy = {
"http": "your_proxy",
"https": "hattps_proxy"
}
api = ziwia.Api( "public_key", "private_key", 30, proxy )
The third parameter is number of seconds before timeout.
4 changes: 4 additions & 0 deletions doc/build/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: cfc5a70ffaac8283de3e6b0ae4176e46
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file added doc/build/.doctrees/basic_usage.doctree
Binary file not shown.
Binary file added doc/build/.doctrees/environment.pickle
Binary file not shown.
Binary file added doc/build/.doctrees/index.doctree
Binary file not shown.
Binary file added doc/build/.doctrees/installation.doctree
Binary file not shown.
Binary file added doc/build/.doctrees/reference.doctree
Binary file not shown.
Binary file added doc/build/.doctrees/todo.doctree
Binary file not shown.
68 changes: 68 additions & 0 deletions doc/build/_sources/basic_usage.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
.. _basic_usage:

===========
Basic Usage
===========

Install ziwia package as described in :ref:`installation`.

After successful installation, import ziwia into your project.

.. code-block:: python
import ziwia
api = ziwia.Api()
server_time = api.time()
print( server_time["unixtime"] )
This example shows simple API call to public Kraken API. Public API means, you do not have to authorize yourself with
private and public API key. Data accessible in public API is mostly about server.

We create an API class instance. You will always start API calls with this line. Next, we call :py:meth:`ziwia.Api.time`
which connects to Kraken API and returns server time in two formats. First one is `Unix timestamp <https://en.wikipedia.org/wiki/Unix_time>`_
and the second one is `RFC 1123 <http://freesoft.org/CIE/RFC/1945/14.htm>`_.

Last line just prints out server time as unix timestamp.

**Note:** Beside :py:meth:`ziwia.Api.time`, every API address Kraken exposes has its corresponding method in ziwia. For example address
*/0/public/Ticker* is mapped to :py:meth:`ziwia.Api.ticker` method.
As you can see, method name is made up of the part after last slash in address. Name is all lower-case and if address contains more than
one word, words are separated by underscore. For example */0/public/AssetPairs* translates as :py:meth:`ziwia.Api.asset_pairs`.

Private and public
------------------

Kraken API is divided into two sections - public and private. Public API is accessible without any authorization and
limits.

For accessing private API, you have to provide your private and public API keys. They should be passed as parameters to :py:class:`ziwia.Api` constructor.

.. code-block:: python
import ziwia
api = ziwia.Api( "public_key", "private_key" )
print( api.balance() )
This code retrives your account balance. To use it, change ``public_key`` and ``private_key`` to keys from your Kraken
Account settings.

Timeout and proxy
-----------------

Since version 0.2, ziwia supports proxy settings. All you have to do is to pass HTTP and HTTPS specific settings to
fourth parameter of :py:class:`ziwia.Api` constructor.

.. code-block:: python
import ziwia
proxy = {
"http": "your_proxy",
"https": "hattps_proxy"
}
api = ziwia.Api( "public_key", "private_key", 30, proxy )
The third parameter is number of seconds before timeout.
69 changes: 69 additions & 0 deletions doc/build/_sources/index.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
ziwia documentation
=====================

`ZIWIA <https://github.com/malja/ziwia>`_ is an API client for Kraken Bitcoin exchange site. It fully supports version 0 of Kraken's API. Main goal of
this project is to make it as easy as possible to contact Kraken, get information you need and return data in readable
format.

**WARNING**: At the moment, ziwia is still in early development stage. I would really appreciate any bug report or idea how to improve it.

Features:

- Data returned as JSON.
- Parameters are checked before connection.
- Proxy support.

Requires:

Ziwia requires ``requests`` library to work properly. See: :ref:`installation`.

User guide
----------

.. toctree::
:maxdepth: 2

installation
basic_usage
reference
todo

Reference
---------

.. autosummary::
:nosignatures:

ziwia.Api
ziwia.Api.__init__
ziwia.Api.public
ziwia.Api.time
ziwia.Api.assets
ziwia.Api.asset_pairs
ziwia.Api.ticker
ziwia.Api.ohlc
ziwia.Api.depth
ziwia.Api.trades
ziwia.Api.spread
ziwia.Api.private
ziwia.Api.balance
ziwia.Api.trade_balance
ziwia.Api.open_orders
ziwia.Api.closed_orders
ziwia.Api.query_orders
ziwia.Api.trades_history
ziwia.Api.query_trades
ziwia.Api.open_positions
ziwia.Api.ledgers
ziwia.Api.query_ledgers
ziwia.Api.trade_volume
ziwia.Api.add_order
ziwia.Api.cancel_order


Indices and tables
------------------

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
26 changes: 26 additions & 0 deletions doc/build/_sources/installation.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
.. _installation:

============
Installation
============

Ziwia is being developed with ``requests >= 2.14.2`` as only requirement. It uses just small set of its functionality
and thus should work even with older versions of requests.

.. code-block:: python
pip install requests
If you install ziwia from PyPi, all requirements should be installed with just one line:

.. code-block:: python
pip install ziwia
Or you may close github repository and install ziwia locally:

.. code-block:: bash
git clone https://github.com/malja/ziwia.git
That is all. See :ref:`basic_usage` for basic examples of usage.
42 changes: 42 additions & 0 deletions doc/build/_sources/reference.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.. _reference:

=============
API reference
=============

This page contains documentation of all methods available in ziwia.

.. autosummary::
:nosignatures:

ziwia.Api
ziwia.Api.__init__
ziwia.Api.public
ziwia.Api.time
ziwia.Api.assets
ziwia.Api.asset_pairs
ziwia.Api.ticker
ziwia.Api.ohlc
ziwia.Api.depth
ziwia.Api.trades
ziwia.Api.spread
ziwia.Api.private
ziwia.Api.balance
ziwia.Api.trade_balance
ziwia.Api.open_orders
ziwia.Api.closed_orders
ziwia.Api.query_orders
ziwia.Api.trades_history
ziwia.Api.query_trades
ziwia.Api.open_positions
ziwia.Api.ledgers
ziwia.Api.query_ledgers
ziwia.Api.trade_volume
ziwia.Api.add_order
ziwia.Api.cancel_order

Methods
-------

.. autoclass:: ziwia.Api
:members:
10 changes: 10 additions & 0 deletions doc/build/_sources/todo.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
==========
To-Do List
==========

.. todo::

* Tests
* Cache
* Implement kraken API calls limits.
* Maybe: Implement ziwia to return objects instead of JSON.
Binary file added doc/build/_static/ajax-loader.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c7ceb23

Please sign in to comment.