示例#1
0
from gs_quant.datetime.time import to_zulu_string
import gs_quant.risk as risk
from gs_quant.api.gs.risk import GsRiskApi
from gs_quant.base import Priceable
from gs_quant.common import AssetClass
from gs_quant.instrument import CommodSwap, EqForward, EqOption, FXOption, IRBasisSwap, IRSwap, IRSwaption, IRCap,\
    IRFloor
from gs_quant.markets import PricingContext
from gs_quant.session import Environment, GsSession
from gs_quant.target.risk import PricingDateAndMarketDataAsOf, RiskPosition, RiskRequestParameters, \
    OptimizationRequest

priceables = (
    CommodSwap('Electricity', '1y'),
    EqForward('GS.N', '1y'),
    EqOption('GS.N', '3m', 'ATMF', 'Call', 'European'),
    FXOption('EUR', 'USD', '1y', 'Call', strike_price='ATMF'),
    IRSwap('Pay', '10y', 'USD'),
    IRBasisSwap('10y', 'USD'),
    IRSwaption('Pay', '10y', 'USD'),
    IRCap('10y', 'EUR'),
    IRFloor('10y', 'EUR')
)


def set_session():
    from gs_quant.session import OAuth2Session
    OAuth2Session.init = mock.MagicMock(return_value=None)
    GsSession.use(Environment.QA, 'client_id', 'secret')

under the License.
"""

import datetime as dt
from unittest import mock

import gs_quant.target.backtests as backtests
from gs_quant.api.gs.backtests import GsBacktestApi
from gs_quant.backtests.core import Backtest, QuantityType, TradeInMethod
from gs_quant.backtests.strategy_systematic import StrategySystematic
from gs_quant.instrument import EqOption
from gs_quant.session import *
from gs_quant.target.backtests import *

underlierList = [
    EqOption("MA4B66MW5E27U8P32SB", "3m", 3000, 'Call', 'European'),
    EqOption("MA4B66MW5E27U8P32SB", "3m", 3000, 'Put', 'European')
]

hedge = DeltaHedgeParameters(frequency='Daily')

strategy = StrategySystematic(name="Mock Test",
                              underliers=underlierList,
                              delta_hedge=hedge,
                              quantity=1,
                              quantity_type=QuantityType.Notional,
                              trade_in_method=TradeInMethod.FixedRoll,
                              roll_frequency='1m')


def set_session():