This page shows how trade sizing is configured on the SigTech platform.
The framework runs strategies in a model world to give target positions and orders. These need to be scaled and combined with the actual positions held to obtain actual executable trades. This action is performed by a separate trading module.
import sigtech.framework as sigfrom sigtech.framework.internal.strategies.timeline.trading_order import TradingOrderimport datetime as dtmimport pandas as pdimport seaborn as snssns.set(rc={'figure.figsize': (18, 6)})ifnot sig.config.is_initialised(): sig.config.init()
Strategy example
The following simple basket consists of a rolling future and rolling FX forwards, going long GBP and short EUR.
The orders and positions are extracted from the strategy timeline, on the specified trade_date. These are used to calculate netted positions and an overall target model position:
trade_date = dtm.date(2018, 6, 29)
pos = st.timeline_holdings.positions()dt = st.decision_dt_from_date(trade_date)port = st.expanded_slice(dt)orders_df = pd.DataFrame([TradingOrder(order).info() for order in port.orders])positions_df = pd.DataFrame( [(p.name, p.quantity) for p in port.positions], columns=['name', 'quantity'])
# net and remove cash entriespositions = positions_df.groupby('name').sum().drop( ['USD CASH', 'ESU18 INDEX VALUATION OFFSET'])
# net and remove cash entriespositions = positions_df.groupby('name').sum().drop( ['USD CASH', 'ESU18 INDEX MARGIN'])
# target position
future_pos = (positions + orders)
future_pos
# orders
orders
Exposures
The notional exposures of the target and orders based on the strategies sizing date:
for col in ['Target Strategy Pos','Strategy Orders','Model Target Pos','Model Orders','PMS Pos','Trade Qty']: trade_table[col]= trade_table[col].map('{:,.0f}'.format)trade_table.index.name ='Instrument Name'
trade_table
This is formatted and combined with trade flags to give the execution output.
Note: the forward quantities here are not given in USD and the future positions are given in contract number.
An overview of placed FX forward orders:
Another example output follows in the case of a random futures portfolio. In this example the PMS is Murex.
Murex PMS screenshot showing futures orders:
There is a separation of the strategy model world and trading module. The strategy output is run and stored in a database. This output is then read by the trading module and combined with positions, read from the PMS.
The model order quantities can be obtained directly from the strategy using the evaluate_trades method.