The SG Markets SP API is a web service that allows Clients to price and trade a wide variation of the structured products available in SG Markets SP. The service is designed to assist users in requesting indicative prices for SG Markets SP products from 3rd party systems where they only need to specify a small number of parameters to receive a price.
Pricing, trading and documentation are available for numerous predefined structured products.
For connecting to the external API, you first need to get a SG Connect token that will authenticate you in the SG ecosystem. For that you must call SG Connect server with your secret and client id formatted correctly. You need to send your credentials separated by a “:” (ex: “secret:client_id”) and encoded as a base64 string. Then add the result in the headers, under the “Authorization” property preceded by “Basic” (see curl example).
You also need to specify the grant type and the scope. The scope will determine the rights that will be granted to you (example: read, write) and the grant type is the way your credential will flow in the SG ecosystem. For connecting to the external API, you must specify the grant type as ”client credentials” and the scope as “openid profile api.sgmarkets-execution-structured-products.v1”.
Please refer to SG Markets Apis / Authentication for further information.
using (var client = new HttpClient()) { // Format client and secret id var result = Convert.ToBase64String(Encoding.UTF8.GetBytes("client_id:secret_id")); //Define Headers client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", result); //Prepare Request Body var requestData = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("grant_type", "client_credentials") }; var requestBody = new FormUrlEncodedContent(requestData); //Request Token var request = await client.PostAsync("https://sso.sgmarkets.com/sgconnect/oauth2/access_token?grant_type=client_credentials& scope=openid profile api.sgmarkets-execution-structured-products.v1", requestBody); }
import requests access_token_endpoint = "https://sso.sgmarkets.com/sgconnect/oauth2/access_token" lient_id = "..." client_secret = "..." scopes = ["openid", "profile", "api.sgmarkets-execution-structured-products.v1"] response = requests.post(access_token_endpoint, verify=False, auth=(client_id, client_secret), data={'grant_type': 'client_credentials', 'scope': ' '.join(scopes)}) if response.ok: print(response.json()["access_token"])
curl -Method POST -Headers @{"Accept"="application/json";" Authorization"="Basic MhBhRzc1ZjAtNDlmMi0ON2FhLVhlODQtYmC2YmNlYWQxMzI5OjFkYWxpZXszYzRkaWo0aWg3ZTg3ZG04OTY2NThr"} 'https://sso.sgmarkets.com/sgconnect/oauth2/access_token? grant_type=client_credentials&scope=openid profile api.sgmarkets-execution-structured-products.v1'
You must refresh the SG Connect token after a certain period of time, the validity period of the token is given under the “expires_in” property of the response given by SG Connect server, this unit is expressed in seconds.
Examples:
{
"Data": {
"QuoteId": "SGM-00000484601",
"SolveFor": "KiBarrier",
"SolveResult": 0,
"Mifid2": {
"PgRequired": "no",
"KidId": "KID-AST-9aW6Yggykd",
"KidRequired": "yes"
}
},
"Status": "Accepted"
}
{
"Data": {
"QuoteId": "SGM-00000484601",
"SolveFor": "KiBarrier",
"SolveResult": 88.43,
"Quote": {
"Wrapper": "Note",
"IssuePricePercent": 100,
"RemunerationMode": "Upfront",
"NotionalType": "Currency",
"NotionalAmount": 1000000,
"UpfrontFee": 2.5,
[...]
},
[...],
"Status": "Quoted",
"RepriceLink": "https://demo.sgmarkets.com/sp/#/quote/SGM-00000484601",
"TradeAuthorizationStatus": "Denied"
}
{
"Status": "Accepted",
QuoteId": "SGM-00000484601"
}
Then, call the route GET /api/v1/quote/{quoteId} to get more information about the status of the execution request. If the deal is traded, the system should return
the status Traded.
{
[...],
"Status": "Traded",
"RepriceLink": "https://demo.sgmarkets.com/sp/#/quote/SGM-00000484601",
"TradeAuthorizationStatus": "Granted"
}
{
"QuoteId": "SGM-00000484601",
"Status": "Booked",
"Isin": "isin code",
"CreatedOn": "2021-12-28 09:38:28Z",
"TradeDate": "2021-12-28",
"Maturity": "2025-01-07",
"Currency": "EUR",
"User": "your email",
"Notional": 1000000,
"SettlementPrice": 100,
"UpfrontFee": 2.5,
"Wrapper": "Note",
"ProductFamily": "Autocall"
}
When requesting for an indicative quote with regulation, meaning with Mifid2section, you have many use cases:
When requesting for an indicative quote without regulation, meaning without Mifid2 section the KID and the Target Market will not be generated even if they are configured as required in the system.
When requesting for a tradable quote
To force the KID generation, you should add the additionalKidLanguages tag under the mifid2 section.
{ [...], "mifid2": { "distributionCountries": [ "France","UnitedKingdom" ], "additionalKidLanguages": [ "German","Dutch" ] }, [...] }
To force Target Market generation, you should add the tag ForceTargetMarket under the mifid2 section:
{ [...], "mifid2": { [...], "forceTargetMarket": true }, [...] }
The values of available KID and Distribution Countries languages are available from the Schemas section from the swagger: API Swagger
DistributionCountry: string Enum [ Andorra, UnitedArabEmirates, Argentina, Austria, Belgium, Bahrain, Bahamas, Bermuda, Bolivia, Brazil, Switzerland, Chile, Colombia, CostaRica, CaymanIslands, Germany, Ecuador, Spain, Finland, France, UnitedKingdom, Guernsey, Guatemala, HongKong, Honduras, Ireland, Israel, Italy, Jersey, Luxembourg, Monaco, Mexico, Netherlands, Panama, Peru, Portugal, RussianFederation, SaudiArabia, Singapore, ElSalvador, Sweden, Uruguay, BritishVirginIslands, Dubai, SouthAfrica ] KidLanguage: string Enum [ Finnish, Dutch, English, French, German, Italian, Portuguese, Spanish, Swedish ]
{ "Custodians": [ { "Code": "custodian num id 1", "Label": "Custodian name 1", "DisabledInSecondaryMarket": true }, [...], { "Code": "custodian num id n", "Label": "Custodian name n" } ] }
{ "Status": "OK", "QuoteId": "SGM-00000484722", "Errors": [], "RepriceLink": "https://demo.sgmarkets.com/sp/#/quote/SGM-00000484722" }
{
[...],
"Status": "Quoted",
"RepriceLink": "https://demo.sgmarkets.com/sp/#/quote/SGM-00000484722",
"TradeAuthorizationStatus": "Granted"
}
{ "Status": "Accepted", "QuoteId": "SGM-00000484722" }
{ "QuoteId": "SGM-00000484722", "Status": "Booked", "Isin": "your isin code", "CreatedOn": "2021-12-28 14:30:01Z", "TradeDate": "2021-12-28", "Maturity": "2025-01-07", "Currency": "EUR", "User": "your email", "Notional": 1000000, "SettlementPrice": 100, "UpfrontFee": 2.5, "Wrapper": "Note", "ProductFamily": "Autocall" }
{ [...], "scheduleCustomization": [ { "periodId": 2, "recallThreshold": 99, "recallCoupon": 3 }, { "periodId": 4, "recallThreshold": 98, "recallCoupon": 7 } ], [...] }
When requesting for an indicative quote with regulation, meaning with Mifid2 section, you have many use cases:
KID document will be generated with the defaulted languages configured in the system and there is no need to explicitly add the AdditionalKidLanguages tag.
Example:
For a specific client, only KID is
mandatory in the system and it is configured as required with these three languages by
default: English, Italian and French. In the JSON template, you will only need to add
the
Mifid2 section as shown below:
As an output you will have the three KID
documents generated with the three defaulted Languages English, Italian and
French:
Example:
For a specific client, only KID is mandatory in the system, and it is configured as required with these three languages by default: English, Italian and French.
If an additional KID language needs to be added, let’s say German, use the below tag.
In the JSON template you will need to add the Mifid2 section as shown below:
As an output you will have 4 KID documents generated with four Languages English, Italian, French and German.
If the Target Market document is needed and not configured as required in the system, we will need to force the generation, to do so the tag ForceTargetMarket must be added to the Mifid2 section as shown below:
As output you will have 4 KID documents generated with four Languages English, Italian, French and German plus the Target Market document:
For indicative and tradable quotes, call the route with the SGM IDGET /api/v1/quote/{quoteId} to get the quote details, the regulation documents are available in the the Mifid2 section.
Below an example of an output:
Mandatory fields for an indicative quote:
Mandatory fields for a tradable quote:
post:/api/v1/tradable-quotes/*/execution: Writing capacity is 3 per minute
get:/api/v1/underlying-universe*: Reading capacity is 1 per minute
post:/api/v1/tradable-quotes*: Writing capacity is 3 per minute
post:/api/v1/custodians*: Reading capacity is 1 per minute
get:/api/v1/termsheet/*: Reading capacity is 6 per minute
get:/api/v1/quote/*: Reading capacity is 6 per minute
post:/api/v1/quotes*: Writing capacity is 3 per minute
get:/api/v1/trade/*: Reading capacity is 6 per minute
If the limit is reached, The request will be rejected and the HTTP error code 429 (Too many requests) will be returned
Use the route GET /api/v1/termsheet/{quoteId}/{language}, The response is a PDF file.
Entry data: The quote ID and the choosen language, today 2 options are available (English and French)
Result: Coded termsheet, it should be then converted from Base64 to PDF.
Please see the example below:
Entry data:
Response: