Command-Line Interface (CLI)¶
This CLI
package contains the main entry point and command structure for
the optpricing command-line interface.
backtest ¶
backtest(
ticker: Annotated[
str,
Option(
"--ticker",
"-t",
help="The stock ticker to backtest.",
),
],
model: Annotated[
str,
Option(
"--model",
"-m",
help="The single model to backtest.",
),
],
verbose: Annotated[
bool,
Option(
"--verbose",
"-v",
help="Enable detailed logging.",
),
] = False,
)
Runs a historical backtest for a given model and ticker.
Source code in src/optpricing/cli/commands/backtest.py
calibrate ¶
calibrate(
ticker: Annotated[
str,
Option(
"--ticker",
"-t",
help="The stock ticker to calibrate against.",
),
],
model: Annotated[
list[str],
Option(
"--model",
"-m",
help="Model to calibrate. Can be used multiple times.",
),
],
date: Annotated[
str | None,
Option(
"--date",
"-d",
help="Snapshot date (YYYY-MM-DD). Defaults to latest available.",
),
] = None,
fix_param: Annotated[
list[str] | None,
Option(
"--fix",
help="Fix a parameter (e.g., 'sigma=0.25'). Can be used multiple times.",
),
] = None,
verbose: Annotated[
bool,
Option(
"--verbose",
"-v",
help="Enable detailed logging.",
),
] = False,
)
Calibrates one or more models to market data for a given ticker and date.
Source code in src/optpricing/cli/commands/calibrate.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
|
dashboard ¶
Launches the Streamlit dashboard application.
Source code in src/optpricing/cli/commands/dashboard.py
download_data ¶
download_data(
tickers: Annotated[
list[str] | None,
Option(
"--ticker",
"-t",
help="Stock ticker to download. Can be used multiple times.",
),
] = None,
all_default: Annotated[
bool,
Option(
"--all",
help="Download all default tickers specified in config.yaml.",
),
] = False,
period: Annotated[
str,
Option(
"--period",
"-p",
help="Time period for historical data (e.g., '10y', '5y').",
),
] = "10y",
)
Downloads and saves historical log returns for specified tickers or all defaults.
Source code in src/optpricing/cli/commands/data.py
get_dividends ¶
get_dividends(
tickers: Annotated[
list[str] | None,
Option(
"--ticker",
"-t",
help="Stock ticker to fetch. Can be used multiple times.",
),
] = None,
all_default: Annotated[
bool,
Option(
"--all",
help="Fetch for all default tickers specified in config.yaml.",
),
] = False,
)
Fetches and displays the live forward dividend yield for specified tickers.
Source code in src/optpricing/cli/commands/data.py
save_snapshot ¶
save_snapshot(
tickers: Annotated[
list[str] | None,
Option(
"--ticker",
"-t",
help="Stock ticker to snapshot. Can be used multiple times.",
),
] = None,
all_default: Annotated[
bool,
Option(
"--all",
help="Snapshot all default tickers specified in config.yaml.",
),
] = False,
)
Fetches and saves a live market data snapshot for specified tickers.
Source code in src/optpricing/cli/commands/data.py
demo_american ¶
demo_european ¶
demo_european(
model: Annotated[
str | None,
Option(
"--model",
"-m",
help="Run for a specific model (e.g., 'BSM').",
case_sensitive=False,
),
] = None,
technique: Annotated[
str | None,
Option(
"--technique",
"-t",
help="Run for a specific technique (e.g., 'MC').",
case_sensitive=False,
),
] = None,
)
Runs the European options pricing and performance benchmark.
Source code in src/optpricing/cli/commands/demo.py
price ¶
price(
ticker: Annotated[
str, Option("--ticker", "-t", help="Stock ticker.")
],
strike: Annotated[
float,
Option("--strike", "-k", help="Strike price."),
],
maturity: Annotated[
str,
Option(
"--maturity", "-T", help="Maturity YYYY-MM-DD."
),
],
option_type: Annotated[
str,
Option(
"--type", help="call|put", case_sensitive=False
),
] = "call",
style: Annotated[
str,
Option(
"--style",
help="european|american",
case_sensitive=False,
),
] = "european",
model: Annotated[
str, Option("--model", "-m", help="Model key.")
] = "BSM",
technique: Annotated[
str | None,
Option(
"--technique",
"-x",
help="Force technique key (e.g., mc, crr).",
case_sensitive=False,
),
] = None,
param: Annotated[
list[str] | None,
Option(
"--param",
help="Repeat: key=value (e.g. sigma=0.2)",
show_default=False,
),
] = None,
)
Prices a single option using live market data and specified parameters.
Source code in src/optpricing/cli/commands/price.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
get_implied_rate ¶
get_implied_rate(
ticker: Annotated[
str,
Option(
"--ticker",
"-t",
help="Stock ticker for the option pair.",
),
],
strike: Annotated[
float,
Option(
"--strike",
"-k",
help="Strike price of the option pair.",
),
],
maturity: Annotated[
str,
Option(
"--maturity",
"-T",
help="Maturity date in YYYY-MM-DD format.",
),
],
)
Calculates the implied risk-free rate from a live call-put pair.