Python code examples

Pre-built building blocks to create strategies

The SigTech platform has built-in solutions to many common problems faced by quant researchers and traders alike. This page shows some of the key ways in which the platform saves users time.

sig.RollingFutureStrategy(
 currency=“USD”,
 contract_code=“ES”,
 contract_sector=“INDEX”,
 rolling_rule=“front”,
 front_offset=“-5:-3”,
)

Rolling Futures

Futures are cheap and liquid way to gain exposure to a wide range of assets. However they must be rolled on a periodic basis to avoid expiry or triggering delivery.

For example, in a few lines of code, users can create a continuous exposure to the front month of the E-Mini S&P 500 futures, rolled over two days starting from the fifth day before expiry.

sig.InterestRateSwap(
 currency=“EUR”,
 trade_date=dtm.date(2017, 4, 14),
 start_date=dtm.date(2017, 1, 5),
 tenor=dtm.date(2022, 7, 5),
 fixed_rate=0.05,
)

Interest Rate Swaps

The SigTech platform aims to model the full lifecycle of each instrument, including but not limited to, dividends and corporate actions for equities, coupons for bonds and daily variation margins for futures.

Owing to the data available and level of detail of the modeling, users are able to construct a wide range of complex listed and OTC instruments and trade these in a portfolio. Good examples are interest rate swaps and total return swaps.

The code snippet below builds a EUR IR swap with a fixed rate of 5% annual (30/360).

sig.TotalReturnSwap(
 currency=“USD”,
 trade_date=dtm.date(2017, 2, 6),
 maturity=dtm.date(2020, 10, 1),
 instrument_name=“SPXT INDEX”,
 financing_ticker=(“FEDL01 INDEX”, “1M”),
 financing_spread=200,
)

Total Return Swaps

The example below builds a USD-denominated total return swap with the S&P500 Index as the underlying with a monthly reset financing rate of fed funds plus 200bps.

sig.Straddle(
start_date=dtm.date(2019, 1, 3),
currency=“USD”,
group_name=“EURUSD OTC OPTION GROUP”,
strike=0.35,
strike_type=“Delta”,
target_type=“Vega”,
target_quantity=500.0,
rolling_frequencies=[“3M”],
maturity=“3M”,
)

Options

One of the key strengths of the SigTech platform is its comprehensive support for options, both vanilla and exotic.

Common options strategies such as straddles, strangles, and butterflies can be quickly constructed with just a few lines of code. Users can then easily calculate and visualize the greeks over time.

The example below builds a USD-denominated EURUSD 3-month FX straddle at 35 delta, sized to target 500 Vega and rolled every three months.

 

sig.SignalStrategy(
currency=“GBP”,
signal_name=“SIGNAL B3P4X2”,
rebalance_frequency=“1W-MON”,
allocation_function=my_signal_to_weights_method,
leverage=2.5,
)

Generic Signal Strategy

Quant trading starts with a signal. It is often desirable to keep that signal in its raw form for as long as possible before using it to generate portfolio allocations.

The SigTech platform supports this workflow by separating the signal logic from the trading logic and providing a straightforward way of creating a robust, reliable backtest from a signal.

The snippet below builds a GBP-denominated strategy using a user-provided signal, rebalanced to the signal weights every week on a Monday. The conversion from signal values to portfolio weights is handled by a user-created allocation function and the total leverage is set to 250%.

sig.FXForwardHedgingStrategy(
currency=“USD”,
strategy_name=“GBP LONG VALUE PREMIA AK429KC”,
hedging_tenor=“1M”,
exposure_rebalance_threshold=0.01,
hedge_rebalance_threshold=0.02,
)

FX Hedging

Another common problem in quant trading is the need to hedge the currency exposures of a strategy with a base currency using FX forwards.

The SigTech platform handles this seamlessly by allowing users to put any arbitrary strategy built on the platform inside an FX forward hedging wrapper.

In the below example, a GBP-denominated strategy is hedged with USD with 1-month FX forwards. The FX hedge rebalance threshold is set to 2% and the FX exposure rebalance threshold is set to 1%.

Launch new systematic strategies faster

Find out how SigTech scales your quant setup.

Connect with An Expert