tastytrade.backtest¶
-
pydantic model tastytrade.backtest.Backtest(*, symbol: str, entryConditions: BacktestEntry, exitConditions: BacktestExit, legs: list[BacktestLeg], startDate: date, endDate: date =
datetime.date(2024, 7, 31), status: str ='pending')¶ Bases:
BacktestDataDataclass of configuration options for a backtest.
Show JSON schema
{ "title": "Backtest", "description": "Dataclass of configuration options for a backtest.", "type": "object", "properties": { "symbol": { "title": "Symbol", "type": "string" }, "entryConditions": { "$ref": "#/$defs/BacktestEntry" }, "exitConditions": { "$ref": "#/$defs/BacktestExit" }, "legs": { "items": { "$ref": "#/$defs/BacktestLeg" }, "title": "Legs", "type": "array" }, "startDate": { "format": "date", "title": "Startdate", "type": "string" }, "endDate": { "default": "2024-07-31", "format": "date", "title": "Enddate", "type": "string" }, "status": { "default": "pending", "title": "Status", "type": "string" } }, "$defs": { "BacktestEntry": { "description": "Dataclass of parameters for backtest trade entry.", "properties": { "useExactDte": { "default": true, "title": "Useexactdte", "type": "boolean" }, "maximumActiveTrials": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Maximumactivetrials" }, "maximumActiveTrialsBehavior": { "anyOf": [ { "enum": [ "close oldest", "don't enter" ], "type": "string" }, { "type": "null" } ], "default": null, "title": "Maximumactivetrialsbehavior" }, "frequency": { "default": "every day", "title": "Frequency", "type": "string" } }, "title": "BacktestEntry", "type": "object" }, "BacktestExit": { "description": "Dataclass of parameters for backtest trade exit.", "properties": { "afterDaysInTrade": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Afterdaysintrade" }, "stopLossPercentage": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Stoplosspercentage" }, "takeProfitPercentage": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Takeprofitpercentage" }, "atDaysToExpiration": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Atdaystoexpiration" } }, "title": "BacktestExit", "type": "object" }, "BacktestLeg": { "description": "Dataclass of parameters for placing legs of backtest trades.\nLeg delta must be a multiple of 5.", "properties": { "daysUntilExpiration": { "default": 45, "title": "Daysuntilexpiration", "type": "integer" }, "delta": { "default": 15, "title": "Delta", "type": "integer" }, "direction": { "default": "sell", "enum": [ "buy", "sell" ], "title": "Direction", "type": "string" }, "quantity": { "default": 1, "title": "Quantity", "type": "integer" }, "side": { "default": "call", "enum": [ "call", "put" ], "title": "Side", "type": "string" } }, "title": "BacktestLeg", "type": "object" } }, "required": [ "symbol", "entryConditions", "exitConditions", "legs", "startDate" ] }- Fields:¶
end_date (datetime.date)entry_conditions (tastytrade.backtest.BacktestEntry)exit_conditions (tastytrade.backtest.BacktestExit)start_date (datetime.date)
- pydantic model tastytrade.backtest.BacktestData¶
Bases:
BaseModelDataclass for converting backtest JSON naming conventions to snake case.
Show JSON schema
{ "title": "BacktestData", "description": "Dataclass for converting backtest JSON naming conventions to snake case.", "type": "object", "properties": {} }
-
pydantic model tastytrade.backtest.BacktestEntry(*, useExactDte: bool =
True, maximumActiveTrials: int | None =None, maximumActiveTrialsBehavior: 'close oldest' | "don't enter" | None =None, frequency: str ='every day')¶ Bases:
BacktestDataDataclass of parameters for backtest trade entry.
Show JSON schema
{ "title": "BacktestEntry", "description": "Dataclass of parameters for backtest trade entry.", "type": "object", "properties": { "useExactDte": { "default": true, "title": "Useexactdte", "type": "boolean" }, "maximumActiveTrials": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Maximumactivetrials" }, "maximumActiveTrialsBehavior": { "anyOf": [ { "enum": [ "close oldest", "don't enter" ], "type": "string" }, { "type": "null" } ], "default": null, "title": "Maximumactivetrialsbehavior" }, "frequency": { "default": "every day", "title": "Frequency", "type": "string" } } }- Fields:¶
maximum_active_trials (int | None)maximum_active_trials_behavior (Literal['close oldest', "don't enter"] | None)use_exact_DTE (bool)
-
pydantic model tastytrade.backtest.BacktestExit(*, afterDaysInTrade: int | None =
None, stopLossPercentage: int | None =None, takeProfitPercentage: int | None =None, atDaysToExpiration: int | None =None)¶ Bases:
BacktestDataDataclass of parameters for backtest trade exit.
Show JSON schema
{ "title": "BacktestExit", "description": "Dataclass of parameters for backtest trade exit.", "type": "object", "properties": { "afterDaysInTrade": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Afterdaysintrade" }, "stopLossPercentage": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Stoplosspercentage" }, "takeProfitPercentage": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Takeprofitpercentage" }, "atDaysToExpiration": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Atdaystoexpiration" } } }- Fields:¶
after_days_in_trade (int | None)at_days_to_expiration (int | None)stop_loss_percentage (int | None)take_profit_percentage (int | None)
-
pydantic model tastytrade.backtest.BacktestLeg(*, daysUntilExpiration: int =
45, delta: int =15, direction: 'buy' | 'sell' ='sell', quantity: int =1, side: 'call' | 'put' ='call')¶ Bases:
BacktestDataDataclass of parameters for placing legs of backtest trades. Leg delta must be a multiple of 5.
Show JSON schema
{ "title": "BacktestLeg", "description": "Dataclass of parameters for placing legs of backtest trades.\nLeg delta must be a multiple of 5.", "type": "object", "properties": { "daysUntilExpiration": { "default": 45, "title": "Daysuntilexpiration", "type": "integer" }, "delta": { "default": 15, "title": "Delta", "type": "integer" }, "direction": { "default": "sell", "enum": [ "buy", "sell" ], "title": "Direction", "type": "string" }, "quantity": { "default": 1, "title": "Quantity", "type": "integer" }, "side": { "default": "call", "enum": [ "call", "put" ], "title": "Side", "type": "string" } } }- Fields:¶
days_until_expiration (int)
- pydantic model tastytrade.backtest.BacktestParameters(*, symbol: str, startDate: date, endDate: date)¶
Bases:
BacktestDataDataclass containing valid start/end dates for a symbol.
Show JSON schema
{ "title": "BacktestParameters", "description": "Dataclass containing valid start/end dates for a symbol.", "type": "object", "properties": { "symbol": { "title": "Symbol", "type": "string" }, "startDate": { "format": "date", "title": "Startdate", "type": "string" }, "endDate": { "format": "date", "title": "Enddate", "type": "string" } }, "required": [ "symbol", "startDate", "endDate" ] }- Fields:¶
end_date (datetime.date)start_date (datetime.date)
-
pydantic model tastytrade.backtest.BacktestResponse(*, symbol: str, entryConditions: BacktestEntry, exitConditions: BacktestExit, legs: list[BacktestLeg], startDate: date, endDate: date =
datetime.date(2024, 7, 31), status: str ='pending', createdAt: datetime, id: str, results: BacktestResults, eta: int | None =None, progress: Decimal | None =None)¶ Bases:
BacktestDataclass containing a backtest and associated information.
Show JSON schema
{ "title": "BacktestResponse", "description": "Dataclass containing a backtest and associated information.", "type": "object", "properties": { "symbol": { "title": "Symbol", "type": "string" }, "entryConditions": { "$ref": "#/$defs/BacktestEntry" }, "exitConditions": { "$ref": "#/$defs/BacktestExit" }, "legs": { "items": { "$ref": "#/$defs/BacktestLeg" }, "title": "Legs", "type": "array" }, "startDate": { "format": "date", "title": "Startdate", "type": "string" }, "endDate": { "default": "2024-07-31", "format": "date", "title": "Enddate", "type": "string" }, "status": { "default": "pending", "title": "Status", "type": "string" }, "createdAt": { "format": "date-time", "title": "Createdat", "type": "string" }, "id": { "title": "Id", "type": "string" }, "results": { "$ref": "#/$defs/BacktestResults" }, "eta": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Eta" }, "progress": { "anyOf": [ { "type": "number" }, { "type": "string" }, { "type": "null" } ], "default": null, "title": "Progress" } }, "$defs": { "BacktestEntry": { "description": "Dataclass of parameters for backtest trade entry.", "properties": { "useExactDte": { "default": true, "title": "Useexactdte", "type": "boolean" }, "maximumActiveTrials": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Maximumactivetrials" }, "maximumActiveTrialsBehavior": { "anyOf": [ { "enum": [ "close oldest", "don't enter" ], "type": "string" }, { "type": "null" } ], "default": null, "title": "Maximumactivetrialsbehavior" }, "frequency": { "default": "every day", "title": "Frequency", "type": "string" } }, "title": "BacktestEntry", "type": "object" }, "BacktestExit": { "description": "Dataclass of parameters for backtest trade exit.", "properties": { "afterDaysInTrade": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Afterdaysintrade" }, "stopLossPercentage": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Stoplosspercentage" }, "takeProfitPercentage": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Takeprofitpercentage" }, "atDaysToExpiration": { "anyOf": [ { "type": "integer" }, { "type": "null" } ], "default": null, "title": "Atdaystoexpiration" } }, "title": "BacktestExit", "type": "object" }, "BacktestLeg": { "description": "Dataclass of parameters for placing legs of backtest trades.\nLeg delta must be a multiple of 5.", "properties": { "daysUntilExpiration": { "default": 45, "title": "Daysuntilexpiration", "type": "integer" }, "delta": { "default": 15, "title": "Delta", "type": "integer" }, "direction": { "default": "sell", "enum": [ "buy", "sell" ], "title": "Direction", "type": "string" }, "quantity": { "default": 1, "title": "Quantity", "type": "integer" }, "side": { "default": "call", "enum": [ "call", "put" ], "title": "Side", "type": "string" } }, "title": "BacktestLeg", "type": "object" }, "BacktestResults": { "description": "Dataclass containing partial or finished results of a backtest.", "properties": { "snapshots": { "anyOf": [ { "items": { "$ref": "#/$defs/BacktestSnapshot" }, "type": "array" }, { "type": "null" } ], "title": "Snapshots" }, "statistics": { "anyOf": [ { "$ref": "#/$defs/BacktestStatistics" }, { "type": "null" } ] }, "trials": { "anyOf": [ { "items": { "$ref": "#/$defs/BacktestTrial" }, "type": "array" }, { "type": "null" } ], "title": "Trials" } }, "required": [ "snapshots", "statistics", "trials" ], "title": "BacktestResults", "type": "object" }, "BacktestSnapshot": { "description": "Dataclass containing a snapshot in time during the backtest.", "properties": { "dateTime": { "format": "date-time", "title": "Datetime", "type": "string" }, "profitLoss": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Profitloss" }, "normalizedUnderlyingPrice": { "anyOf": [ { "type": "number" }, { "type": "string" }, { "type": "null" } ], "default": null, "title": "Normalizedunderlyingprice" }, "underlyingPrice": { "anyOf": [ { "type": "number" }, { "type": "string" }, { "type": "null" } ], "default": null, "title": "Underlyingprice" } }, "required": [ "dateTime", "profitLoss" ], "title": "BacktestSnapshot", "type": "object" }, "BacktestStatistics": { "description": "Dataclass containing statistics on the overall performance of a backtest.", "properties": { "Avg. BPR per trade": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Bpr Per Trade" }, "Avg. daily change in PNL": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Daily Change In Pnl" }, "Avg. daily change in net liq": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Daily Change In Net Liq" }, "Avg. days in trade": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Days In Trade" }, "Avg. premium": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Premium" }, "Avg. profit/loss per trade": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Profit/Loss Per Trade" }, "Avg. return per trade": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Return Per Trade" }, "Highest profit": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Highest Profit" }, "Loss percentage": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Loss Percentage" }, "Losses": { "title": "Losses", "type": "integer" }, "Max drawdown": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Max Drawdown" }, "Number of trades": { "title": "Number Of Trades", "type": "integer" }, "Premium capture rate": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Premium Capture Rate" }, "Return on used capital": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Return On Used Capital" }, "Total fees": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Total Fees" }, "Total premium": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Total Premium" }, "Total profit/loss": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Total Profit/Loss" }, "Used capital": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Used Capital" }, "Win percentage": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Win Percentage" }, "Wins": { "title": "Wins", "type": "integer" }, "Worst loss": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Worst Loss" } }, "required": [ "Avg. BPR per trade", "Avg. daily change in PNL", "Avg. daily change in net liq", "Avg. days in trade", "Avg. premium", "Avg. profit/loss per trade", "Avg. return per trade", "Highest profit", "Loss percentage", "Losses", "Max drawdown", "Number of trades", "Premium capture rate", "Return on used capital", "Total fees", "Total premium", "Total profit/loss", "Used capital", "Win percentage", "Wins", "Worst loss" ], "title": "BacktestStatistics", "type": "object" }, "BacktestTrial": { "description": "Dataclass containing information on trades placed during the backtest.", "properties": { "closeDateTime": { "format": "date-time", "title": "Closedatetime", "type": "string" }, "openDateTime": { "format": "date-time", "title": "Opendatetime", "type": "string" }, "profitLoss": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Profitloss" } }, "required": [ "closeDateTime", "openDateTime", "profitLoss" ], "title": "BacktestTrial", "type": "object" } }, "required": [ "symbol", "entryConditions", "exitConditions", "legs", "startDate", "createdAt", "id", "results" ] }- Fields:¶
created_at (datetime.datetime)
- pydantic model tastytrade.backtest.BacktestResults(*, snapshots: list[BacktestSnapshot] | None, statistics: BacktestStatistics | None, trials: list[BacktestTrial] | None)¶
Bases:
BacktestDataDataclass containing partial or finished results of a backtest.
Show JSON schema
{ "title": "BacktestResults", "description": "Dataclass containing partial or finished results of a backtest.", "type": "object", "properties": { "snapshots": { "anyOf": [ { "items": { "$ref": "#/$defs/BacktestSnapshot" }, "type": "array" }, { "type": "null" } ], "title": "Snapshots" }, "statistics": { "anyOf": [ { "$ref": "#/$defs/BacktestStatistics" }, { "type": "null" } ] }, "trials": { "anyOf": [ { "items": { "$ref": "#/$defs/BacktestTrial" }, "type": "array" }, { "type": "null" } ], "title": "Trials" } }, "$defs": { "BacktestSnapshot": { "description": "Dataclass containing a snapshot in time during the backtest.", "properties": { "dateTime": { "format": "date-time", "title": "Datetime", "type": "string" }, "profitLoss": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Profitloss" }, "normalizedUnderlyingPrice": { "anyOf": [ { "type": "number" }, { "type": "string" }, { "type": "null" } ], "default": null, "title": "Normalizedunderlyingprice" }, "underlyingPrice": { "anyOf": [ { "type": "number" }, { "type": "string" }, { "type": "null" } ], "default": null, "title": "Underlyingprice" } }, "required": [ "dateTime", "profitLoss" ], "title": "BacktestSnapshot", "type": "object" }, "BacktestStatistics": { "description": "Dataclass containing statistics on the overall performance of a backtest.", "properties": { "Avg. BPR per trade": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Bpr Per Trade" }, "Avg. daily change in PNL": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Daily Change In Pnl" }, "Avg. daily change in net liq": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Daily Change In Net Liq" }, "Avg. days in trade": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Days In Trade" }, "Avg. premium": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Premium" }, "Avg. profit/loss per trade": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Profit/Loss Per Trade" }, "Avg. return per trade": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Return Per Trade" }, "Highest profit": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Highest Profit" }, "Loss percentage": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Loss Percentage" }, "Losses": { "title": "Losses", "type": "integer" }, "Max drawdown": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Max Drawdown" }, "Number of trades": { "title": "Number Of Trades", "type": "integer" }, "Premium capture rate": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Premium Capture Rate" }, "Return on used capital": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Return On Used Capital" }, "Total fees": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Total Fees" }, "Total premium": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Total Premium" }, "Total profit/loss": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Total Profit/Loss" }, "Used capital": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Used Capital" }, "Win percentage": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Win Percentage" }, "Wins": { "title": "Wins", "type": "integer" }, "Worst loss": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Worst Loss" } }, "required": [ "Avg. BPR per trade", "Avg. daily change in PNL", "Avg. daily change in net liq", "Avg. days in trade", "Avg. premium", "Avg. profit/loss per trade", "Avg. return per trade", "Highest profit", "Loss percentage", "Losses", "Max drawdown", "Number of trades", "Premium capture rate", "Return on used capital", "Total fees", "Total premium", "Total profit/loss", "Used capital", "Win percentage", "Wins", "Worst loss" ], "title": "BacktestStatistics", "type": "object" }, "BacktestTrial": { "description": "Dataclass containing information on trades placed during the backtest.", "properties": { "closeDateTime": { "format": "date-time", "title": "Closedatetime", "type": "string" }, "openDateTime": { "format": "date-time", "title": "Opendatetime", "type": "string" }, "profitLoss": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Profitloss" } }, "required": [ "closeDateTime", "openDateTime", "profitLoss" ], "title": "BacktestTrial", "type": "object" } }, "required": [ "snapshots", "statistics", "trials" ] }
- class tastytrade.backtest.BacktestSession(session: Session)¶
Bases:
objectClass for creating a backtesting session which can be reused for multiple backtests.
Example usage:
from tastytrade import BacktestSession, Backtest from tqdm.asyncio import tqdm # progress bar backtest = Backtest(...) backtest_session = BacktestSession(session) results = [r async for r in tqdm(backtest_session.run(backtest))] print(results[-1])- async available_parameters() list[BacktestParameters]¶
Get a list of available symbols for backtesting, as well as valid testing dates for each symbol.
- async cancel(backtest_id: str) bool¶
Cancel the running backtest with the given ID.
- async get(backtest_id: str) BacktestResponse¶
Fetch a specific past backtest by ID.
- async run(backtest: Backtest) AsyncGenerator[BacktestResponse, None]¶
Run the given backtest and yield results progresively.
-
pydantic model tastytrade.backtest.BacktestSnapshot(*, dateTime: datetime, profitLoss: Decimal, normalizedUnderlyingPrice: Decimal | None =
None, underlyingPrice: Decimal | None =None)¶ Bases:
BacktestDataDataclass containing a snapshot in time during the backtest.
Show JSON schema
{ "title": "BacktestSnapshot", "description": "Dataclass containing a snapshot in time during the backtest.", "type": "object", "properties": { "dateTime": { "format": "date-time", "title": "Datetime", "type": "string" }, "profitLoss": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Profitloss" }, "normalizedUnderlyingPrice": { "anyOf": [ { "type": "number" }, { "type": "string" }, { "type": "null" } ], "default": null, "title": "Normalizedunderlyingprice" }, "underlyingPrice": { "anyOf": [ { "type": "number" }, { "type": "string" }, { "type": "null" } ], "default": null, "title": "Underlyingprice" } }, "required": [ "dateTime", "profitLoss" ] }- Fields:¶
date_time (datetime.datetime)normalized_underlying_price (decimal.Decimal | None)profit_loss (decimal.Decimal)underlying_price (decimal.Decimal | None)
- pydantic model tastytrade.backtest.BacktestStatistics(*, avg_bp_per_trade: Decimal, avg_daily_pnl_change: Decimal, avg_daily_net_liq_change: Decimal, avg_days_in_trade: Decimal, avg_premium: Decimal, avg_profit_loss_per_trade: Decimal, avg_return_per_trade: Decimal, highest_profit: Decimal, loss_percentage: Decimal, Losses: int, max_drawdown: Decimal, number_of_trades: int, premium_capture_rate: Decimal, return_on_used_capital: Decimal, total_fees: Decimal, total_premium: Decimal, total_profit_loss: Decimal, used_capital: Decimal, win_percentage: Decimal, Wins: int, worst_loss: Decimal)¶
Bases:
BaseModelDataclass containing statistics on the overall performance of a backtest.
Show JSON schema
{ "title": "BacktestStatistics", "description": "Dataclass containing statistics on the overall performance of a backtest.", "type": "object", "properties": { "Avg. BPR per trade": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Bpr Per Trade" }, "Avg. daily change in PNL": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Daily Change In Pnl" }, "Avg. daily change in net liq": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Daily Change In Net Liq" }, "Avg. days in trade": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Days In Trade" }, "Avg. premium": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Premium" }, "Avg. profit/loss per trade": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Profit/Loss Per Trade" }, "Avg. return per trade": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Avg. Return Per Trade" }, "Highest profit": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Highest Profit" }, "Loss percentage": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Loss Percentage" }, "Losses": { "title": "Losses", "type": "integer" }, "Max drawdown": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Max Drawdown" }, "Number of trades": { "title": "Number Of Trades", "type": "integer" }, "Premium capture rate": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Premium Capture Rate" }, "Return on used capital": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Return On Used Capital" }, "Total fees": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Total Fees" }, "Total premium": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Total Premium" }, "Total profit/loss": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Total Profit/Loss" }, "Used capital": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Used Capital" }, "Win percentage": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Win Percentage" }, "Wins": { "title": "Wins", "type": "integer" }, "Worst loss": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Worst Loss" } }, "required": [ "Avg. BPR per trade", "Avg. daily change in PNL", "Avg. daily change in net liq", "Avg. days in trade", "Avg. premium", "Avg. profit/loss per trade", "Avg. return per trade", "Highest profit", "Loss percentage", "Losses", "Max drawdown", "Number of trades", "Premium capture rate", "Return on used capital", "Total fees", "Total premium", "Total profit/loss", "Used capital", "Win percentage", "Wins", "Worst loss" ] }- Fields:¶
losses (int)wins (int)
- pydantic model tastytrade.backtest.BacktestTrial(*, closeDateTime: datetime, openDateTime: datetime, profitLoss: Decimal)¶
Bases:
BacktestDataDataclass containing information on trades placed during the backtest.
Show JSON schema
{ "title": "BacktestTrial", "description": "Dataclass containing information on trades placed during the backtest.", "type": "object", "properties": { "closeDateTime": { "format": "date-time", "title": "Closedatetime", "type": "string" }, "openDateTime": { "format": "date-time", "title": "Opendatetime", "type": "string" }, "profitLoss": { "anyOf": [ { "type": "number" }, { "type": "string" } ], "title": "Profitloss" } }, "required": [ "closeDateTime", "openDateTime", "profitLoss" ] }- Fields:¶
close_date_time (datetime.datetime)open_date_time (datetime.datetime)profit_loss (decimal.Decimal)