Code Monkey home page Code Monkey logo

pysentosa's Introduction

##pysentosa - Python API for sentosa trading system

  • pysentosa is the Python API for sentosa trading system written by Wu Fuheng

  • WebSite: http://www.quant365.com (Quant365 - Trading with Science and Technology)

  • OS: Linux Ubuntu 15.10 64bit

  • Installation:

      GITURL=https://raw.githubusercontent.com/henrywoo/pysentosa/master
      wget $GITURL/install_nanomsg.sh -O install_nanomsg.sh
      chmod u+x install_nanomsg.sh
      ./install_nanomsg.sh
    
      wget $GITURL/install_yaml_cpp.sh -O install_yaml_cpp.sh
      chmod u+x install_yaml_cpp.sh
      ./install_yaml_cpp.sh
    
      sudo apt-get install -y python-pip libboost-all-dev
      sudo pip install -U pysentosa pyyaml netifaces websocket-client nanomsg \
        setproctitle psutil
    
  • Launch your IB TWS.

  • Run your strategy to trade

    Run demo:

      from pysentosa.demo import run_demo
      run_demo()
    

    Sample code:

      from pysentosa import Merlion
      from ticktype import *
    
      m = Merlion()
        target = 'SPY'
        m.track_symbol([target, 'BITA'])
        bounds = {target: [220, 250]}
        while True:
          symbol, ticktype, value = m.get_mkdata()
          if symbol == target:
            if ticktype == ASK_PRICE and value < bounds[symbol][0]:
                oid = m.buy(symbol, 5)
                while True:
                    ord_st = m.get_order_status(oid)
                    print ORDSTATUS[ord_st]
                    if ord_st == FILLED:
                        bounds[symbol][0] -= 20
                        break
                    sleep(2)
            elif ticktype == BID_PRICE and value > bounds[symbol][1]:
                oid = m.sell(symbol, 100)
                bounds[symbol][1] += 20
    

Bitdeli Badge

pysentosa's People

Contributors

bitdeli-chef avatar henrywoo avatar

Watchers

 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.