Touchprice is an extension feature of Shioaji. Using the conditions to trigger placing order.
pip install touchprice
Just import our API library like other popular python library and adding Shioaji to start using the feature of touchprice.
import touchprice as tp
import shioaji as sj
api = sj.Shioaji()
api.login("YOUR_API_KEY", "YOUR_SECRET_KEY")
api.activate_ca(CA_PATH, CA_USERID, CA_PASSWORD)
touch = tp.TouchOrderExecutor(api)
TouchOrderCond contains touch condition and order condition.
touch_cmd =
tp.TouchCmd(
code="2890",
close = tp.Price(price=11.0, trend="Up")
)
- code: str,
- close: condition.Price = None,
- buy_price: condition.Price = None,
- sell_price: condition.Price = None,
- high: condition.Price = None,
- low: condition.Price = None,
- volume: condition.Qty = None,
- total_volume: condition.Qty = None,
- ask_volume: condition.Qty = None,
- bid_volume: condition.Qty = None,
- price: float = 0.0,
- trend: constant.Trend = 'Equal' ('Up', 'Down', 'Equal')
- price_type: constant.PriceType = 'LimitPrice' ('LimitPrice', 'LimitUp', 'Unchanged', 'LimitDown ')
- qty: int,
- trend: constant.Trend = 'Equal' ('Up', 'Down', 'Equal')
order_cmd = tp.OrderCmd(
code="2890",
order = sj.Order(
action="Buy",
price=10,
quantity=1,
order_type="ROD",
price_type="LMT",)
)
- code: str
- order: shioaji.order.Order
condition = tp.TouchOrderCond(
touch_cmd = touch_cmd,
order_cmd = order_cmd
)
touch.add_condition(condition)
touch.delete_condition(condition)
If not set code can show all conditions, else just show coditions of code.
touch.show_condition(code)
The package are used at your own risk.