Skip to content

Commit

Permalink
add more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jialuechen committed Oct 9, 2024
1 parent 64545d3 commit c6a212d
Show file tree
Hide file tree
Showing 28 changed files with 636 additions and 187 deletions.
28 changes: 6 additions & 22 deletions docs/source/api_reference.rst
Original file line number Diff line number Diff line change
@@ -1,30 +1,14 @@
api_reference.rst
===============================
API Reference
=============

This section provides detailed documentation for the TorchQuant API.

.. toctree::
:maxdepth: 2

torchquantlib.core
torchquantlib.models
torchquantlib.utils
torchquantlib.calibration
torchquantlib.risk
torchquantlib.utils

torchquantlib.core.rst (Example for one module)
===============================
Core
========

.. automodule:: torchquantlib.core
:members:
:undoc-members:
:show-inheritance:

Submodules
----------

.. toctree::
:maxdepth: 4

torchquantlib.core.asset_pricing
torchquantlib.core.risk
For more information on specific modules and functions, please refer to the individual module pages.
18 changes: 18 additions & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Changelog
=========

This page documents the version history and changes made to TorchQuant.

Version 1.3.0 (Current Release)
-------------------------------

- Current stable release of TorchQuant
- Four main modules: core, calibration, risk, and utils
- Compatible with PyTorch 2.4.0

For detailed changes in this version, please refer to the release notes.

Previous Versions
-----------------

For information about previous versions, please check our GitHub repository.
39 changes: 15 additions & 24 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,35 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

import os
import sys
import sphinx_rtd_theme

sys.path.insert(0, os.path.abspath('..'))
sys.path.insert(0, os.path.abspath('../../torchquantlib'))

# -- Project information -----------------------------------------------------
project = 'TorchQuant'
copyright = '2024, Jialue Chen'
author = 'Jialue Chen'
release = '1.3.0'

# -- General configuration ---------------------------------------------------
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
]
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.napoleon', 'sphinx.ext.mathjax', 'sphinx.ext.coverage', 'sphinx.ext.githubpages','sphinx.ext.intersphinx','sphinx.ext.autosummary']

templates_path = ['_templates']
exclude_patterns = []



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'sphinx_rtd_theme'
html_theme_path=[sphinx_rtd_theme.get_html_theme_path()]
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
html_static_path = ['_static']

# -- Extension configuration -------------------------------------------------
autodoc_member_order = 'bysource'
autodoc_typehints = 'description'
napoleon_google_docstring = True
napoleon_numpy_docstring = True
napoleon_include_init_with_doc = False
napoleon_include_private_with_doc = False
napoleon_include_special_with_doc = True
napoleon_use_admonition_for_examples = False
napoleon_use_admonition_for_notes = False
napoleon_use_admonition_for_references = False
napoleon_use_ivar = False
napoleon_use_param = True
napoleon_use_rtype = True
30 changes: 30 additions & 0 deletions docs/source/examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Examples
========

This section provides examples of how to use TorchQuant for various quantitative finance tasks.

Model Calibration
-----------------

Here's an example of calibrating a model using TorchQuant:

.. code-block:: python
import torch
import torchquant as tq
# Load market data
market_data = tq.utils.load_market_data('path/to/data.csv')
# Create a model
model = tq.models.HestonModel()
# Create a calibrator
calibrator = tq.calibration.ModelCalibrator(model, market_data)
# Perform calibration
calibrated_params = calibrator.calibrate()
print("Calibrated parameters:", calibrated_params)
More examples covering different aspects of TorchQuant will be added in future updates.
13 changes: 8 additions & 5 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
===============================
.. TorchQuant documentation master file
TorchQuant documentation
========================

Welcome to TorchQuant's documentation!
=============================================
Welcome to TorchQuant's documentation. TorchQuant is a library for quantitative finance using PyTorch.

.. toctree::
:maxdepth: 2
:caption: Contents:

introduction
installation
usage
quickstart
api_reference
examples
contributing
changelog

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
64 changes: 9 additions & 55 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
@@ -1,65 +1,19 @@
Installation
============

This section covers the installation process for TorchQuant.

Prerequisites
-------------

Before installing TorchQuant, ensure you have the following:

- Python 3.7 or higher
- pip (Python package installer)

Installing from PyPI
--------------------

The easiest way to install TorchQuant is using pip:
TorchQuant can be installed using pip, the Python package installer. To install TorchQuant, run the following command:

.. code-block:: bash
pip install torchquantlib
Installing from Source
----------------------

To install TorchQuant from source:

1. Clone the repository:

.. code-block:: bash
git clone https://github.com/jialuechen/torchquant.git
cd torchquant
2. Install the package:
pip install torchquantlib
.. code-block:: bash
pip install .
Verifying the Installation
--------------------------

To verify that TorchQuant has been installed correctly, you can run:

.. code-block:: python
import torchquantlib
print(torchquantlib.__version__)
This should print the version number of the installed package.

Upgrading
---------

To upgrade to the latest version of TorchQuant, use:

.. code-block:: bash
Requirements
------------

pip install --upgrade torchquantlib
TorchQuant requires:

Troubleshooting
---------------
- Python 3.7+
- PyTorch 2.4.0+
- NumPy

If you encounter any issues during installation, please check our :doc:`troubleshooting` guide or open an issue on our GitHub repository.
For GPU acceleration, ensure you have a CUDA-compatible GPU and the appropriate CUDA toolkit installed.
45 changes: 0 additions & 45 deletions docs/source/introduction.rst

This file was deleted.

7 changes: 7 additions & 0 deletions docs/source/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
torchquantlib
=============

.. toctree::
:maxdepth: 4

torchquantlib
26 changes: 26 additions & 0 deletions docs/source/quickstart.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Quickstart Guide
================

This guide will help you get started with TorchQuant quickly.

Basic Usage
-----------

Here's a simple example of using TorchQuant:

.. code-block:: python
import torch
from torchquantlib.core.asset_pricing.option.black_scholes_merton import black_scholes_merton
spot = torch.tensor(100.0)
strike = torch.tensor(105.0)
expiry = torch.tensor(1.0)
volatility = torch.tensor(0.2)
rate = torch.tensor(0.05)
dividend = torch.tensor(0.02)
price = black_scholes_merton('call', 'european', spot, strike, expiry, volatility, rate, dividend)
print(f'Option Price: {price.item()}')
This example demonstrates how to use the Black-Scholes model to price a European call option.
21 changes: 21 additions & 0 deletions docs/source/torchquantlib.calibration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
torchquantlib.calibration package
=================================

Submodules
----------

torchquantlib.calibration.model\_calibrator module
--------------------------------------------------

.. automodule:: torchquantlib.calibration.model_calibrator
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: torchquantlib.calibration
:members:
:undoc-members:
:show-inheritance:
29 changes: 29 additions & 0 deletions docs/source/torchquantlib.core.asset_pricing.bond.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
torchquantlib.core.asset\_pricing.bond package
==============================================

Submodules
----------

torchquantlib.core.asset\_pricing.bond.bond\_pricer module
----------------------------------------------------------

.. automodule:: torchquantlib.core.asset_pricing.bond.bond_pricer
:members:
:undoc-members:
:show-inheritance:

torchquantlib.core.asset\_pricing.bond.fixed\_income\_forward module
--------------------------------------------------------------------

.. automodule:: torchquantlib.core.asset_pricing.bond.fixed_income_forward
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: torchquantlib.core.asset_pricing.bond
:members:
:undoc-members:
:show-inheritance:
Loading

0 comments on commit c6a212d

Please sign in to comment.