Smarkets Python SDK - API clients and utility library
Project description
Smarkets Python library (streaming API client, id generation, more to come).
Compatible with Python 2.x >= 2.6 and PyPy 1.9+.
Installing using source distribution
When you install smk-python-sdk using PyPI distribution there are no non-Python dependencies. All the Python dependencies will be fetched for you when you install smk-python-sdk.
PyPI page: https://pypi.python.org/pypi/smk_python_sdk
pip install smk-python-sdk
Getting Started
import logging
logging.basicConfig(level=logging.DEBUG)
import smarkets
username = 'username'
password = 'password'
settings = smarkets.SessionSettings(username, password)
settings.host = 'api.smarkets.com'
settings.port = 3701
session = smarkets.Session(settings)
client = smarkets.Smarkets(session)
client.login()
client.ping()
client.flush()
client.read()
market_id = client.str_to_uuid128('fc024')
client.subscribe(market_id)
client.flush()
client.read()
order = smarkets.Order()
order.quantity = 400000 # £40 payout
order.price = 2500 # 25.00%
order.side = smarkets.Order.BUY
order.market = market_id
order.contract = client.str_to_uuid128('fcccc')
client.order(order)
client.flush()
client.read()
client.logout()
Registering callbacks
from google.protobuf import text_format
def login_response(msg):
print "eto.login_response", text_format.MessageToString(msg)
def global_callback(name, msg):
print name, text_format.MessageToString(msg)
client.add_handler('eto.login_response', login_response)
client.add_global_handler(global_callback)
Thread Safety
Functions and class members contained in this package are thread safe. Instance members are not thread safe.
Development
GitHub repository: https://github.com/smarkets/smk_python_sdk/
Non-Python dependencies:
piqi
Google protocol buffers compiler and libraries
You can install Python dependencies by executing:
pip install -r requirements-dev-py2.txt
To build and install call:
python setup.py clean build install
License
Copyright (C) 2011-2013 Smarkets Limited <support@smarkets.com>
This module is released under the MIT License: http://www.opensource.org/licenses/mit-license.php (or see the LICENSE file)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smk_python_sdk-0.6.2.tar.gz.
File metadata
- Download URL: smk_python_sdk-0.6.2.tar.gz
- Upload date:
- Size: 57.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c319c1fd8cac05d1d5a50d184974ef2d6b1f6363a0fba91fd1a6e7b4b70f7655
|
|
| MD5 |
05cf4d9458ec0984005ea1a253038920
|
|
| BLAKE2b-256 |
cd3cd3941e3ed8bf5c4d572b59ecf179436d3718fc6008dba8e6d9f1318dcbe2
|
File details
Details for the file smk_python_sdk-0.6.2-py27-none-any.whl.
File metadata
- Download URL: smk_python_sdk-0.6.2-py27-none-any.whl
- Upload date:
- Size: 45.3 kB
- Tags: Python 2.7
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
955e6d1fe6b062cc9368d4b43f23262abf42f2ecef5f2dd41d4f8a49cae70e9e
|
|
| MD5 |
638317d85c285bf91e244c579391ceaa
|
|
| BLAKE2b-256 |
76d021c74e12b3dbdf4b1dc43a352905f95bda8f3f0ee8780e110bbc961eec07
|