{"id":8052,"date":"2025-09-04T23:22:22","date_gmt":"2025-09-05T04:22:22","guid":{"rendered":"https:\/\/librarytestdev.wpenginepowered.com\/?post_type=doc&#038;p=8052"},"modified":"2025-09-04T23:23:54","modified_gmt":"2025-09-05T04:23:54","slug":"products","status":"publish","type":"doc","link":"https:\/\/library-staging.tradingtechnologies.com\/apis\/tt-net-sdk\/working-with-instruments-tt-net-sdk\/products\/","title":{"rendered":"Products"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"fetching-all-products-for-a-given-market\">Fetching all products for a given market<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To fetch all products for a given market, you:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Instantiate the\u00a0<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html\">ProductCatalog<\/a>\u00a0class.<\/li>\n\n\n\n<li>Choose a fetch type:\n<ul class=\"wp-block-list\">\n<li>Synchronous\n<ol class=\"wp-block-list\">\n<li>Call the\u00a0<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html#Get\">Get()<\/a>\u00a0method.<\/li>\n<\/ol>\n<\/li>\n\n\n\n<li>Asynchronous\n<ol class=\"wp-block-list\">\n<li>Create an event handler method that will be called when notifications regarding this Product\u00a0<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.Product.html\">Product<\/a>\u00a0are available.<\/li>\n\n\n\n<li>Register this event handler with the\u00a0<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html\">ProductCatalog<\/a>\u00a0instance.<\/li>\n\n\n\n<li>Call the\u00a0<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html#GetAsync\">GetAsync()<\/a>\u00a0method of the\u00a0<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html\">ProductCatalog<\/a>\u00a0instance.<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"instantiating-the-productcatalog-class\"><a href=\"\/tt-net-sdk\/articles\/instr-products.html#instantiating-the-productcatalog-class\"><\/a>Instantiating the ProductCatalog class<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html\">ProductCatalog<\/a>&nbsp;class provides the following constructors that let you identify a market using specific criteria.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public ProductCatalog(Market market, Dispatcher dispatcher);\npublic ProductCatalog(MarketId marketId, Dispatcher dispatcher);\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The following code snippet illustrates how to instantiate this class using a&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.MarketId.html\">MarketId<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ProductCatalog prod_cat = new ProductCatalog(MarketId.CME, tt_net_sdk.Dispatcher.Current);\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"synchronous-fetch\"><a href=\"\/tt-net-sdk\/articles\/instr-products.html#synchronous-fetch\"><\/a>Synchronous fetch<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Once an&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html\">ProductCatalog<\/a>&nbsp;object has been created, you can simply call the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog_Get.html\">Get()<\/a>&nbsp;method to perform a synchronous lookup of the products as shown below. Note that although this is normally fairly quick, your execution thread will be blocked until this action is complete.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ProductDataEvent e = prod_cat.Get();\nif (e == ProductDataEvent.Found)\n{\n  \/\/ Products were found\n  foreach (KeyValuePair&lt;ProductKey, Product&gt; kvp in prod_cat.Products)\n  {\n      Console.WriteLine(\"Key = {0} : Value = {1}\", kvp.Key, kvp.Value);\n  }\n}\nelse\n{\n  \/\/ Products were not found\n  Console.WriteLine(\"Cannot find product: {0}\", e.ToString());\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"asynchronous-fetch\"><a href=\"\/tt-net-sdk\/articles\/instr-products.html#asynchronous-fetch\"><\/a>Asynchronous fetch<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you prefer not to be blocked, you can register a callback function to be called once the fetching has been completed as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>prod_cat.OnData += new EventHandler&lt;ProductCatalogEventArgs&gt;(Prod_cat_OnData);\nprod_cat.GetAsync();\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html#GetAsync\">GetAsync()<\/a>&nbsp;method of the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html\">ProductCatalog<\/a>&nbsp;instance is called, TT .NET SDK performs a lookup for the products based on the market that it is given. Whether the products were found or not, the specified event handler method is called. The following code snippet illustrates the structure of this event handler.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private void prod_cat_OnData(object sender, ProductCatalogEventArgs e)\n{\n  if (e.Event == ProductDataEvent.Found)\n  {\n    \/\/ Products were found\n    foreach (KeyValuePair&lt;ProductKey, Product&gt; kvp in e.ProductCatalog.Products)\n    {\n      Console.WriteLine(\"Key = {0} : Value = {1}\", kvp.Key, kvp.Value);\n    }\n  }\n  else\n  {\n    \/\/ Products were not found\n    Console.WriteLine(\"Cannot find product: {0}\", e.Message);\n  }\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"cleaning-up\"><a href=\"\/tt-net-sdk\/articles\/instr-products.html#cleaning-up\"><\/a>Cleaning up<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">When you shut down your application, you should detach all event handlers and call the&nbsp;<code>Dispose()<\/code>&nbsp;method for each instance of the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html\">ProductCatalog<\/a>&nbsp;class as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>prod_cat.OnData -= prod_cat_OnData;\nprod_cat.Dispose();\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"about-the-product-class\"><a href=\"\/tt-net-sdk\/articles\/instr-products.html#about-the-product-class\"><\/a>About the Product class<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.Product.html\">Product<\/a>&nbsp;class provides the data as it relates to a given product. Its members include:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ product name\npublic string Name;\n\/\/ product description\npublic string Description;\n\/\/ product\u2019s currency\npublic Currency Currency;\n\/\/ ProductKey struct\npublic ProductKey Key;\n\/\/ product\u2019s market\npublic Market Market;\n\/\/ product\u2019s product type\npublic ProductType Type;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductKey.html\">ProductKey<\/a>&nbsp;struct is a simple collection of the product\u2019s descriptive information. Its constructors and members include:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Constructor\npublic ProductKey(MarketId marketId, tt_net_sdk.ProductType type, string name);\n\n\/\/ TT\u2019s identifier for this product\npublic UInt64 ProductId;\n\/\/ MarketKey struct\npublic MarketKey MarketKey;\n\/\/ product\u2019s name\npublic string Name;\n\/\/ product\u2019s product type\npublic tt_net_sdk.ProductType Type;\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Note that the&nbsp;<code>ProductId<\/code>&nbsp;is only populated if the instance is constructed as a result of a product fetch via the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html\">ProductCatalog<\/a>&nbsp;class.<\/p>\n","protected":false},"excerpt":{"rendered":"<h2 class=\"wp-block-heading\" id=\"fetching-all-products-for-a-given-market\">Fetching all products for a given market<\/h2>\n<p class=\"wp-block-paragraph\">To fetch all products for a given market, you:<\/p>\n<h2 class=\"wp-block-heading\" id=\"instantiating-the-productcatalog-class\"><a href=\"\/tt-net-sdk\/articles\/instr-products.html#instantiating-the-productcatalog-class\"><\/a>Instantiating the ProductCatalog class<\/h2>\n<p class=\"wp-block-paragraph\">The&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html\">ProductCatalog<\/a>&nbsp;class provides the following constructors that let you identify a market using specific criteria.<\/p>\n<p class=\"wp-block-paragraph\">The following code snippet illustrates how to instantiate this class using a&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.MarketId.html\">MarketId<\/a>.<\/p>\n<h2 class=\"wp-block-heading\" id=\"synchronous-fetch\"><a href=\"\/tt-net-sdk\/articles\/instr-products.html#synchronous-fetch\"><\/a>Synchronous fetch<\/h2>\n<p class=\"wp-block-paragraph\">Once an&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html\">ProductCatalog<\/a>&nbsp;object has been created, you can simply call the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog_Get.html\">Get()<\/a>&nbsp;method to perform a synchronous lookup of the products as shown below. Note that although this is normally fairly quick, your execution thread will be blocked until this action is complete.<\/p>\n<h2 class=\"wp-block-heading\" id=\"asynchronous-fetch\"><a href=\"\/tt-net-sdk\/articles\/instr-products.html#asynchronous-fetch\"><\/a>Asynchronous fetch<\/h2>\n<p class=\"wp-block-paragraph\">If you prefer not to be blocked, you can register a callback function to be called once the fetching has been completed as shown below.<\/p>\n<p class=\"wp-block-paragraph\">After the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html#GetAsync\">GetAsync()<\/a>&nbsp;method of the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html\">ProductCatalog<\/a>&nbsp;instance is called, TT .NET SDK performs a lookup for the products based on the market that it is given. Whether the products were found or not, the specified event handler method is called. The following code snippet illustrates the structure of this event handler.<\/p>\n<h2 class=\"wp-block-heading\" id=\"cleaning-up\"><a href=\"\/tt-net-sdk\/articles\/instr-products.html#cleaning-up\"><\/a>Cleaning up<\/h2>\n<p class=\"wp-block-paragraph\">When you shut down your application, you should detach all event handlers and call the&nbsp;<code>Dispose()<\/code>&nbsp;method for each instance of the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html\">ProductCatalog<\/a>&nbsp;class as follows:<\/p>\n<h2 class=\"wp-block-heading\" id=\"about-the-product-class\"><a href=\"\/tt-net-sdk\/articles\/instr-products.html#about-the-product-class\"><\/a>About the Product class<\/h2>\n<p class=\"wp-block-paragraph\">The&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.Product.html\">Product<\/a>&nbsp;class provides the data as it relates to a given product. Its members include:<\/p>\n<p class=\"wp-block-paragraph\">The&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductKey.html\">ProductKey<\/a>&nbsp;struct is a simple collection of the product\u2019s descriptive information. Its constructors and members include:<\/p>\n<p class=\"wp-block-paragraph\">Note that the&nbsp;<code>ProductId<\/code>&nbsp;is only populated if the instance is constructed as a result of a product fetch via the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.ProductCatalog.html\">ProductCatalog<\/a>&nbsp;class.<\/p>\n","protected":false},"author":2,"template":"wp-custom-template-single-doc-tt-net-sdk","meta":{"_acf_changed":true,"footnotes":""},"docs-category":[772],"class_list":["post-8052","doc","type-doc","status-publish","hentry","docs-category-working-with-instruments-tt-net-sdk"],"acf":[],"_links":{"self":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc\/8052","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc"}],"about":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/types\/doc"}],"author":[{"embeddable":true,"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/users\/2"}],"version-history":[{"count":0,"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc\/8052\/revisions"}],"wp:attachment":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/media?parent=8052"}],"wp:term":[{"taxonomy":"docs-category","embeddable":true,"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/docs-category?post=8052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}