Giter VIP home page Giter VIP logo

shioaji's Introduction

Shioaji

shioaji-logosinopac-logo

PyPI - Status PyPI - Python Version PyPI - Downloads Build - Status

Coverage Binder doc Gitter

Shioaji is sinopac provide the most pythonic api for trading the taiwan and global financial market. You can use your favorite Python packages such as numpy, scipy, pandas, pytorch or tensorflow to build your own trading model with intergrated the shioaji api on cross platform.

Installation

Binaries

simple using pip to install

pip install shioaji

Docker Image

simple run with interactive mode in docker

docker run -it sinotrade/shioaji:latest

run with jupyter lab or notebook

docker run -p 8888:8888 sinotrade/shioaji:jupyter

Initialization

import shioaji as sj

api = sj.Shioaji()
accounts = api.login("YOUR_PERSON_ID", "YOUR_PASSWORD")
api.activate_ca(
    ca_path="/c/your/ca/path/Sinopac.pfx",
    ca_passwd="YOUR_CA_PASSWORD",
    person_id="Person of this Ca",
)

Just import our API library like other popular python library and new the instance to start using our API. Login your account and activate the certification then you can start placing order.

api.quote.subscribe(api.Contracts.Stocks["2330"], quote_type="tick")
api.quote.subscribe(api.Contracts.Stocks["2330"], quote_type="bidask")
api.quote.subscribe(api.Contracts.Futures["TXFC0"], quote_type="tick")

Subscribe the real time market data. Simplely pass contract into quote subscribe function and give the quote type will receive the streaming data.

contract = api.Contracts.Stocks["2890"]
order = api.Order(
    price=9.6,
    quantity=1,
    action="Buy",
    price_type="LMT",
    order_type="ROD",
    order_lot="Common",
    account=api.stock_account,
)
# or
order = api.Order(
    price=9.6,
    quantity=1,
    action=sj.constant.Action.Buy,
    price_type=sj.constant.TFTStockPriceType.LMT,
    order_type=sj.constant.TFTOrderType.ROD,
    order_lot=sj.constant.TFTStockOrderLot.Common,
    account=api.stock_account,
)
trade = api.place_order(contract, order)

Like the above subscribing market data using the contract, then need to define the order. Pass them into place_order function, then it will return the trade that describe the status of your order.

Conclusion

This quickstart demonstrates how easy to use our package for native Python users. Unlike many other trading API is hard for Python developer. We focus on making more pythonic trading API for our users.

More usage detail on document.

doc

Communication

Gitter

  • Gitter: general chat, online discussions, collaboration etc.
  • GitHub issues: bug reports, feature requests, install issues, RFCs, thoughts, etc.

Releases and Contributing

Shioaji has a 14 day release cycle. See the release change log. Please let us know if you encounter a bug by filing an issue.

We appreciate all suggestions. If you have any idea want us to implement, please discuss with us in gitter.

The Team

Shioaji is currently maintained by Sally, Yvictor, Sam, CC.Chiao and Po Chien Yang with major contributions.

shioaji's People

Contributors

yvictor avatar ypochien avatar gitter-badger avatar

Stargazers

 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.