sjtrade
shioaji day trading demo package
Install
pip install sjtrade
Get started
Init Shioaji and SjTrader
import shioaji as sj
import sjtrade
api = sj.Shioaji()
accounts = api.login(**login_kws)
sjtrader = sjtrade.SJTrader(api)
Set Position Filepath and Preview Position
sjtrader.position_filepath = "position.txt"
sjtrade.io.file.read_position(sjtrader.position_filepath)
Set Custom Position FileReader
from sjtrade.io.file import read_csv_position
sjtrader.read_position_func = read_csv_position
sjtrader.position_filepath = "position.csv"
sjtrader.read_position_func(sjtrader.position_filepath)
Set entry_pct stop_profit_pct stop_loss_pct
sjtrader.entry_pct = 0.05
sjtrader.stop_profit_pct = 0.095
sjtrader.stop_loss_pct = 0.09
Start sjtrader
sjtrader.start()
What do sjtrader start actually do
sjtrader.start??
Signature: sjtrader.start()
Source:
def start(self):
positions = read_position(self._position_filepath)
self.api.set_order_callback(self.order_deal_handler)
sleep_until(8, 45)
self.place_entry_order(positions, self.entry_pct)
sleep_until(8, 54, 59)
self.api.quote.set_on_tick_stk_v1_callback(self.cancel_preorder_handler)
sleep_until(8, 59, 55)
self.api.quote.set_on_tick_stk_v1_callback(self.intraday_handler)
sleep_until(13, 25, 59)
self.open_position_cover()
File: ~/.pyenv/versions/miniconda3-latest/lib/python3.7/site-packages/sjtrade/trader.py
Type: method
Simulation
all order will be place as success and deal when price touch
api = sj.Shioaji()
accounts = api.login(**login_kws)
sjtrader = sjtrade.SJTrader(api, simulation=True)
sjtrader.position_filepath = "position.txt"
sjtrade.io.file.read_position(sjtrader.position_filepath)
sjtrader.entry_pct = 0.05
sjtrader.stop_profit_pct = 0.095
sjtrader.stop_loss_pct = 0.09
sjtrader.start()
Notifications
pip install notifiers
Check notifiers
from notifiers import get_notifier
notifier = get_notifier("telegram")
TELECHATID = ""
TELEBOT_TOKEN = ""
PARAMS = {"chat_id": TELECHATID, "token": TELEBOT_TOKEN}
notifier.notify(message="test", **PARAMS)
Check logger
from loguru import logger
from notifiers.logging import NotificationHandler
handler = NotificationHandler("telegram", defaults=PARAMS)
logger.add(handler, level="INFO")
logger.info("logger test")
Developer's guide
flit install -s
Metadata
Release files for sjtrade 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sjtrade-1.1.1.tar.gz | 24.1 kB | Without provenance | Details for sjtrade-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sjtrade-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for sjtrade-1.1.1-py3-none-any.whl |
Total release size: 36.2 kB
Release files / sjtrade-1.1.1.tar.gz
| Download URL | sjtrade-1.1.1.tar.gz |
|---|---|
| Size | 24.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6580b073b9dd36c151cb40024bab6eb2cdbe99e5e7281c8cf38a2ee184503b58
|
|
BLAKE2b-256 checksum How to use checksums |
89024ef52d97e7f17314353ef08b4d6bc3dd12397ab7ad08cc5c88f97a07438c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Release files / sjtrade-1.1.1-py3-none-any.whl
| Download URL | sjtrade-1.1.1-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
43d973ea5537208e853ed317ff38f999d51373d2a239dfde2aad9fbac01aaac3
|
|
BLAKE2b-256 checksum How to use checksums |
7163a94b1dc994e85739c28f80a3e8707c1a4459fea3cbea21397b33fccdf57f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
python-requests/2.31.0
|
Security for sjtrade 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.