🕸️ Core¤
The core
module to contain logic & functions used in controllers.
This module is intended to contain sub-modules and functions that are not directly utilized from the package, but rather used in building the package itself. This means that the core module should not contain any code that is specific to the package's use case, but rather should be generic and reusable in other contexts.
humbldata.core.standard_models
¤
Models to represent core data structures of the Standardization Framework.
humbldata.core.standard_models.abstract
¤
Abstract core DATA MODELS to be inherited by other models.
humbldata.core.standard_models.abstract.errors
¤
An ABSTRACT DATA MODEL to be inherited by custom errors.
humbldata.core.standard_models.abstract.errors.HumblDataError
¤
Bases: BaseException
Base Error for HumblData logic.
Source code in src/humbldata/core/standard_models/abstract/errors.py
4 5 6 7 8 9 |
|
humbldata.core.standard_models.abstract.query_params
¤
A wrapper around OpenBB QueryParams Standardized Model to use with humbldata.
humbldata.core.standard_models.abstract.query_params.QueryParams
¤
Bases: QueryParams
An abstract standard_model to represent a base QueryParams Data.
QueryParams model should be used to define the query parameters for a
context.category.command
call.
This QueryParams model is meant to be inherited and built upon by other standard_models for a specific context.
Examples:
class EquityHistoricalQueryParams(QueryParams):
symbol: str = Field(description=QUERY_DESCRIPTIONS.get("symbol", ""))
interval: Optional[str] = Field(
default="1d",
description=QUERY_DESCRIPTIONS.get("interval", ""),
)
start_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("start_date", ""),
)
end_date: Optional[dateType] = Field(
default=None,
description=QUERY_DESCRIPTIONS.get("end_date", ""),
)
@field_validator("symbol", mode="before", check_fields=False)
@classmethod
def upper_symbol(cls, v: Union[str, List[str], Set[str]]):
if isinstance(v, str):
return v.upper()
return ",".join([symbol.upper() for symbol in list(v)])
This would create a class that would be used to query historical price data for equities from any given command.
This could then be used to create a
MandelbrotChannelEquityHistoricalQueryParams
that would define what query
parameters are needed for the Mandelbrot Channel command.
Source code in src/humbldata/core/standard_models/abstract/query_params.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 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 |
|
humbldata.core.standard_models.abstract.singleton
¤
An ABSTRACT DATA MODEL, Singleton, to represent a class that should only have one instance.
humbldata.core.standard_models.abstract.singleton.SingletonMeta
¤
Bases: type
, Generic[T]
SingletonMeta is a metaclass that creates a Singleton instance of a class.
Singleton design pattern restricts the instantiation of a class to a single instance. This is useful when exactly one object is needed to coordinate actions across the system.
Source code in src/humbldata/core/standard_models/abstract/singleton.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
humbldata.core.standard_models.abstract.singleton.SingletonMeta.__call__
¤
__call__(*args, **kwargs) -> T
Override the call method.
If the class exists, otherwise creates a new instance and stores it in the _instances dictionary.
Source code in src/humbldata/core/standard_models/abstract/singleton.py
21 22 23 24 25 26 27 28 29 30 31 32 |
|
humbldata.core.standard_models.abstract.chart
¤
humbldata.core.standard_models.abstract.chart.ChartTemplate
¤
Bases: str
, Enum
Chart format.
Available options: - plotly - humbl_light - humbl_dark - plotly_light - plotly_dark - ggplot2 - seaborn - simple_white - presentation - xgridoff - ygridoff - gridon - none
Source code in src/humbldata/core/standard_models/abstract/chart.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
humbldata.core.standard_models.abstract.chart.Chart
¤
Bases: BaseModel
a Chart Object that is returned from a View.
Source code in src/humbldata/core/standard_models/abstract/chart.py
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 |
|
humbldata.core.standard_models.abstract.chart.Chart.__repr__
¤
__repr__() -> str
Human readable representation of the object.
Source code in src/humbldata/core/standard_models/abstract/chart.py
60 61 62 63 64 65 66 67 |
|
humbldata.core.standard_models.abstract.data
¤
A wrapper around OpenBB Data Standardized Model to use with humbldata.
humbldata.core.standard_models.abstract.data.Data
¤
Bases: DataFrameModel
An abstract standard_model to represent a base Data Model.
The Data Model should be used to define the data that is being
collected and analyzed in a context.category.command
call.
This Data model is meant to be inherited and built upon by other standard_models for a specific context.
Example
class EquityHistoricalData(Data):
date: Union[dateType, datetime] = Field(
description=DATA_DESCRIPTIONS.get("date", "")
)
open: float = Field(description=DATA_DESCRIPTIONS.get("open", ""))
high: float = Field(description=DATA_DESCRIPTIONS.get("high", ""))
low: float = Field(description=DATA_DESCRIPTIONS.get("low", ""))
close: float = Field(description=DATA_DESCRIPTIONS.get("close", ""))
volume: Optional[Union[float, int]] = Field(
default=None, description=DATA_DESCRIPTIONS.get("volume", "")
)
@field_validator("date", mode="before", check_fields=False)
def date_validate(cls, v): # pylint: disable=E0213
v = parser.isoparse(str(v))
if v.hour == 0 and v.minute == 0:
return v.date()
return v
Source code in src/humbldata/core/standard_models/abstract/data.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
humbldata.core.standard_models.abstract.humblobject
¤
humbldata.core.standard_models.abstract.humblobject.extract_subclass_dict
¤
extract_subclass_dict(self, attribute_name: str, items: list)
Extract the dictionary representation of the specified attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attribute_name |
str
|
The name of the attribute to update in the items list. |
required |
Source code in src/humbldata/core/standard_models/abstract/humblobject.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
humbldata.core.standard_models.abstract.humblobject.HumblObject
¤
Bases: Tagged
, Generic[T]
HumblObject is the base class for all dta returned from the Toolbox.
Source code in src/humbldata/core/standard_models/abstract/humblobject.py
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 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
|
humbldata.core.standard_models.abstract.humblobject.HumblObject.__repr__
¤
__repr__() -> str
Human readable representation of the object.
Source code in src/humbldata/core/standard_models/abstract/humblobject.py
104 105 106 107 108 109 110 111 112 113 114 |
|
humbldata.core.standard_models.abstract.humblobject.HumblObject.to_polars
¤
to_polars(collect: bool = True, equity_data: bool = False) -> LazyFrame | DataFrame
Deserialize the stored results or return the LazyFrame, and optionally collect them into a Polars DataFrame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collect |
bool
|
If True, collects the deserialized LazyFrame into a DataFrame. Default is True. |
True
|
equity_data |
bool
|
If True, processes equity_data instead of results. Default is False. |
False
|
Returns:
Type | Description |
---|---|
LazyFrame | DataFrame
|
The results as a Polars LazyFrame or DataFrame, depending on the collect parameter. |
Raises:
Type | Description |
---|---|
HumblDataError
|
If no results or equity data are found to process |
Source code in src/humbldata/core/standard_models/abstract/humblobject.py
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 |
|
humbldata.core.standard_models.abstract.humblobject.HumblObject.to_df
¤
to_df(collect: bool = True, equity_data: bool = False) -> LazyFrame | DataFrame
Alias for the to_polars
method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collect |
bool
|
If True, collects the deserialized LazyFrame into a DataFrame. Default is True. |
True
|
Returns:
Type | Description |
---|---|
LazyFrame | DataFrame
|
The deserialized results as a Polars LazyFrame or DataFrame, depending on the collect parameter. |
Source code in src/humbldata/core/standard_models/abstract/humblobject.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
|
humbldata.core.standard_models.abstract.humblobject.HumblObject.to_pandas
¤
to_pandas(equity_data: bool = False) -> DataFrame
Convert the results to a Pandas DataFrame.
Returns:
Type | Description |
---|---|
DataFrame
|
The results as a Pandas DataFrame. |
Source code in src/humbldata/core/standard_models/abstract/humblobject.py
185 186 187 188 189 190 191 192 193 194 |
|
humbldata.core.standard_models.abstract.humblobject.HumblObject.to_numpy
¤
to_numpy(equity_data: bool = False) -> ndarray
Convert the results to a NumPy array.
Returns:
Type | Description |
---|---|
ndarray
|
The results as a NumPy array. |
Source code in src/humbldata/core/standard_models/abstract/humblobject.py
196 197 198 199 200 201 202 203 204 205 |
|
humbldata.core.standard_models.abstract.humblobject.HumblObject.to_dict
¤
to_dict(row_wise: bool = False, equity_data: bool = False, as_series: bool = True) -> dict | list[dict]
Transform the stored data into a dictionary or a list of dictionaries.
This method allows for the conversion of the internal data representation into a more universally accessible format, either aggregating the entire dataset into a single dictionary (column-wise) or breaking it down into a list of dictionaries, each representing a row in the dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
row_wise |
bool
|
Determines the format of the output. If set to True, the method returns a list of dictionaries, with each dictionary representing a row and its corresponding data as key-value pairs. If set to False, the method returns a single dictionary, with column names as keys and lists of column data as values. Default is False. |
False
|
equity_data |
bool
|
A flag to specify whether to use equity-specific data for the conversion. This parameter allows for flexibility in handling different types of data stored within the object. Default is False. |
False
|
as_series |
bool
|
If True, the method returns a pl.Series with values as Series. If False, the method returns a dict with values as List[Any]. Default is True. |
True
|
Returns:
Type | Description |
---|---|
dict | list[dict]
|
Depending on the |
Source code in src/humbldata/core/standard_models/abstract/humblobject.py
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 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
|
humbldata.core.standard_models.abstract.humblobject.HumblObject.to_arrow
¤
to_arrow(equity_data: bool = False) -> Table
Convert the results to an Arrow Table.
Returns:
Type | Description |
---|---|
Table
|
The results as an Arrow Table. |
Source code in src/humbldata/core/standard_models/abstract/humblobject.py
254 255 256 257 258 259 260 261 262 263 |
|
humbldata.core.standard_models.abstract.humblobject.HumblObject.to_struct
¤
to_struct(name: str = 'results', equity_data: bool = False) -> Series
Convert the results to a struct.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the struct. Default is "results". |
'results'
|
Returns:
Type | Description |
---|---|
Struct
|
The results as a struct. |
Source code in src/humbldata/core/standard_models/abstract/humblobject.py
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|
humbldata.core.standard_models.abstract.humblobject.HumblObject.to_json
¤
to_json(equity_data: bool = False, chart: bool = False) -> str | list[str]
Convert the results to a JSON string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
equity_data |
bool
|
A flag to specify whether to use equity-specific data for the conversion. Default is False. |
False
|
chart |
bool
|
If True, return all generated charts as a JSON string instead of returning the results. Default is False. |
False
|
Returns:
Type | Description |
---|---|
str
|
The results or charts as a JSON string. |
Raises:
Type | Description |
---|---|
HumblDataError
|
If chart is True but no charts are available. |
Source code in src/humbldata/core/standard_models/abstract/humblobject.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
|
humbldata.core.standard_models.abstract.humblobject.HumblObject.is_empty
¤
is_empty(equity_data: bool = False) -> bool
Check if the results are empty.
Returns:
Type | Description |
---|---|
bool
|
True if the results are empty, False otherwise. |
Source code in src/humbldata/core/standard_models/abstract/humblobject.py
343 344 345 346 347 348 349 350 351 352 |
|
humbldata.core.standard_models.abstract.humblobject.HumblObject.show
¤
show() -> None
Show the chart.
Source code in src/humbldata/core/standard_models/abstract/humblobject.py
354 355 356 357 358 359 360 361 362 363 364 365 |
|
humbldata.core.standard_models.abstract.tagged
¤
An ABSTRACT DATA MODEL, Tagged, to be inherited by other models as identifier.
humbldata.core.standard_models.abstract.tagged.Tagged
¤
Bases: BaseModel
A class to represent an object tagged with a uuid7.
Source code in src/humbldata/core/standard_models/abstract/tagged.py
7 8 9 10 |
|
humbldata.core.standard_models.portfolio
¤
Context: Portfolio || Category: Analytics.
This module defines the QueryParams and Data classes for the Portfolio context.
humbldata.core.standard_models.portfolio.analytics
¤
humbldata.core.standard_models.portfolio.analytics.etf_category
¤
UserTable Standard Model.
Context: Portfolio || Category: Analytics || Command: user_table.
This module is used to define the QueryParams and Data model for the UserTable command.
humbldata.core.standard_models.portfolio.analytics.etf_category.ETFCategoryData
¤
Bases: Data
Data model for the etf_category command, a Pandera.Polars Model.
Used for simple validation of ETF category data for the UserTableFetcher
internal logic aggregate_user_table_data()
Source code in src/humbldata/core/standard_models/portfolio/analytics/etf_category.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
|
humbldata.core.standard_models.portfolio.analytics.user_table
¤
UserTable Standard Model.
Context: Portfolio || Category: Analytics || Command: user_table.
This module is used to define the QueryParams and Data model for the UserTable command.
humbldata.core.standard_models.portfolio.analytics.user_table.UserTableQueryParams
¤
Bases: QueryParams
QueryParams model for the UserTable command, a Pydantic v2 model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
symbols |
str | list[str] | set[str]
|
The symbol or ticker of the stock(s). Can be a single symbol, a comma-separated string, or a list/set of symbols. Default is "AAPL". Examples: "AAPL", "AAPL,MSFT", ["AAPL", "MSFT"] All inputs will be converted to uppercase. |
required |
Notes
The symbols
input will be processed to ensure all symbols are uppercase
and properly formatted, regardless of the input format.
Source code in src/humbldata/core/standard_models/portfolio/analytics/user_table.py
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 |
|
humbldata.core.standard_models.portfolio.analytics.user_table.UserTableQueryParams.upper_symbol
classmethod
¤upper_symbol(v: str | list[str] | set[str]) -> str | list[str]
Convert the stock symbol to uppercase.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v |
Union[str, List[str], Set[str]]
|
The stock symbol or collection of symbols to be converted. |
required |
Returns:
Type | Description |
---|---|
Union[str, List[str]]
|
The uppercase stock symbol or a comma-separated string of uppercase symbols. |
Source code in src/humbldata/core/standard_models/portfolio/analytics/user_table.py
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 |
|
humbldata.core.standard_models.portfolio.analytics.user_table.UserTableData
¤
Bases: Data
Data model for the user_table command, a Pandera.Polars Model.
This Data model is used to validate data in the .transform_data()
method of the UserTableFetcher
class.
Attributes:
Name | Type | Description |
---|---|---|
symbol |
Utf8
|
The stock symbol. |
last_price |
Float64
|
The last known price of the stock. |
buy_price |
Float64
|
The recommended buy price for the stock. |
sell_price |
Float64
|
The recommended sell price for the stock. |
ud_pct |
Utf8
|
The upside/downside percentage. |
ud_ratio |
Float64
|
The upside/downside ratio. |
asset_class |
Utf8
|
The asset class of the stock. |
sector |
Utf8
|
The sector of the stock. |
humbl_suggestion |
Utf8 | None
|
The suggestion provided by HUMBL. |
Methods:
Name | Description |
---|---|
None |
|
Source code in src/humbldata/core/standard_models/portfolio/analytics/user_table.py
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 |
|
humbldata.core.standard_models.portfolio.analytics.user_table.UserTableFetcher
¤
Fetcher for the UserTable command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context_params |
PortfolioQueryParams
|
The context parameters for the Portfolio query. |
required |
command_params |
UserTableQueryParams
|
The command-specific parameters for the UserTable query. |
required |
Attributes:
Name | Type | Description |
---|---|---|
context_params |
PortfolioQueryParams
|
Stores the context parameters passed during initialization. |
command_params |
UserTableQueryParams
|
Stores the command-specific parameters passed during initialization. |
data |
DataFrame
|
The raw data extracted from the data provider, before transformation. |
Methods:
Name | Description |
---|---|
transform_query |
Transform the command-specific parameters into a query. |
extract_data |
Extracts the data from the provider and returns it as a Polars DataFrame. |
transform_data |
Transforms the command-specific data according to the UserTable logic. |
fetch_data |
Execute TET Pattern. |
Returns:
Type | Description |
---|---|
HumblObject
|
results : UserTableData Serializable results. provider : Literal['fmp', 'intrinio', 'polygon', 'tiingo', 'yfinance'] Provider name. warnings : Optional[List[Warning_]] List of warnings. chart : Optional[Chart] Chart object. context_params : PortfolioQueryParams Context-specific parameters. command_params : UserTableQueryParams Command-specific parameters. |
Source code in src/humbldata/core/standard_models/portfolio/analytics/user_table.py
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 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
|
humbldata.core.standard_models.portfolio.analytics.user_table.UserTableFetcher.__init__
¤__init__(context_params: PortfolioQueryParams, command_params: UserTableQueryParams)
Initialize the UserTableFetcher with context and command parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context_params |
PortfolioQueryParams
|
The context parameters for the Portfolio query. |
required |
command_params |
UserTableQueryParams
|
The command-specific parameters for the UserTable query. |
required |
Source code in src/humbldata/core/standard_models/portfolio/analytics/user_table.py
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
|
humbldata.core.standard_models.portfolio.analytics.user_table.UserTableFetcher.transform_query
¤transform_query()
Transform the command-specific parameters into a query.
If command_params is not provided, it initializes a default UserTableQueryParams object.
Source code in src/humbldata/core/standard_models/portfolio/analytics/user_table.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 |
|
humbldata.core.standard_models.portfolio.analytics.user_table.UserTableFetcher.extract_data
async
¤extract_data()
Extract the data from the provider and returns it as a Polars DataFrame.
Returns:
Type | Description |
---|---|
DataFrame
|
The extracted data as a Polars DataFrame. |
Source code in src/humbldata/core/standard_models/portfolio/analytics/user_table.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
humbldata.core.standard_models.portfolio.analytics.user_table.UserTableFetcher.transform_data
async
¤transform_data()
Transform the command-specific data according to the user_table logic.
Returns:
Type | Description |
---|---|
DataFrame
|
The transformed data as a Polars DataFrame |
Source code in src/humbldata/core/standard_models/portfolio/analytics/user_table.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 |
|
humbldata.core.standard_models.portfolio.analytics.user_table.UserTableFetcher.fetch_data
async
¤fetch_data()
Execute TET Pattern.
This method executes the query transformation, data fetching and
transformation process by first calling transform_query
to prepare the query parameters, then
extracting the raw data using extract_data
method, and finally
transforming the raw data using transform_data
method.
Returns:
Type | Description |
---|---|
HumblObject
|
The HumblObject containing the transformed data and metadata. |
Source code in src/humbldata/core/standard_models/portfolio/analytics/user_table.py
308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
|
humbldata.core.standard_models.portfolio.PortfolioQueryParams
¤
Bases: QueryParams
Query parameters for the PortfolioController.
This class defines the query parameters used by the PortfolioController.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
symbol |
str or list of str
|
The stock symbol(s) to query. Default is "AAPL". |
required |
provider |
OBB_EQUITY_PRICE_HISTORICAL_PROVIDERS
|
The data provider for historical price data. Default is "yahoo". |
required |
membership |
Literal['anonymous', 'humblPEON', 'humblPREMIUM', 'humblPOWER', 'humblPERMANENT', 'admin']
|
The membership level of the user accessing the data. Default is "anonymous". |
required |
Attributes:
Name | Type | Description |
---|---|---|
symbol |
str or list of str
|
The stock symbol(s) to query. |
provider |
OBB_EQUITY_PRICE_HISTORICAL_PROVIDERS
|
The data provider for historical price data. |
membership |
Literal['anonymous', 'humblPEON', 'humblPREMIUM', 'humblPOWER', 'humblPERMANENT', 'admin']
|
The membership level of the user. |
Source code in src/humbldata/core/standard_models/portfolio/__init__.py
18 19 20 21 22 23 24 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 |
|
humbldata.core.standard_models.portfolio.PortfolioQueryParams.upper_symbol
classmethod
¤
upper_symbol(v: str | list[str] | set[str]) -> list[str]
Convert the stock symbols to uppercase and remove empty strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v |
Union[str, List[str], Set[str]]
|
The stock symbol or collection of symbols to be converted. |
required |
Returns:
Type | Description |
---|---|
List[str]
|
A list of uppercase stock symbols with empty strings removed. |
Source code in src/humbldata/core/standard_models/portfolio/__init__.py
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 |
|
humbldata.core.standard_models.portfolio.PortfolioData
¤
Bases: Data
The Data for the PortfolioController.
Source code in src/humbldata/core/standard_models/portfolio/__init__.py
101 102 103 104 105 106 107 |
|
humbldata.core.standard_models.toolbox
¤
Context: Toolbox || Category: Standardized Framework Model.
This module defines the QueryParams and Data classes for the Toolbox context. THis is where all of the context(s) of your project go. The STANDARD MODELS for categories and subsequent commands are nested here.
Classes:
Name | Description |
---|---|
ToolboxQueryParams |
Query parameters for the ToolboxController. |
ToolboxData |
A Pydantic model that defines the data returned by the ToolboxController. |
Attributes:
Name | Type | Description |
---|---|---|
symbol |
str
|
The symbol/ticker of the stock. |
interval |
Optional[str]
|
The interval of the data. Defaults to '1d'. |
start_date |
str
|
The start date of the data. |
end_date |
str
|
The end date of the data. |
humbldata.core.standard_models.toolbox.fundamental
¤
humbldata.core.standard_models.toolbox.fundamental.humbl_compass
¤
HumblCompass Standard Model.
Context: Toolbox || Category: Fundamental || Command: humbl_compass.
This module is used to define the QueryParams and Data model for the HumblCompass command.
humbldata.core.standard_models.toolbox.fundamental.humbl_compass.AssetRecommendation
¤
Bases: str
, Enum
Asset recommendation categories.
Source code in src/humbldata/core/standard_models/toolbox/fundamental/humbl_compass.py
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 |
|
humbldata.core.standard_models.toolbox.fundamental.humbl_compass.RecommendationCategory
¤
Bases: BaseModel
Category-specific recommendations with rationale.
Source code in src/humbldata/core/standard_models/toolbox/fundamental/humbl_compass.py
106 107 108 109 110 111 |
|
humbldata.core.standard_models.toolbox.fundamental.humbl_compass.RegimeRecommendations
¤
Bases: BaseModel
Complete set of recommendations for a specific regime.
Source code in src/humbldata/core/standard_models/toolbox/fundamental/humbl_compass.py
114 115 116 117 118 119 120 121 122 123 |
|
humbldata.core.standard_models.toolbox.fundamental.humbl_compass.HumblCompassQueryParams
¤
Bases: QueryParams
QueryParams model for the HumblCompass command, a Pydantic v2 model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
country |
Literal
|
The country or group of countries to collect humblCOMPASS data for. |
required |
cli_start_date |
str
|
The adjusted start date for CLI data collection. |
required |
cpi_start_date |
str
|
The adjusted start date for CPI data collection. |
required |
z_score |
Optional[str]
|
The time window for z-score calculation (e.g., "1 year", "18 months"). |
required |
chart |
bool
|
Whether to return a chart object. |
required |
template |
Literal
|
The template/theme to use for the plotly figure. |
required |
Source code in src/humbldata/core/standard_models/toolbox/fundamental/humbl_compass.py
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 |
|
humbldata.core.standard_models.toolbox.fundamental.humbl_compass.HumblCompassData
¤
Bases: Data
Data model for the humbl_compass command, a Pandera.Polars Model.
This Data model is used to validate data in the .transform_data()
method of the HumblCompassFetcher
class.
Source code in src/humbldata/core/standard_models/toolbox/fundamental/humbl_compass.py
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
|
humbldata.core.standard_models.toolbox.fundamental.humbl_compass.HumblCompassFetcher
¤
Fetcher for the HumblCompass command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context_params |
ToolboxQueryParams
|
The context parameters for the Toolbox query. |
required |
command_params |
HumblCompassQueryParams
|
The command-specific parameters for the HumblCompass query. |
required |
Attributes:
Name | Type | Description |
---|---|---|
context_params |
ToolboxQueryParams
|
Stores the context parameters passed during initialization. |
command_params |
HumblCompassQueryParams
|
Stores the command-specific parameters passed during initialization. |
data |
DataFrame
|
The raw data extracted from the data provider, before transformation. |
Methods:
Name | Description |
---|---|
transform_query |
Transform the command-specific parameters into a query. |
extract_data |
Extracts the data from the provider and returns it as a Polars DataFrame. |
transform_data |
Transforms the command-specific data according to the HumblCompass logic. |
fetch_data |
Execute TET Pattern. |
Returns:
Type | Description |
---|---|
HumblObject
|
results : HumblCompassData Serializable results. provider : Literal['fmp', 'intrinio', 'polygon', 'tiingo', 'yfinance'] Provider name. warnings : Optional[List[Warning_]] List of warnings. chart : Optional[Chart] Chart object. context_params : ToolboxQueryParams Context-specific parameters. command_params : HumblCompassQueryParams Command-specific parameters. |
Source code in src/humbldata/core/standard_models/toolbox/fundamental/humbl_compass.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 |
|
humbldata.core.standard_models.toolbox.fundamental.humbl_compass.HumblCompassFetcher.__init__
¤__init__(context_params: ToolboxQueryParams, command_params: HumblCompassQueryParams)
Initialize the HumblCompassFetcher with context and command parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context_params |
ToolboxQueryParams
|
The context parameters for the Toolbox query. |
required |
command_params |
HumblCompassQueryParams
|
The command-specific parameters for the HumblCompass query. |
required |
Source code in src/humbldata/core/standard_models/toolbox/fundamental/humbl_compass.py
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
|
humbldata.core.standard_models.toolbox.fundamental.humbl_compass.HumblCompassFetcher.transform_query
¤transform_query()
Transform the command-specific parameters into a query.
If command_params is not provided, it initializes a default HumblCompassQueryParams object. Calculates adjusted start dates for CLI and CPI data collection.
Source code in src/humbldata/core/standard_models/toolbox/fundamental/humbl_compass.py
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 |
|
humbldata.core.standard_models.toolbox.fundamental.humbl_compass.HumblCompassFetcher.extract_data
¤extract_data()
Extract the data from the provider and returns it as a Polars DataFrame.
Returns:
Type | Description |
---|---|
self
|
The HumblCompassFetcher instance with extracted data. |
Source code in src/humbldata/core/standard_models/toolbox/fundamental/humbl_compass.py
659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 |
|
humbldata.core.standard_models.toolbox.fundamental.humbl_compass.HumblCompassFetcher.transform_data
¤transform_data()
Transform the command-specific data according to the humbl_compass logic.
Returns:
Type | Description |
---|---|
self
|
The HumblCompassFetcher instance with transformed data. |
Source code in src/humbldata/core/standard_models/toolbox/fundamental/humbl_compass.py
705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 |
|
humbldata.core.standard_models.toolbox.fundamental.humbl_compass.HumblCompassFetcher.fetch_data
¤fetch_data()
Execute TET Pattern.
This method executes the query transformation, data fetching and
transformation process by first calling transform_query
to prepare the query parameters, then
extracting the raw data using extract_data
method, and finally
transforming the raw data using transform_data
method.
Returns:
Type | Description |
---|---|
HumblObject
|
The HumblObject containing the transformed data and metadata. |
Source code in src/humbldata/core/standard_models/toolbox/fundamental/humbl_compass.py
896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 |
|
humbldata.core.standard_models.toolbox.technical
¤
Context: Toolbox || Category: Technical.
humbldata.core.standard_models.toolbox.technical.realized_volatility
¤
Volatility Standard Model.
Context: Toolbox || Category: Technical || Command: Volatility.
This module is used to define the QueryParams and Data model for the Volatility command.
humbldata.core.standard_models.toolbox.technical.realized_volatility.RealizedVolatilityQueryParams
¤
Bases: QueryParams
QueryParams for the Realized Volatility command.
Source code in src/humbldata/core/standard_models/toolbox/technical/realized_volatility.py
21 22 23 24 |
|
humbldata.core.standard_models.toolbox.technical.realized_volatility.RealizedVolatilityData
¤
Bases: Data
Data model for the Realized Volatility command.
Source code in src/humbldata/core/standard_models/toolbox/technical/realized_volatility.py
27 28 29 30 |
|
humbldata.core.standard_models.toolbox.technical.realized_volatility.RealizedVolatilityFetcher
¤
Bases: RealizedVolatilityQueryParams
Fetcher for the Realized Volatility command.
Source code in src/humbldata/core/standard_models/toolbox/technical/realized_volatility.py
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 |
|
humbldata.core.standard_models.toolbox.technical.realized_volatility.RealizedVolatilityFetcher.transform_query
¤transform_query()
Transform the params to the command-specific query.
Source code in src/humbldata/core/standard_models/toolbox/technical/realized_volatility.py
48 49 |
|
humbldata.core.standard_models.toolbox.technical.realized_volatility.RealizedVolatilityFetcher.extract_data
¤extract_data()
Extract the data from the provider.
Source code in src/humbldata/core/standard_models/toolbox/technical/realized_volatility.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
humbldata.core.standard_models.toolbox.technical.realized_volatility.RealizedVolatilityFetcher.transform_data
¤transform_data()
Transform the command-specific data.
Source code in src/humbldata/core/standard_models/toolbox/technical/realized_volatility.py
68 69 |
|
humbldata.core.standard_models.toolbox.technical.realized_volatility.RealizedVolatilityFetcher.fetch_data
¤fetch_data()
Execute the TET pattern.
Source code in src/humbldata/core/standard_models/toolbox/technical/realized_volatility.py
72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
humbldata.core.standard_models.toolbox.technical.mandelbrot_channel
¤
Mandelbrot Channel Standard Model.
Context: Toolbox || Category: Technical || Command: Mandelbrot Channel.
This module is used to define the QueryParams and Data model for the Mandelbrot Channel command.
humbldata.core.standard_models.toolbox.technical.mandelbrot_channel.MandelbrotChannelQueryParams
¤
Bases: QueryParams
QueryParams model for the Mandelbrot Channel command, a Pydantic v2 model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
window |
str
|
The width of the window used for splitting the data into sections for detrending. Defaults to "1m". |
required |
rv_adjustment |
bool
|
Whether to adjust the calculation for realized volatility. If True, the data is filtered to only include observations in the same volatility bucket that the stock is currently in. Defaults to True. |
required |
rv_method |
str
|
The method to calculate the realized volatility. Only need to define when rv_adjustment is True. Defaults to "std". |
required |
rs_method |
Literal['RS', 'RS_min', 'RS_max', 'RS_mean']
|
The method to use for Range/STD calculation. This is either, min, max or mean of all RS ranges per window. If not defined, just used the most recent RS window. Defaults to "RS". |
required |
rv_grouped_mean |
bool
|
Whether to calculate the mean value of realized volatility over multiple window lengths. Defaults to False. |
required |
live_price |
bool
|
Whether to calculate the ranges using the current live price, or the most recent 'close' observation. Defaults to False. |
required |
historical |
bool
|
Whether to calculate the Historical Mandelbrot Channel (over-time), and return a time-series of channels from the start to the end date. If False, the Mandelbrot Channel calculation is done aggregating all of the data into one observation. If True, then it will enable daily observations over-time. Defaults to False. |
required |
chart |
bool
|
Whether to return a chart object. Defaults to False. |
required |
Source code in src/humbldata/core/standard_models/toolbox/technical/mandelbrot_channel.py
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 |
|
humbldata.core.standard_models.toolbox.technical.mandelbrot_channel.MandelbrotChannelQueryParams.window_format
classmethod
¤window_format(v: str) -> str
Format the window string into a standardized format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v |
str
|
The window size as a string. |
required |
Returns:
Type | Description |
---|---|
str
|
The window string in a standardized format. |
Raises:
Type | Description |
---|---|
ValueError
|
If the input is not a string. |
Source code in src/humbldata/core/standard_models/toolbox/technical/mandelbrot_channel.py
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 |
|
humbldata.core.standard_models.toolbox.technical.mandelbrot_channel.MandelbrotChannelData
¤
Bases: Data
Data model for the Mandelbrot Channel command, a Pandera.Polars Model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
date |
Union[date, datetime]
|
The date of the data point. Defaults to None. |
required |
symbol |
str
|
The stock symbol. Defaults to None. |
required |
bottom_price |
float
|
The bottom price in the Mandelbrot Channel. Defaults to None. |
required |
recent_price |
float
|
The most recent price within the Mandelbrot Channel. Defaults to None. |
required |
top_price |
float
|
The top price in the Mandelbrot Channel. Defaults to None. |
required |
Source code in src/humbldata/core/standard_models/toolbox/technical/mandelbrot_channel.py
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 |
|
humbldata.core.standard_models.toolbox.technical.mandelbrot_channel.MandelbrotChannelFetcher
¤
Fetcher for the Mandelbrot Channel command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context_params |
ToolboxQueryParams
|
The context parameters for the toolbox query. |
required |
command_params |
MandelbrotChannelQueryParams
|
The command-specific parameters for the Mandelbrot Channel query. |
required |
Attributes:
Name | Type | Description |
---|---|---|
context_params |
ToolboxQueryParams
|
Stores the context parameters passed during initialization. |
command_params |
MandelbrotChannelQueryParams
|
Stores the command-specific parameters passed during initialization. |
equity_historical_data |
DataFrame
|
The raw data extracted from the data provider, before transformation. |
Methods:
Name | Description |
---|---|
transform_query |
Transform the command-specific parameters into a query. |
extract_data |
Extracts the data from the provider and returns it as a Polars DataFrame. |
transform_data |
Transforms the command-specific data according to the Mandelbrot Channel logic. |
fetch_data |
Execute TET Pattern. |
Returns:
Type | Description |
---|---|
HumblObject
|
results : MandelbrotChannelData Serializable results. provider : Literal['fmp', 'intrinio', 'polygon', 'tiingo', 'yfinance'] Provider name. warnings : Optional[List[Warning_]] List of warnings. chart : Optional[Chart] Chart object. context_params : ToolboxQueryParams Context-specific parameters. command_params : MandelbrotChannelQueryParams Command-specific parameters. |
Source code in src/humbldata/core/standard_models/toolbox/technical/mandelbrot_channel.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
|
humbldata.core.standard_models.toolbox.technical.mandelbrot_channel.MandelbrotChannelFetcher.__init__
¤__init__(context_params: ToolboxQueryParams, command_params: MandelbrotChannelQueryParams)
Initialize the MandelbrotChannelFetcher with context and command parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
context_params |
ToolboxQueryParams
|
The context parameters for the toolbox query. |
required |
command_params |
MandelbrotChannelQueryParams
|
The command-specific parameters for the Mandelbrot Channel query. |
required |
Source code in src/humbldata/core/standard_models/toolbox/technical/mandelbrot_channel.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
humbldata.core.standard_models.toolbox.technical.mandelbrot_channel.MandelbrotChannelFetcher.transform_query
¤transform_query()
Transform the command-specific parameters into a query.
If command_params is not provided, it initializes a default MandelbrotChannelQueryParams object.
Source code in src/humbldata/core/standard_models/toolbox/technical/mandelbrot_channel.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
|
humbldata.core.standard_models.toolbox.technical.mandelbrot_channel.MandelbrotChannelFetcher.extract_data
¤extract_data()
Extract the data from the provider and returns it as a Polars DataFrame.
Drops unnecessary columns like dividends and stock splits from the data.
Returns:
Type | Description |
---|---|
DataFrame
|
The extracted data as a Polars DataFrame. |
Source code in src/humbldata/core/standard_models/toolbox/technical/mandelbrot_channel.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
|
humbldata.core.standard_models.toolbox.technical.mandelbrot_channel.MandelbrotChannelFetcher.transform_data
¤transform_data()
Transform the command-specific data according to the Mandelbrot Channel logic.
Returns:
Type | Description |
---|---|
DataFrame
|
The transformed data as a Polars DataFrame |
Source code in src/humbldata/core/standard_models/toolbox/technical/mandelbrot_channel.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
|
humbldata.core.standard_models.toolbox.technical.mandelbrot_channel.MandelbrotChannelFetcher.fetch_data
¤fetch_data()
Execute TET Pattern.
This method executes the query transformation, data fetching and
transformation process by first calling transform_query
to prepare the query parameters, then
extracting the raw data using extract_data
method, and finally
transforming the raw data using transform_data
method.
Returns:
Type | Description |
---|---|
DataFrame
|
The transformed data as a Polars DataFrame, ready for further analysis or visualization. |
Source code in src/humbldata/core/standard_models/toolbox/technical/mandelbrot_channel.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
|
humbldata.core.standard_models.toolbox.ToolboxQueryParams
¤
Bases: QueryParams
Query parameters for the ToolboxController.
This class defines the query parameters used by the ToolboxController, including the stock symbol, data interval, start date, and end date. It also includes a method to ensure the stock symbol is in uppercase. If no dates constraints are given, it will collect the MAX amount of data available.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
symbol |
str | list[str] | set[str]
|
The symbol or ticker of the stock. You can pass multiple tickers like: "AAPL", "AAPL, MSFT" or ["AAPL", "MSFT"]. The input will be converted to uppercase. |
""
|
interval |
str | None
|
The interval of the data. Can be None. |
"1d"
|
start_date |
str
|
The start date for the data query. |
""
|
end_date |
str
|
The end date for the data query. |
""
|
provider |
OBB_EQUITY_PRICE_HISTORICAL_PROVIDERS
|
The data provider to be used for the query. |
"yfinance"
|
membership |
str
|
The membership level of the user. |
"anonymous"
|
Methods:
Name | Description |
---|---|
upper_symbol |
A Pydantic |
validate_interval |
A Pydantic |
validate_date_format |
A Pydantic |
validate_start_date |
A Pydantic |
Raises:
Type | Description |
---|---|
ValueError
|
If the |
Notes
A Pydantic v2 Model
Source code in src/humbldata/core/standard_models/toolbox/__init__.py
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 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
|
humbldata.core.standard_models.toolbox.ToolboxQueryParams.upper_symbol
classmethod
¤
upper_symbol(v: str | list[str] | set[str]) -> list[str]
Convert the stock symbols to uppercase and remove empty strings.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v |
Union[str, List[str], Set[str]]
|
The stock symbol or collection of symbols to be converted. |
required |
Returns:
Type | Description |
---|---|
List[str]
|
A list of uppercase stock symbols with empty strings removed. |
Source code in src/humbldata/core/standard_models/toolbox/__init__.py
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 |
|
humbldata.core.standard_models.toolbox.ToolboxQueryParams.validate_interval
classmethod
¤
validate_interval(v: str) -> str
Validate the interval format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v |
str
|
The interval string to be validated. |
required |
Returns:
Type | Description |
---|---|
str
|
The validated interval string. |
Raises:
Type | Description |
---|---|
ValueError
|
If the interval format is invalid. |
Source code in src/humbldata/core/standard_models/toolbox/__init__.py
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 |
|
humbldata.core.standard_models.toolbox.ToolboxQueryParams.validate_date_format
classmethod
¤
validate_date_format(v: str | date) -> date
Validate and convert the input date to a datetime.date object.
This method accepts either a string in 'YYYY-MM-DD' format or a datetime.date object. It converts the input to a datetime.date object, ensuring it's in the correct format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v |
str | date
|
The input date to validate and convert. |
required |
Returns:
Type | Description |
---|---|
date
|
The validated and converted date. |
Raises:
Type | Description |
---|---|
ValueError
|
If the input string is not in the correct format. |
TypeError
|
If the input is neither a string nor a datetime.date object. |
Source code in src/humbldata/core/standard_models/toolbox/__init__.py
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 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 |
|
humbldata.core.standard_models.toolbox.ToolboxData
¤
Bases: Data
The Data for the ToolboxController.
WIP: I'm thinking that this is the final layer around which the HumblDataObject will be returned to the user, with all necessary information about the query, command, data and charts that they should want. This HumblDataObject will return values in json/dict format, with methods to allow transformation into polars_df, pandas_df, a list, a dict...
Source code in src/humbldata/core/standard_models/toolbox/__init__.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
|
humbldata.core.utils
¤
humbldata core utils.
Utils is used to keep; helpers, descriptions, constants, and other useful tools.
humbldata.core.utils.env
¤
The Env Module, to control a single instance of environment variables.
humbldata.core.utils.env.Env
¤
A singleton environment to hold all Environment variables.
Source code in src/humbldata/core/utils/env.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 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 |
|
humbldata.core.utils.env.Env.LOGGER_LEVEL
property
¤
LOGGER_LEVEL: int
Get the global logger level.
Returns:
Type | Description |
---|---|
int
|
The numeric logging level (default: 20 for INFO). |
Notes
Mapping of string levels to numeric values: DEBUG: 10, INFO: 20, WARNING: 30, ERROR: 40, CRITICAL: 50
humbldata.core.utils.env.Env.str2bool
staticmethod
¤
str2bool(value: str | bool) -> bool
Match a value to its boolean correspondent.
Args: value (str): The string value to be converted to a boolean.
Returns:
Type | Description |
---|---|
bool: The boolean value corresponding to the input string.
|
|
Raises:
Type | Description |
---|---|
ValueError: If the input string does not correspond to a boolean
|
value. |
Source code in src/humbldata/core/utils/env.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
|
humbldata.core.utils.descriptions
¤
Common descriptions for model fields.
humbldata.core.utils.constants
¤
A module to contain all project-wide constants.
humbldata.core.utils.logger
¤
humbldata.core.utils.logger.setup_logger
¤
setup_logger(name: str, level: int = logging.INFO) -> Logger
Set up a logger with the specified name and logging level.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the logger. |
required |
level |
int
|
The logging level, by default logging.INFO. |
INFO
|
Returns:
Type | Description |
---|---|
Logger
|
A configured logger instance. |
Notes
This function creates a logger with a StreamHandler that outputs to sys.stdout. It uses a formatter that includes timestamp, logger name, log level, and message. If the logger already has handlers, it skips the setup to avoid duplicate logging. The logger is configured not to propagate messages to the root logger.
Examples:
>>> logger = setup_logger("my_logger", logging.DEBUG)
>>> logger.debug("This is a debug message")
2023-05-20 10:30:45,123 - my_logger - DEBUG - This is a debug message
Source code in src/humbldata/core/utils/logger.py
18 19 20 21 22 23 24 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 |
|
humbldata.core.utils.logger.log_start_end
¤
log_start_end(func: Callable | None = None, *, logger: Logger | None = None) -> Callable
Log the start and end of any function, including time tracking.
This decorator works with both synchronous and asynchronous functions. It logs the start and end of the function execution, as well as the total execution time. If an exception occurs, it logs the exception details.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
func |
Callable | None
|
The function to be decorated. If None, the decorator can be used with parameters. |
None
|
logger |
Logger | None
|
The logger to use. If None, a logger will be created using the function's module name. |
None
|
Returns:
Type | Description |
---|---|
Callable
|
The wrapped function. |
Notes
- For asynchronous functions, the decorator uses an async wrapper.
- For synchronous functions, it uses a sync wrapper.
- If a KeyboardInterrupt occurs, it logs the interruption and returns an empty list.
- If any other exception occurs, it logs the exception and re-raises it.
Examples:
>>> @log_start_end
... def example_function():
... print("This is an example function")
...
>>> example_function()
START: example_function (sync)
This is an example function
END: example_function (sync) - Total time: 0.0001s
>>> @log_start_end(logger=custom_logger)
... async def async_example():
... await asyncio.sleep(1)
...
>>> asyncio.run(async_example())
START: async_example (async)
END: async_example (async) - Total time: 1.0012s
Source code in src/humbldata/core/utils/logger.py
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 |
|
humbldata.core.utils.openbb_helpers
¤
Core Module - OpenBB Helpers.
This module contains functions used to interact with OpenBB, or wrap commands to have specific data outputs.
humbldata.core.utils.openbb_helpers.obb_login
¤
obb_login(pat: str | None = None) -> bool
Log into the OpenBB Hub using a Personal Access Token (PAT).
This function wraps the obb.account.login
method to provide a simplified
interface for logging into OpenBB Hub. It optionally accepts a PAT. If no PAT
is provided, it attempts to use the PAT stored in the environment variable
OBB_PAT
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pat |
str | None
|
The personal access token for authentication. If None, the token is
retrieved from the environment variable |
None
|
Returns:
Type | Description |
---|---|
bool
|
True if login is successful, False otherwise. |
Raises:
Type | Description |
---|---|
HumblDataError
|
If an error occurs during the login process. |
Examples:
>>> # obb_login("your_personal_access_token_here")
True
>>> # obb_login() # Assumes `OBB_PAT` is set in the environment
True
Source code in src/humbldata/core/utils/openbb_helpers.py
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 |
|
humbldata.core.utils.openbb_helpers.get_latest_price
¤
get_latest_price(symbol: str | list[str] | Series, provider: OBB_EQUITY_PRICE_QUOTE_PROVIDERS | None = 'yfinance') -> LazyFrame
Context: Core || Category: Utils || Subcategory: OpenBB Helpers || Command: get_latest_price.
Queries the latest stock price data for the given symbol(s) using the
specified provider. Defaults to YahooFinance (yfinance
) if no provider is
specified. Returns a LazyFrame with the stock symbols and their latest prices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
symbol |
str | list[str] | Series
|
The stock symbol(s) to query for the latest price. Accepts a single symbol, a list of symbols, or a Polars Series of symbols. |
required |
provider |
OBB_EQUITY_PRICE_QUOTE_PROVIDERS
|
The data provider for fetching stock prices. Defaults is |
'yfinance'
|
Returns:
Type | Description |
---|---|
LazyFrame
|
A Polars LazyFrame with columns for the stock symbols ('symbol') and their latest prices ('last_price'). |
Source code in src/humbldata/core/utils/openbb_helpers.py
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 |
|
humbldata.core.utils.openbb_helpers.aget_latest_price
async
¤
aget_latest_price(symbols: str | list[str] | Series, provider: OBB_EQUITY_PRICE_QUOTE_PROVIDERS | None = 'yfinance') -> LazyFrame
Asynchronous version of get_latest_price.
Context: Core || Category: Utils || Subcategory: OpenBB Helpers || Command: get_latest_price_async.
Queries the latest stock price data for the given symbol(s) using the
specified provider asynchronously. This functions collects the latest prices
for ETF's and Equities, but not futures or options. Defaults to YahooFinance
(yfinance
) if no provider is specified. Returns a LazyFrame with the stock
symbols and their latest prices.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
symbols |
str | List[str] | Series
|
The stock symbol(s) to query for the latest price. Accepts a single
symbol, a list of symbols, or a Polars Series of symbols.
You can pass multiple symbols as a string; |
required |
provider |
OBB_EQUITY_PRICE_QUOTE_PROVIDERS
|
The data provider for fetching stock prices. Default is |
'yfinance'
|
Returns:
Type | Description |
---|---|
LazyFrame
|
A Polars LazyFrame with columns for the stock symbols ('symbol') and their latest prices ('recent_price'). |
Notes
If entering symbols as a string, DO NOT include spaces between the symbols.
Source code in src/humbldata/core/utils/openbb_helpers.py
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 |
|
humbldata.core.utils.openbb_helpers.aget_last_close
async
¤
aget_last_close(symbols: str | list[str] | Series, provider: OBB_EQUITY_PRICE_QUOTE_PROVIDERS = 'yfinance') -> LazyFrame
Context: Core || Category: Utils || Subcategory: OpenBB Helpers || Command: aget_last_close.
Asynchronously retrieves the last closing price for the given stock symbol(s) using OpenBB's equity price quote data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
symbols |
str | List[str] | Series
|
The stock symbol(s) to query for the last closing price. Accepts a single
symbol, a list of symbols, or a Polars Series of symbols. You can pass
multiple symbols as a string; |
required |
provider |
OBB_EQUITY_PRICE_QUOTE_PROVIDERS
|
The data provider for fetching stock prices. Default is |
'yfinance'
|
Returns:
Type | Description |
---|---|
LazyFrame
|
A Polars LazyFrame with columns for the stock symbols ('symbol') and their last closing prices ('prev_close'). |
Notes
This function uses OpenBB's equity price quote data to fetch the last closing price. It returns a lazy frame for efficient processing, especially with large datasets.
If entering symbols as a string, DO NOT include spaces between the symbols.
Source code in src/humbldata/core/utils/openbb_helpers.py
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 |
|
humbldata.core.utils.openbb_helpers.get_equity_sector
¤
get_equity_sector(symbols: str | list[str] | Series, provider: OBB_EQUITY_PROFILE_PROVIDERS | None = 'yfinance') -> LazyFrame
Context: Core || Category: Utils || Subcategory: OpenBB Helpers || Command: get_sector.
Retrieves the sector information for the given stock symbol(s) using OpenBB's equity profile data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
symbols |
str | list[str] | Series
|
The stock symbol(s) to query for sector information. Accepts a single symbol, a list of symbols, or a Polars Series of symbols. |
required |
provider |
str | None
|
The data provider to use for fetching sector information. If None, the default provider will be used. |
'yfinance'
|
Returns:
Type | Description |
---|---|
LazyFrame
|
A Polars LazyFrame with columns for the stock symbols ('symbol') and their corresponding sectors ('sector'). |
Notes
This function uses OpenBB's equity profile data to fetch sector information. It returns a lazy frame for efficient processing, especially with large datasets.
Source code in src/humbldata/core/utils/openbb_helpers.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
|
humbldata.core.utils.openbb_helpers.aget_equity_sector
async
¤
aget_equity_sector(symbols: str | list[str] | Series, provider: OBB_EQUITY_PROFILE_PROVIDERS | None = 'yfinance') -> LazyFrame
Asynchronous version of get_sector.
Context: Core || Category: Utils || Subcategory: OpenBB Helpers || Command: get_sector_async.
Retrieves the sector information for the given stock symbol(s) using
OpenBB's equity profile data asynchronously. If an ETF is passed, it will
return a NULL sector for the symbol. The sector returned hasn't been
normalized to GICS_SECTORS, it is the raw OpenBB sector output.
Sectors are normalized to GICS_SECTORS in the aet_sector_filter
function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
symbols |
str | List[str] | Series
|
The stock symbol(s) to query for sector information. Accepts a single symbol, a list of symbols, or a Polars Series of symbols. |
required |
provider |
str | None
|
The data provider to use for fetching sector information. If None, the default provider will be used. |
'yfinance'
|
Returns:
Type | Description |
---|---|
LazyFrame
|
A Polars LazyFrame with columns for the stock symbols ('symbol') and their corresponding sectors ('sector'). |
Notes
This function uses OpenBB's equity profile data to fetch sector information. It returns a lazy frame for efficient processing, especially with large datasets.
If you just pass an ETF to the obb.equity.profile
function, it will throw
return data without the NULL columns (sector column included) and only
returns columns where there is data, so we need to handle that edge case.
If an ETF is included with an equity, it will return a NULL sector column,
so we can select the sector column from the ETF data and return it as a
NULL sector for the equity.
Source code in src/humbldata/core/utils/openbb_helpers.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|
humbldata.core.utils.openbb_helpers.aget_etf_category
async
¤
aget_etf_category(symbols: str | list[str] | Series, provider: OBB_ETF_INFO_PROVIDERS | None = 'yfinance') -> LazyFrame
Asynchronously retrieves the category information for the given ETF symbol(s).
This function uses the obb.etf.info
function and selects the category
column to get the sector information. This function handles EQUITY
symbols that are not ETF's the same way that aget_equity_sector
does.
The sector returned (under the OpenBB column name category
) hasn't been
normalized to GICS_SECTORS, it is the raw OpenBB category output.
Sectors are normalized to GICS_SECTORS in the aget_sector_filter
function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
symbols |
str | list[str] | Series
|
The ETF symbol(s) to query for category information. |
required |
provider |
OBB_EQUITY_PROFILE_PROVIDERS | None
|
|
'yfinance'
|
Returns:
Type | Description |
---|---|
LazyFrame
|
A Polars LazyFrame with columns for the ETF symbols ('symbol') and their corresponding categories ('category'). |
Source code in src/humbldata/core/utils/openbb_helpers.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
|
humbldata.core.utils.core_helpers
¤
A module to contain core helper functions for the program.
humbldata.core.utils.core_helpers.is_debug_mode
¤
is_debug_mode() -> bool
Check if the current system is in debug mode.
Returns:
Type | Description |
---|---|
bool
|
True if the system is in debug mode, False otherwise. |
Source code in src/humbldata/core/utils/core_helpers.py
14 15 16 17 18 19 20 21 22 23 |
|
humbldata.core.utils.core_helpers.run_async
¤
run_async(coro)
Run an async function in a new thread and return the result.
Source code in src/humbldata/core/utils/core_helpers.py
26 27 28 29 30 |
|