quantrs 0.1.8

A tiny Rust library for quantitative finance
Documentation
�

v��h���F�SrSSKrSSKJs Jr SSKrSSKr"SS5r	g)z<
Pytest-compatible test script for quantrs Python bindings.
�Nc�<�\rSrSrSrSrSrSrSrSr	Sr
S	rg
)�TestQuantrsPythonBindings�	z'Test class for quantrs Python bindings.c�v�/SQnUGH.n[R"U5nURSS5nURSS5n[	U[
5of(Gd+SS[R"5;d[R"[5(a[R"[5OSS[R"5;d[R"U5(a[R"U5OSS[R"5;d[R"[
5(a[R"[
5OS[R"U5S.-n[[R"U55eS	n[	U[5of(Gd+SS[R"5;d[R"[5(a[R"[5OSS
[R"5;d[R"U5(a[R"U5OS
S[R"5;d[R"[5(a[R"[5OS[R"U5S.-n[[R"U55eS	nSo�U:�o�(d�[R"S
U	4SXH45S[R"5;d[R"U5(a[R"U5OS[R"U5S.-n
SSU
0-n[[R"U55eS	=p�So�U:�o�(d�[R"S
U	4SXX45S
[R"5;d[R"U5(a[R"U5OS
[R"U5S.-n
SSU
0-n[[R"U55eS	=p�GM1 g	)zTest day count functionality.)�ACT/365FzACT/365zACT/360z30/360USz30/360EzACT/ACT ISDAzACT/ACT ICMA�
2025-01-01�
2025-07-01�5assert %(py4)s
{%(py4)s = %(py0)s(%(py1)s, %(py2)s)
}�
isinstance�	year_frac�float��py0�py1�py2�py4N�days�intr��>�z%(py0)s > %(py3)s�r�py3�assert %(py5)s�py5)�quantrs�DayCount�
year_fraction�	day_countrr
�@py_builtins�locals�
@pytest_ar�_should_repr_global_name�	_saferepr�AssertionError�_format_explanationr�_call_reprcompare)�self�conventions�conv�dcrr�@py_assert3�@py_format5�@py_assert2�@py_assert1�@py_format4�@py_format6s            �B/home/cb/github/quantrs/bindings/python/tests/test_fixed_income.py�test_day_count�(TestQuantrsPythonBindings.test_day_counts��
�� �D��!�!�$�'�B��(�(��|�D�I��<�<��l�;�D��i��/�/�/�/�/�/�/�/�/�:�/�/�/�/�:�/�/�/�/�/�/�i�/�/�/�/�i�/�/�/�/�/�/��/�/�/�/��/�/�/�/�/�/�/�/�/�/��d�C�(�(�(�(�(�(�(�(�(�:�(�(�(�(�:�(�(�(�(�(�(�d�(�(�(�(�d�(�(�(�(�(�(�C�(�(�(�(�C�(�(�(�(�(�(�(�(�(�(� � �q�=� � � � �9� � � � � � �9� � � � �9� � � �q� � � � � � � ��O�!�8�O�O�O�O�4�O�O�O�O�O�O�4�O�O�O�O�4�O�O�O�!�O�O�O�O�O�O�O� �c�4�[R"SS5n[R"S5nURnSoCU:HoU(d�[R
"SU4SX445S[R"5;d[R"U5(a[R"U5OS[R"U5[R"U5S.-nSS	U0-n[[R"U55eS
=n=pTURnSoCU:HoU(d�[R
"SU4SX445S[R"5;d[R"U5(a[R"U5OS[R"U5[R"U5S.-nSS	U0-n[[R"U55eS
=n=pT/SQnS
n	S
n
UGH�nURX�U5n[U[5oU(Gd+SS[R"5;d[R"[5(a[R"[5OSS[R"5;d[R"U5(a[R"U5OSS[R"5;d[R"[5(a[R"[5OS[R"U5S.-n
[[R"U
55eS
nSo�U:�o3(d�[R
"SU4SX�45S[R"5;d[R"U5(a[R"U5OS[R"U5S.-nSSU0-n[[R"U55eS
=p>So�U:*o3(d�[R
"SU4SX�45S[R"5;d[R"U5(a[R"U5OS[R"U5S.-nSSU0-n[[R"U55eS
=p>U
b�X�:o3(d�[R
"SU4SX�45S[R"5;d[R"U5(a[R"U5OSS[R"5;d[R"U
5(a[R"U
5OSS.-nSS U0-n
[[R"U
55eS
nUn
GM� g
)!z Test bond pricing functionality.�@�@�
2030-12-31r)�==)z2%(py2)s
{%(py2)s = %(py0)s.face_value
} == %(py5)s�bond)rrrzassert %(py7)s�py7N)z0%(py2)s
{%(py2)s = %(py0)s.maturity
} == %(py5)s)g{�G�z�?g{�G�z�?g���Q��?�{�G�z�?g�������?�
2025-06-19r
r�pricer
rrrrrrr)�<=)z%(py0)s <= %(py3)s��<)z%(py0)s < %(py2)s�
prev_price)rrzassert %(py4)sr)r�ZeroCouponBondr�
face_valuer"r'r r!r#r$r%r&�maturityr>rr
)r(r:r+r/�@py_assert4r,r1�@py_format8�yields�
settlementrB�ytmr>r-r.r0�@py_format3s                 r2�test_bond_pricing�+TestQuantrsPythonBindings.test_bond_pricing$s����%�%�f�l�;��
�
�
�j�
)�����(�&�(�&�(�(�(�(�(��(�(�(�(�(�(�t�(�(�(�(�t�(�(�(��(�(�(�&�(�(�(�(�(�(�(��}�}�,��,��,�,�,�,�,�}�,�,�,�,�,�,�t�,�,�,�,�t�,�,�,�}�,�,�,��,�,�,�,�,�,�,�0��!�
��
��C��J�J�z��3�E��e�U�+�+�+�+�+�+�+�+�+�:�+�+�+�+�:�+�+�+�+�+�+�e�+�+�+�+�e�+�+�+�+�+�+�U�+�+�+�+�U�+�+�+�+�+�+�+�+�+�+���1�9�����5�������5�����5����1��������"�"�F�?�"�"�"�"�5�"�"�"�"�"�"�5�"�"�"�"�5�"�"�"�F�"�"�"�"�"�"�"��%��)�)�)�)�)�u�)�)�)�)�)�)�u�)�)�)�)�u�)�)�)�)�)�)�z�)�)�)�)�z�)�)�)�)�)�)�)��J�r5c�z�[R"SSS5n[R"S5nURSS5nX-
n[	U5nSoeU:ow(GdX[
R"SU4SXV45S[R"5;d[
R"[5(a[
R"[5OSS[R"5;d[
R"U5(a[
R"U5OSS	[R"5;d[
R"U5(a[
R"U5OS	[
R"U5[
R"U5S
.-nSSU0-n	[[
R"U	55eS
=n=n=pvg
)zTest convenience functions.rr	rg�����|�=r@)z;%(py5)s
{%(py5)s = %(py0)s((%(py1)s - %(py2)s))
} < %(py8)s�abs�result1�result2)rrrr�py8zassert %(py10)s�py10N)
r�calculate_year_fractionrrrOr"r'r r!r#r$r%r&)
r(rPr+rQr,rF�@py_assert7�@py_assert6�@py_format9�@py_format11s
          r2�test_convenience_functions�4TestQuantrsPythonBindings.test_convenience_functions>s����1�1��,�
�
��
�
�
�j�
)���"�"�<��>���$�-�s�$�%�-��-��-�-�-�-�-�%�-�-�-�-�-�-�s�-�-�-�-�s�-�-�-�-�-�-�7�-�-�-�-�7�-�-�-�-�-�-�W�-�-�-�-�W�-�-�-�%�-�-�-��-�-�-�-�-�-�-r5c���[R"[5 [R"S5 SSS5 [R"[5 [R"S5nURSS5 SSS5 [R"[5 [R"SS5 SSS5 g!,(df   N�=f!,(df   NZ=f!,(df   g=f)zTest error handling.�INVALID_CONVENTIONNrzinvalid-dater	r7)�pytest�raises�
ValueErrorrrrrC)r(r+s  r2�test_error_handling�-TestQuantrsPythonBindings.test_error_handlingKs����]�]�:�
&����1�2�'��]�]�:�
&��!�!�*�-�B����^�\�:�'�
�]�]�:�
&��"�"�6�>�:�'�
&�'�
&��'�
&��
'�
&�s#�C�)C�C"�
C�
C�"
C0c�*�[R"S5n[U5nSo3U;oD(d�[R"SU4SX245[R
"U5S[R"5;d[R"U5(a[R
"U5OSS.-nSSU0-n[[R"U55eS	=p4[R"S
S5n[U5nSo3U;oD(d�[R"SU4SX845[R
"U5S
[R"5;d[R"U5(a[R
"U5OS
S.-nSSU0-n[[R"U55eS	=p4So3U;oD(d�[R"SU4SX845[R
"U5S
[R"5;d[R"U5(a[R
"U5OS
S.-nSSU0-n[[R"U55eS	=p4So3U;oD(d�[R"SU4SX845[R
"U5S
[R"5;d[R"U5(a[R
"U5OS
S.-nSSU0-n[[R"U55eS	=p4g	)zTest string representations.rr)�in)z%(py1)s in %(py3)s�dc_repr)rrrrNr7r8rC�	bond_repr�1000)rr�reprr"r'r$r r!r#r%r&rC)	r(r+rd�@py_assert0r.r0r1r:res	         r2�test_repr_methods�+TestQuantrsPythonBindings.test_repr_methodsZs����
�
�j�
)���r�(���$�W�$�$�$�$�$�z�$�$�$�z�$�$�$�$�$�$�W�$�$�$�$�W�$�$�$�$�$�$�$��%�%�f�l�;����J�	��,�9�,�,�,�,�,��,�,�,��,�,�,�,�,�,�9�,�,�,�,�9�,�,�,�,�,�,�,��"��"�"�"�"�"�v�"�"�"�v�"�"�"�"�"�"��"�"�"�"��"�"�"�"�"�"�"��(�y�(�(�(�(�(�|�(�(�(�|�(�(�(�(�(�(�y�(�(�(�(�y�(�(�(�(�(�(�(r5c�j�SSKn[R"S5n[R"SS5nSnSnSnUR5n[	U5HnURXEU5n	M UR5n
X�-
nS	o�U:o�(d�[R"S
U
4SX�45S[R"5;d[R"U5(a[R"U5OS[R"U5S
.-nSSU0-n[[R"U55eS=p�g)zBasic performance test.rNrr7r8r=r<�dg�?r@)z%(py0)s < %(py3)s�
total_timerrr)�timerrrC�ranger>r"r'r r!r#r$r%r&)r(rnr+r:rIrJ�n_iterations�
start_time�_r>�end_timermr.r/r0r1s                r2�test_performance�*TestQuantrsPythonBindings.test_performancehs�����
�
�j�
)���%�%�f�l�;��!�
������Y�Y�[�
��|�$�A��J�J�z��3�E�%��9�9�;���*�
� ��C������z�������z�����z����C�������r5�N)�__name__�
__module__�__qualname__�__firstlineno__�__doc__r3rLrYr`rirt�__static_attributes__rvr5r2rr	s#��1��0�4.�
;�)� r5r)
r{�builtinsr �_pytest.assertion.rewrite�	assertion�rewriter"r]rrrvr5r2�<module>r�s"�����
��t �t r5