OptionOrderMixin#
- class swordfish.plugins.backtest.OptionOrderMixin#
- final submit_option_order(code, exchange, time, order_type, order_price, stop_price, quantity, direct, order_validity, /, label=None, account_type=AccountType.DEFAULT)#
Submits an options order.
- Parameters:
code (str) – A STRING scalar representing the option 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).
6: Cancel order.
9: Auto order mode. In this mode, only directions 1 and 2 are supported:
If direct = 1:
When the order quantity is greater than the current long position (longPosition), a buy open order is submitted.
When the order quantity is less than or equal to longPosition, a sell close (direction = 3) order is submitted.
If direct = 2:
When the order quantity is greater than the current short position (shortPosition), a sell open order is submitted.
When the order quantity is less than or equal to shortPosition, a buy close (direction = 4) order is submitted.
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.
The stop-loss/take-profit price is not currently supported and defaults to 0.
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 option_total_portfolios#
Query daily option PnL
- 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 cumulative PnL
cash
Available cash
totalEquity
Total account equity
marginRatio
Margin ratio
pnl
Daily PnL
netValue
Account unit net value
totalReturn
Cumulative return up to the day
ratio
Daily return
- Return type: