Skip to main content

Sinopac All New Trading Api.

Project description

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.

We are in early-release alpha. Expect some adventures and rough edges.

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

Quickstarts

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.

Streaming Market Data

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.

Place Order

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 current state is Pre-Alpha, we expect no obvious bugs. 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, Sky Wu and Po Chien Yang with major contributions.

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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

shioaji-0.2.0.dev1-cp37-cp37m-manylinux1_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.7m

shioaji-0.2.0.dev1-cp36-cp36m-manylinux1_x86_64.whl (4.4 MB view details)

Uploaded CPython 3.6m

shioaji-0.2.0.dev1-cp35-cp35m-win_amd64.whl (1.8 MB view details)

Uploaded CPython 3.5mWindows x86-64

File details

Details for the file shioaji-0.2.0.dev1-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: shioaji-0.2.0.dev1-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.7m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.22.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for shioaji-0.2.0.dev1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ade5a7a9c88061e92f362340dd1d90048b89ff21248ce1ec508e646d85d2aafd
MD5 fdb44f7ad70d29c094bac31b4e8c6eda
BLAKE2b-256 29245af72d071917151a78c4a8778db9eb48109d2d7664553ac00f519a1b7aa9

See more details on using hashes here.

File details

Details for the file shioaji-0.2.0.dev1-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: shioaji-0.2.0.dev1-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: CPython 3.6m
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.22.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for shioaji-0.2.0.dev1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 f30e111f7b660cf13b4b7a84b33107d8497bd046daa7d4e59d6e93ffd1f47383
MD5 0def165fbbc16f09369ea82ae47c668c
BLAKE2b-256 9d61787b62727f7c7b85e77c8f45f20606719af8996122573834ec4998a39741

See more details on using hashes here.

File details

Details for the file shioaji-0.2.0.dev1-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: shioaji-0.2.0.dev1-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 1.8 MB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.7.2

File hashes

Hashes for shioaji-0.2.0.dev1-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 3d813520a3fac556d1686bf9f114736c2ee3446ab7ff77b404cc79f987a958a2
MD5 61493a37ac24535207da5dc474c9c996
BLAKE2b-256 f6e489ecd2c95d3c4217d85d5a2c5dbcf324721a0f76b277815a92b2b3d4548b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page