Skip to main content
Version: Upcoming

SR Trade

Overview

The SR Trade database provides comprehensive order management capabilities through SQL queries. It enables users to input orders, view fills, and monitor working orders. Users can also programmatically cancel orders and configure customized auto-hedge settings and metrics for programmatic trading. Key features include:

  • SpiderRock Connect equity, option, and future parent order management
  • Parent order executions and reports
  • Multi-leg parent order management
  • Upload away executions (drops)

SR Trade Tables

The following images show the available tables in SR Trade:

SR Trade Tables SR Trade Tables

Query Examples

Sample Query 1: Retrieve definitions for any table with the docColumns query below. It is especially useful when navigating through the different tables in the SR Trade database.

SELECT * FROM srtrade.doccolumns 
WHERE TABLE_NAME='msgparentordergateway'
ORDER BY ordinal_position ASC;
Doc Columns

Inserting Orders

Orders (option, stock, future) are inserted into the system via the ParentOrderGateway table. There are many different fields and variables that can be used for different order types. The examples below demonstrate the simplest order parameters.

Sample Query 2: Insert an option order:

REPLACE INTO srtrade.msgparentordergateway 
(seckey_at, seckey_ts, seckey_tk, seckey_yr, seckey_mn, seckey_dy, seckey_xx, seckey_cp, sectype,
orderSize, orderActiveSize, accnt, clientFirm, spdrActionType, groupingCode, orderSide,
marketSession, orderDuration, orderLimitType, orderVolLimit, parentOrderHandling,
parentBalanceHandling, takeLimitClass, makeLimitClass, autoHedge, riskGroupId, traderName, CHECKSUM)
VALUES
('EQT', 'NMS', 'NVDA', 2025, 10, 17, 180, 'Put', 'Option', 35, -1, 'T.ACCNT', 'SRCORE',
'AddReplace', '0000-0000-0000-0042', 'Buy', 'RegMkt', 400, 'VolX', 0.34, 'ActiveTaker',
'PostLimit', 'Simple', 'Simple', 'None', '0000-0000-0000-0028', 'user.name', 13);

Sample Query 3: Insert a stock order:

REPLACE INTO srtrade.msgparentordergateway 
(accnt, clientFirm, groupingCode, spdrActionType, sectype, seckey_at, seckey_ts, seckey_tk,
seckey_yr, seckey_mn, seckey_dy, seckey_xx, seckey_cp, orderSide, orderSize,
parentOrderHandling, parentBalanceHandling, orderLimitType, orderPrcLimit, marketSession,
traderName, riskGroupId, CHECKSUM)
VALUES
('T.ACCNT', 'SRCORE', '0000-0000-0000-0043', 'AddReplace', 'Stock', 'EQT', 'NMS', 'SPY',
2000, 0, 0, 0, 'Call', 'Buy', 1000, 'ActiveTaker', 'PostLimit', 'Prc', 681, 'RegPostMkt',
'user.name', '0000-0000-0000-0043', 13);

Sample Query 4: Insert a futures order:

REPLACE INTO srtrade.msgparentordergateway 
(accnt, clientFirm, groupingCode, spdrActionType, sectype, seckey_at, seckey_ts, seckey_tk,
seckey_yr, seckey_mn, seckey_dy, seckey_xx, seckey_cp, orderSide, orderSize,
parentOrderHandling, parentBalanceHandling, orderLimitType, orderPrcLimit, marketSession,
traderName, riskGroupId, CHECKSUM)
VALUES
('T.ACCNT', 'SRCORE', '0000-0000-0000-0045', 'AddReplace', 'Future', 'FUT', 'CME', 'ES',
2025, 12, 19, 0, 'Call', 'Buy', 1000, 'ActiveTaker', 'PostLimit', 'Prc', 6711, 'RegPostMkt',
'user.name', '0000-0000-0000-0045', 13);

Sample Query 5: Insert an option order with futures hedging:

REPLACE INTO srtrade.msgparentordergateway 
(seckey_at, seckey_ts, seckey_tk, seckey_yr, seckey_mn, seckey_dy, seckey_xx, seckey_cp, sectype,
orderSize, accnt, clientFirm, spdrActionType, groupingCode, orderSide, marketSession,
orderDuration, orderActiveSize, orderLimitType, parentOrderHandling, parentBalanceHandling,
takeLimitClass, makeLimitClass, autoHedge, hedgeInstrument, hedgeSeckey_at, hedgeSeckey_ts,
hedgeSeckey_tk, hedgeSeckey_yr, hedgeSeckey_mn, hedgeSeckey_dy, riskGroupId, traderName, CHECKSUM)
VALUES
('EQT', 'NMS', 'SPX', 2025, 10, 17, 6900, 'Put', 'Option', 908, 'T.ACCNT', 'SRCORE',
'AddReplace', '0000-0000-0000-0032', 'Buy', 'RegMkt', -1, 0, 'Market', 'ActiveTaker',
'PostLimit', 'Surface', 'Surface', 'SpdrAuto', 'Future', 'FUT', 'CME', 'ES', 2025, 12, 19,
'0000-0000-0000-0032', 'user.name', 13);

Sample Query 6: Insert a multi-leg order into the Complex Order Book using the ParentOrderGatewayExt table:

REPLACE INTO srtrade.msgparentordergatewayext 
(accnt, clientFirm, spdrActionType, orderSize, marketSession, orderDuration, seckey_at,
seckey_ts, seckey_tk, sectype, orderSide, startType, parentOrderHandling, parentBalanceHandling,
takeLimitClass, maxExposureSize, maxCompletionSlippage, orderLimitType, orderPrcLimit,
optPremium, leadSide, traderName, mlegNumLegs, CHECKSUM, autoHedge, orderActiveSize,
mlegSeckey1_at, mlegSeckey1_ts, mlegSeckey1_tk, mlegSeckey1_yr, mlegSeckey1_mn, mlegSeckey1_dy,
mlegSeckey1_xx, mlegSeckey1_cp, mlegSectype1, mlegMult1, mlegSide1, mlegLegId1, mlegPosType1,
mlegSeckey2_at, mlegSeckey2_ts, mlegSeckey2_tk, mlegSeckey2_yr, mlegSeckey2_mn, mlegSeckey2_dy,
mlegSeckey2_xx, mlegSeckey2_cp, mlegSectype2, mlegMult2, mlegSide2, mlegLegId2, mlegPosType2,
groupingCode, riskGroupId)
VALUES
('T.ACCNT', 'SRCORE', 'AddReplace', 100, 'RegMkt', 600, 'EQT', 'NMS', 'AAPL', 'Mleg', 'Buy',
'None', 'SeekerLegger', 'PostLimit', 'Simple', 10, 0.5, 'Prc', 10.00, 10.00, 'Buy',
'user.name', 2, 13, 'SpdrAuto', -1, 'EQT', 'NMS', 'AAPL', 2025, 10, 17, 255, 'Call',
'Option', 1, 'Buy', 1, 'Auto', 'EQT', 'NMS', 'AAPL', 2025, 10, 17, 255, 'Put', 'Option',
1, 'Buy', 2, 'Auto', '1200-1000-0001-1140', '0120-0000-1001-1140');

Monitoring Orders

The following queries enable users to monitor orders in held or working states.

Sample Query 7: Monitor orders in a hold state:

DESCRIBE srtrade.msgsrparentbrkrstate;

SELECT accnt, groupingCode, riskGroupId, seckey_tk, seckey_yr, seckey_mn, seckey_dy,
seckey_xx, seckey_cp, sectype, orderSide, orderSize, orderActiveSize, cumFillQuantity,
makeState, takeState, riskLimitDesc, riskLimitSize, spdrBrokerStatus, spdrCloseReason,
spdrRejectReason
FROM srtrade.msgsrparentbrkrstate a
WHERE accnt = 'T.ACCNT' AND riskLimitDesc != 'Activesize' AND riskLimitSize = 0 AND spdrBrokerStatus = 'Active';

Sample Query 8: Monitor working orders and child orders in the market:

SELECT accnt, groupingCode, riskGroupId, seckey_tk, seckey_yr, seckey_mn, seckey_dy, 
seckey_xx, seckey_cp, sectype, orderSide, orderSize, orderActiveSize, cumFillQuantity,
makeState, takeState, riskLimitDesc, riskLimitSize, spdrBrokerStatus, spdrCloseReason,
spdrRejectReason, csz1, cpx1
FROM srtrade.msgsrparentbrkrstate a
WHERE accnt = 'T.ACCNT' AND riskLimitSize != 0 AND spdrBrokerStatus = 'Active';

Sample Query 9: Monitor orders in all states:

SELECT spdrBrokerStatus, spdrOrderStatus, spdrCloseReason, spdrRejectReason, makeState, 
riskLimitSize, riskLimitDesc, orderActiveSize, csz1, st.*
FROM srtrade.msgsrparentbrkrstate st
WHERE accnt = 'T.ACCNT';

Sample Query 10: View fills programmatically or retrieve fill data for calculating your own TCA metrics with the query below:

SELECT accnt, execStatus, seckey_tk, seckey_yr, seckey_mn, seckey_dy, seckey_xx, seckey_cp, 
sectype, fillQuantity, fillPrice, fillDttm, a.*
FROM srtrade.msgsrparentexecution a
WHERE accnt = 'T.ACCNT';

Cancelling Orders

The ability to quickly cancel single or multiple orders is essential. The following queries demonstrate how to perform these actions.

Sample Query 11: Cancel all orders across multiple accounts (all accounts must belong to the same client firm):

SELECT * FROM srtrade.msgspdrusercancel;

REPLACE INTO srtrade.msgspdrusercancel
VALUES ('user.name', 'SR', 'CancelAll', 'user.name', NOW(), 0);

Sample Query 12: Cancel all orders within a single account (emergency cancel all):

DESCRIBE srtrade.msgsraccntcancel;

REPLACE INTO srtrade.msgsraccntcancel (accnt, cxlReason, altCancelId, username, TIMESTAMP)
VALUES ('T.ACCNT', 'TEST', 'NONE', 'user.name', NOW());

Sample Query 13: Cancel specific orders (or all orders for a symbol). Pull information from SpdrParentBrkrState to filter as needed:

DESCRIBE srtrade.msgsrparentcancel;
DESCRIBE srtrade.msgsrparentbrkrstate;

REPLACE INTO srtrade.msgsrparentcancel
(accnt, parentNumber, cxlReason, altCancelId, username, TIMESTAMP, timestamp_us)
(SELECT accnt, parentNumber, 'Test', 1234, 'user.name', NOW(), 0
FROM srtrade.msgsrparentbrkrstate
WHERE accnt = 'T.ACCNT' AND seckey_tk = 'SPY' AND sectype = 'Stock' AND spdrOrderStatus != 'Closed');