shioaji day trading demo package
pip install sjtrade
import shioaji as sj
import sjtrade
api = sj.Shioaji()
accounts = api.login(**login_kws)
sjtrader = sjtrade.SJTrader(api)
sjtrader.position_filepath = "position.txt"
sjtrade.io.file.read_position(sjtrader.position_filepath)
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)
sjtrader.entry_pct = 0.05
sjtrader.stop_profit_pct = 0.095
sjtrader.stop_loss_pct = 0.09
sjtrader.start()
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
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()
pip install 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)
from loguru import logger
from notifiers.logging import NotificationHandler
handler = NotificationHandler("telegram", defaults=PARAMS)
logger.add(handler, level="INFO")
logger.info("logger test")
flit install -s