AlgoOrderMixin#
- class swordfish.plugins.backtest.AlgoOrderMixin#
- final submit_limit_tp_sl_order(code, exchange, time, order_type, order_price, stop_loss_price, take_profit_price, quantity, direct, slippage, order_validity, expiration_time, /, label='', account_type=AccountType.DEFAULT)#
Submit a take-profit/stop-loss limit algorithmic order.
- Parameters:
code (str) – A STRING scalar, indicating the futures code.
exchange (str) – A STRING scalar, indicating the exchange code.
time (Timestamp) – A TIMESTAMP scalar, indicating the order timestamp.
order_type (int) –
An INT scalar, indicating the order type:
0: Market order (submitted at limit up/limit-down price, following time-priority rules)
1: Stop-loss market order
2: Take-profit market order
3: Stop-loss limit order
4: Take-profit limit order
5: Limit order (default)
6: Cancel order request
order_price (float) – A FLOAT scalar indicating the order price.
stop_loss_price (float) – A FLOAT scalar indicating the stop-loss price.
take_profit_price (float) – A FLOAT scalar indicating the take-profit price.
quantity (int) – An INT scalar indicating the order quantity.
direct (int) – An INT scalar indicating the buy/sell direction.
slippage (float) – A FLOAT scalar indicating the slippage.
order_validity (int) – An INT scalar indicating the validity of the order.
expiration_time (Timestamp) – A TIMESTAMP scalar indicating the order timestamp.
label (str, optional) – A STRING scalar used to specify the tag for order categorization.
account_type (AccountType, optional) –
An Enum value indicating the account type:
SPOT: Cash account
STOCK: Stock account
FUTURES: Futures account
OPTION: Options account
- final submit_market_tp_sl_order(code, exchange, time, order_type, order_price, stop_loss_price, take_profit_price, quantity, direct, slippage, order_validity, expiration_time, /, label='', account_type=AccountType.DEFAULT)#
Submit a take-profit/stop-loss market algorithmic order.
- Parameters:
code (str) – A STRING scalar, indicating the futures code.
exchange (str) – A STRING scalar, indicating the exchange code.
time (Timestamp) – A TIMESTAMP scalar, indicating the order timestamp.
order_type (int) –
An INT scalar, indicating the order type:
0: Market order (submitted at limit up/limit-down price, following time-priority rules)
1: Stop-loss market order
2: Take-profit market order
3: Stop-loss limit order
4: Take-profit limit order
5: Limit order (default)
6: Cancel order request
order_price (float) – A FLOAT scalar indicating the order price.
stop_loss_price (float) – A FLOAT scalar indicating the stop-loss price.
take_profit_price (float) – A FLOAT scalar indicating the take-profit price.
quantity (int) – An INT scalar indicating the order quantity.
direct (int) – An INT scalar indicating the buy/sell direction.
slippage (float) – A FLOAT scalar indicating the slippage.
order_validity (int) – An INT scalar indicating the validity of the order.
expiration_time (Timestamp) – A TIMESTAMP scalar indicating the order timestamp.
label (str, optional) – A STRING scalar used to specify the tag for order categorization.
account_type (AccountType, optional) –
An Enum value indicating the account type:
SPOT: Cash account
STOCK: Stock account
FUTURES: Futures account
OPTION: Options account
- final submit_ask_bid_order(code, exchange, time, order_type, bid_offset_flag, bid_price, bid_qty, ask_offset_flag, ask_price, ask_qty, bid_difftolerance, ask_difftolerance, quantity_allowed, /, label='', account_type=AccountType.DEFAULT)#
Submit a two sided quote order.
- Parameters:
code (str) – A STRING scalar, indicating the futures code.
exchange (str) – A STRING scalar, indicating the exchange code.
time (Timestamp) – A TIMESTAMP scalar, indicating the order timestamp.
order_type (int) –
An INT scalar, indicating the order type:
0: Market order (submitted at limit up/limit-down price, following time-priority rules)
1: Stop-loss market order
2: Take-profit market order
3: Stop-loss limit order
4: Take-profit limit order
5: Limit order (default)
6: Cancel order request
bid_offset_flag (int) – An INT scalar indicating the status of buy action, where 1 represents buy to open and 4 represents buy to close.
bid_price (float) – A FLOAT scalar indicating the bid price.
bid_qty (int) – An INT scalar indicating the bid quantity.
ask_offset_flag (int) – An INT scalar indicating the status of sell action, where 2 represents sell to open and 3 represents sell to close.
ask_price (float) – A FLOAT scalar indicating the ask price.
ask_qty (int) – An INT scalar indicating the ask quantity.
bid_difftolerance (float) – A FLOAT scalar indicating the maximum allowable deviation between the bid price and the reference market price.
ask_difftolerance (float) – A FLOAT scalar indicating the maximum allowable deviation between the ask price and the reference market price.
quantity_allowed (bool) – _description_
label (str, optional) – A STRING scalar used to specify the tag for order categorization.
account_type (AccountType, optional) –
An Enum value representing the account type:
SPOT: Cash account
STOCK: Stock account
FUTURES: Futures account
OPTION: Options account
- final submit_auto_order(code, exchange, time, order_type, order_price, stop_price, quantity, direct, order_validity, /, label=None, account_type=AccountType.DEFAULT)#
Submit a auto order.
- Parameters:
code (str) – A STRING scalar, indicating the futures code.
exchange (str) – A STRING scalar, indicating the exchange code.
time (Timestamp) – A TIMESTAMP scalar, indicating the order timestamp.
order_type (int) –
An INT scalar, indicating the order type:
0: Market order (submitted at limit up/limit-down price, following time-priority rules)
1: Stop-loss market order
2: Take-profit market order
3: Stop-loss limit order
4: Take-profit limit order
5: Limit order (default)
6: Cancel order request
order_price (float) – A FLOAT scalar indicating the bid or ask price.
stop_price (float) – A FLOAT scalar indicating the take-profit or stop-loss price.
quantity (int) – An INT scalar indicating the order quantity.
direct (int) – An INT scalar indicating the trade side.
order_validity (int) – An INT scalar indicating the validity of the order.
label (str, optional) – A STRING scalar used to specify the tag for order categorization.
account_type (AccountType, optional) –
An Enum value representing the account type:
SPOT: Cash account
STOCK: Stock account
FUTURES: Futures account
OPTION: Options account