Skip to main content

Sinopac All New Trading Api.

Project description

Shioaji

shioaji-logosinopac-logo

PyPI - Status PyPI - Python Version PyPI - Downloads Coverage Binder doc Telegram

Shioaji is a trading API provided by Sinopac that offers a comprehensive and user-friendly platform for accessing the Taiwan financial markets. With Shioaji, you can trade a variety of financial instruments including stocks, futures, and options using your favorite Python packages such as numpy, scipy, pandas, pytorch, or tensorflow to build your own custom trading models. The platform is easy to use and intuitive, with advanced charting tools, real-time market data, and a customizable interface that allows you to tailor your trading experience to your specific needs. Shioaji is fast and efficient, with a high-performance core implemented in C++ and using FPGA event broker technology, and it is the first Python trading API in Taiwan that is compatible with Linux and Mac, making it a truly cross-platform solution. Whether you are a beginner looking to get started in the world of trading or an experienced trader looking for a more powerful platform, Shioaji has something to offer. Sign up for a free account today and start trading with confidence.

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

or

docker run -it sinotrade/shioaji:{version}

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_TOKEN", "YOUR_SECRET_KEY")
api.activate_ca(
    ca_path="/c/your/ca/path/Sinopac.pfx",
    ca_passwd="YOUR_CA_PASSWORD",
    person_id="person_id 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.StockPriceType.LMT,
    order_type=sj.constant.OrderType.ROD,
    order_lot=sj.constant.StockOrderLot.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

Telegram

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, CC.Chiao and Po Chien Yang with major contributions.

Release history Release notifications | RSS feed

This version

1.2.5

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

shioaji-1.2.5-cp312-cp312-win_amd64.whl (548.3 kB view hashes)

Uploaded CPython 3.12 Windows x86-64

shioaji-1.2.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl (4.5 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.28+ x86-64

shioaji-1.2.5-cp312-cp312-macosx_11_0_arm64.whl (681.5 kB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

shioaji-1.2.5-cp312-cp312-macosx_10_15_x86_64.whl (748.2 kB view hashes)

Uploaded CPython 3.12 macOS 10.15+ x86-64

shioaji-1.2.5-cp311-cp311-win_amd64.whl (573.7 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

shioaji-1.2.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (3.1 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

shioaji-1.2.5-cp311-cp311-macosx_11_0_arm64.whl (702.5 kB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

shioaji-1.2.5-cp311-cp311-macosx_10_9_x86_64.whl (776.6 kB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

shioaji-1.2.5-cp310-cp310-win_amd64.whl (577.3 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

shioaji-1.2.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

shioaji-1.2.5-cp310-cp310-macosx_11_0_arm64.whl (703.2 kB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

shioaji-1.2.5-cp310-cp310-macosx_10_9_x86_64.whl (833.3 kB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

shioaji-1.2.5-cp39-cp39-win_amd64.whl (623.2 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

shioaji-1.2.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (3.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

shioaji-1.2.5-cp39-cp39-macosx_11_0_arm64.whl (708.9 kB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

shioaji-1.2.5-cp39-cp39-macosx_10_9_x86_64.whl (829.9 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

shioaji-1.2.5-cp38-cp38-win_amd64.whl (656.7 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

shioaji-1.2.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (6.5 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

shioaji-1.2.5-cp38-cp38-macosx_11_0_arm64.whl (729.6 kB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

shioaji-1.2.5-cp38-cp38-macosx_10_9_x86_64.whl (898.6 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

shioaji-1.2.5-cp37-cp37m-win_amd64.whl (620.0 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

shioaji-1.2.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (3.0 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

shioaji-1.2.5-cp37-cp37m-macosx_10_9_x86_64.whl (877.2 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

shioaji-1.2.5-cp36-cp36m-win_amd64.whl (618.7 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

shioaji-1.2.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (3.0 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64 manylinux: glibc 2.24+ x86-64

shioaji-1.2.5-cp36-cp36m-macosx_10_9_x86_64.whl (877.0 kB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

Supported by

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