FuturesOrderMixin#

class swordfish.plugins.backtest.FuturesOrderMixin#
final submit_futures_order(code, exchange, time, order_type, order_price, stop_price, quantity, direct, order_validity, /, label=None, account_type=AccountType.DEFAULT)#

Submits a futures order.

Parameters:
  • code (str) – A STRING scalar representing the futures symbol.

  • exchange (str) – A STRING scalar representing the exchange code.

  • time (Timestamp) – A TIMESTAMP scalar indicating the order timestamp.

  • order_type (int) –

    An INT scalar specifying the order type. Possible values are:

    • 0: Market order, submitted at the limit up or limit down price, following the time priority rule.

    • 1: Market stop-loss order.

    • 2: Market take-profit order.

    • 3: Limit stop-loss order.

    • 4: Limit take-profit order.

    • 5: Limit order (default).

  • order_price (float) – A FLOAT scalar representing the order price.

  • stop_price (float) – A FLOAT scalar representing the stop-loss or take-profit price.

  • quantity (int) – An INT scalar representing the order quantity.

  • direct (int) –

    An INT scalar specifying the trade direction. Possible values are:

    • 1: Buy open

    • 2: Sell open

    • 3: Sell close

    • 4: Buy close

    • 5: Option exercise

  • order_validity (int) –

    An INT scalar indicating the order validity type. Possible values are:

    • 0: Good for day (default).

    • 1: Fill or kill (FOK) — execute immediately in full or cancel.

    • 2: Fill and kill (FAK) — execute immediately and cancel any remaining quantity.

  • label (str, optional) – A STRING scalar used to tag or categorize the order.

  • account_type (AccountType, optional) –

    The account type. Possible values are:

    • SPOT: Cash account

    • STOCK: Stock account

    • FUTURES: Futures account

    • OPTION: Options account

property futures_total_portfolios#

Query the daily futures profit and loss.

Returns:

Return a table with the following structure:

Field Name

Description

tradeDate

Date

margin

Margin Occupied

floatingPnl

Floating PnL

realizedPnl

Realized Cumulative PnL

totalPnl

Total PnL

cash

Available Cash

totalEquity

Total Equity

marginRatio

Margin Occupancy Ratio

pnl

Daily PnL

netValue

Unit Net Value

totalReturn

Cumulative Return as of Date

ratio

Daily Return

Return type:

Table