예제 #1
0
from dateutil.relativedelta import relativedelta as rdelta
from pydash import chunk

from gs_quant.api.utils import ThreadPoolManager
from gs_quant.timeseries.econometrics import volatility, correlation
from gs_quant.timeseries.helper import _create_enum
from gs_quant.timeseries.measures_helper import EdrDataReference, VolReference, preprocess_implied_vol_strikes_eq
from gs_quant import timeseries as ts
from .statistics import *
from ..api.gs.assets import GsAssetApi
from ..api.gs.data import GsDataApi, MarketDataResponseFrame
from ..data.log import log_debug

_logger = logging.getLogger(__name__)

RebalFreq = _create_enum('RebalFreq', ['Daily', 'Monthly'])
ReturnType = _create_enum('ReturnType', ['excess_return'])


def backtest_basket(
    series: list,
    weights: list,
    costs: list = None,
    rebal_freq: RebalFreq = RebalFreq.DAILY,
):
    num_assets = len(series)
    costs = costs or [0] * num_assets

    if not all(isinstance(x, pd.Series) for x in series):
        raise MqTypeError("expected a list of series")
예제 #2
0
파일: backtesting.py 프로젝트: qg0/gs-quant
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
"""

from dateutil.relativedelta import relativedelta as rdelta
from functools import reduce

from gs_quant.timeseries.helper import _create_enum
from .statistics import *

RebalFreq = _create_enum('RebalFreq', ['Daily', 'Monthly'])
ReturnType = _create_enum('ReturnType', ['ER'])


@plot_function
def basket(
    series: list,
    weights: list,
    costs: list = None,
    rebal_freq: RebalFreq = RebalFreq.DAILY,
    return_type: ReturnType = ReturnType.ER,
) -> pd.Series:
    """
    Calculates a basket return series.

    :param series: list of time series of instruments