Giter Site home page Giter Site logo

twspy's Introduction

twspy

https://travis-ci.org/bdkearns/twspy.svg?branch=master

twspy is an unofficial Python implementation of the Interactive Brokers Trader Workstation API. It is similar to ibpy in that it uses java2python to translate the official Java API to Python. On top of the standard API, a new implementation of a "Pythonic" wrapper is included.

Reasons to use twspy

  • Implements TWS API 971.01
  • Generated using an updated fork of java2python instead of manually applied changes
  • Supports both Python 2.6+ and Python 3.2+
  • Simpler implementation of the "Pythonic" wrapper
  • Tested using added test suite based on pytest

Design changes in new wrapper

  • Exceptions are used to indicate errors instead of return values.
  • Message names are validated during register/unregister to avoid silent errors.
  • Messages are represented using namedtuples rather than regular class instances.
  • Exceptions in callbacks aren't swallowed with a log message by default. Instead they are left alone, allowing them to pass back to the TWS API resulting in a disconnect. To get a different behavior, specify the 'exceptions' option when creating a connection or registering a listener.

Using twspy

from twspy import Connection
con = Connection(host, port, clientId)

@con.listener('nextValidId')
def my_callback(msg):
    assert msg.orderId > 0

def my_other_callback(msg, extra):
    assert extra == 123
con.register('openOrder', my_other_callback, 123, exceptions='unregister')

con.connect()
...

twspy's People

Contributors

bdkearns avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.