Quotes Module¶
Quotes¶
SimpleQuote¶
- class pyquantlib.SimpleQuote¶
Bases:
QuoteSimple quote for market data.
- __init__(*args, **kwargs)¶
Overloaded function.
__init__() -> None
Constructs an invalid SimpleQuote.
__init__(value: SupportsFloat | SupportsIndex) -> None
Constructs a SimpleQuote with the given value.
- setValue(value: SupportsFloat | SupportsIndex) float¶
Sets the quote value and notifies observers.
spot = ql.SimpleQuote(100.0)
spot.setValue(105.0)
print(spot.value()) # 105.0
DerivedQuote¶
- class pyquantlib.DerivedQuote¶
Bases:
QuoteQuote derived from another quote using a unary function.
- __init__(quote: QuoteHandle, function: collections.abc.Callable) None¶
Creates a derived quote from another quote and a Python function.
CompositeQuote¶
- class pyquantlib.CompositeQuote¶
Bases:
QuoteQuote composed from two quotes using a binary function.
- __init__(quote1: QuoteHandle, quote2: QuoteHandle, function: collections.abc.Callable) None¶
Creates a composite quote from two quotes and a Python function.
QuoteHandle¶
- class pyquantlib.QuoteHandle¶
Bases:
pybind11_objectHandle to Quote objects
- __init__(*args, **kwargs)¶
Overloaded function.
__init__() -> None
Creates an empty handle.
__init__(ptr: object, registerAsObserver: bool = True) -> None
Creates a handle linked to the given object.
- asObservable() Observable¶
Converts to Observable for observer registration.
- currentLink() base.Quote¶
Returns the shared_ptr to the current object link.
- get() base.Quote¶
Returns the underlying shared_ptr. Raises error if empty.
RelinkableQuoteHandle¶
- class pyquantlib.RelinkableQuoteHandle¶
Bases:
QuoteHandleRelinkable handle to Quote objects
- __init__(*args, **kwargs)¶
Overloaded function.
__init__() -> None
Creates an empty relinkable handle.
__init__(ptr: object, registerAsObserver: bool = True) -> None
Creates a relinkable handle linked to the given object.
spot = ql.SimpleQuote(100.0)
handle = ql.QuoteHandle(spot)
# Relinkable handles can be redirected
relinkable = ql.RelinkableQuoteHandle(spot)
new_spot = ql.SimpleQuote(105.0)
relinkable.linkTo(new_spot)
Observer Pattern¶
Quotes participate in QuantLib’s observer pattern. When a quote’s value changes, all dependent calculations are automatically invalidated:
spot = ql.SimpleQuote(100.0)
# ... create option using spot handle ...
npv1 = option.NPV() # computed with spot = 100
spot.setValue(105.0)
npv2 = option.NPV() # automatically recomputed with spot = 105