{"id":8094,"date":"2025-09-04T23:21:37","date_gmt":"2025-09-05T04:21:37","guid":{"rendered":"https:\/\/librarytestdev.wpenginepowered.com\/?post_type=doc&#038;p=8094"},"modified":"2025-09-04T23:23:48","modified_gmt":"2025-09-05T04:23:48","slug":"fetching-a-list-of-all-algos","status":"publish","type":"doc","link":"https:\/\/library-staging.tradingtechnologies.com\/apis\/tt-net-sdk\/working-with-algos\/algo-server\/fetching-a-list-of-all-algos\/","title":{"rendered":"Fetching a list of all algos"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Launching an algo requires that you first fetch its full definition. You can fetch a partial definition of all of your algos as well as any that have been shared with you using the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.AlgoCatalog.html\">AlgoCatalog<\/a>&nbsp;class. You can then fetch an individual algo\u2019s full definition using the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.AlgoLookup.html\">AlgoLookup<\/a>&nbsp;class.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"steps-for-fetching-a-list-of-algo-definitions\"><a href=\"\/tt-net-sdk\/articles\/as-fetch-all.html#steps-for-fetching-a-list-of-algo-definitions\"><\/a>Steps for fetching a list of algo definitions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To fetch a partial definition of all of your algos as well as any that have been shared with you, 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.AlgoCatalog.html\">AlgoCatalog<\/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.AlgoCatalog.html#tt_net_sdk_AlgoCatalog_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 algo are available.<\/li>\n\n\n\n<li>Register this event handler with the\u00a0<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.AlgoCatalog.html\">AlgoCatalog<\/a>\u00a0instance.<\/li>\n\n\n\n<li>Call the\u00a0<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.AlgoCatalog.html#tt_net_sdk_AlgoCatalog_GetAsync.html\">GetAsync()<\/a>\u00a0method of the\u00a0<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.AlgoCatalog.html\">AlgoCatalog<\/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-algocatalog-class\"><a href=\"\/tt-net-sdk\/articles\/as-fetch-all.html#instantiating-the-algocatalog-class\"><\/a>Instantiating the AlgoCatalog class<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.AlgoCatalog.html\">AlgoCatalog<\/a>&nbsp;class provides the following constructor.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public AlgoCatalog(Dispatcher dispatcher);\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The following code snippet illustrates how to instantiate this class.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>AlgoCatalog algo_cat = new AlgoCatalog(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\/as-fetch-all.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.AlgoCatalog.html\">AlgoCatalog<\/a>&nbsp;object has been created, you can simply call the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.AlgoCatalog.html#tt_net_sdk_AlgoCatalog_Get\">Get()<\/a>&nbsp;method to perform a synchronous lookup of the algos 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 = algo_cat.Get();\nif (e == ProductDataEvent.Found)\n{\n  \/\/ Algos were found\n  foreach (AlgoInfo ai in algo_cat.Algos)\n  {\n      Console.WriteLine(\"Alias = {0}\", ai.Alias);\n  }\n}\nelse\n{\n  \/\/ Algos were not found\n  Console.WriteLine(\"Cannot find algos: {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\/as-fetch-all.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>algo_cat.OnData += new EventHandler&lt;AlgoCatalogEventArgs&gt;(algo_cat_OnData);\nalgo_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.AlgoCatalog.html#tt_net_sdk_AlgoCatalog_GetAsync.html\">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 the lookup. Whether any algos 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 algo_cat_OnData(object sender, AlgoCatalogEventArgs e)\n{\n  if (e.Event == ProductDataEvent.Found)\n  {\n    \/\/ Algos were found\n    foreach (AlgoInfo ai in algo_cat.Algos)\n    {\n      Console.WriteLine(\"Name = {0}\", ai.Alias);\n    }\n  }\n  else\n  {\n    \/\/ Algos were not found\n    Console.WriteLine(\"Cannot find algos: {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\/as-fetch-all.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.AlgoCatalog.html\">AlgoCatalog<\/a>&nbsp;class as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>algo_cat.OnData -= algo_cat_OnData;\nalgo_cat.Dispose();\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"about-the-algoinfo-struct\"><a href=\"\/tt-net-sdk\/articles\/as-fetch-all.html#about-the-algoinfo-struct\"><\/a>About the AlgoInfo struct<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.AlgoInfo.html\">AlgoInfo<\/a>&nbsp;struct provides the basic data as it relates to a given algo. Its members include:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/  Algo\u2019s alias\npublic string        Alias;\n\/\/ Category -- ADL, Vendor, SSE, TT, etc.\npublic AlgoCategory  Category;\n\/\/ Whether this algo is owned by you or shared with you\npublic bool          IsMyAlgo;\n\/\/ Whether this algo is deployed or not\npublic bool          IsDeployed;\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p class=\"wp-block-paragraph\">Launching an algo requires that you first fetch its full definition. You can fetch a partial definition of all of your algos as well as any that have been shared with you using the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.AlgoCatalog.html\">AlgoCatalog<\/a>&nbsp;class. You can then fetch an individual algo\u2019s full definition using the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.AlgoLookup.html\">AlgoLookup<\/a>&nbsp;class.<\/p>\n<h2 class=\"wp-block-heading\" id=\"steps-for-fetching-a-list-of-algo-definitions\"><a href=\"\/tt-net-sdk\/articles\/as-fetch-all.html#steps-for-fetching-a-list-of-algo-definitions\"><\/a>Steps for fetching a list of algo definitions<\/h2>\n<p class=\"wp-block-paragraph\">To fetch a partial definition of all of your algos as well as any that have been shared with you, you:<\/p>\n<h2 class=\"wp-block-heading\" id=\"instantiating-the-algocatalog-class\"><a href=\"\/tt-net-sdk\/articles\/as-fetch-all.html#instantiating-the-algocatalog-class\"><\/a>Instantiating the AlgoCatalog class<\/h2>\n<p class=\"wp-block-paragraph\">The&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.AlgoCatalog.html\">AlgoCatalog<\/a>&nbsp;class provides the following constructor.<\/p>\n<p class=\"wp-block-paragraph\">The following code snippet illustrates how to instantiate this class.<\/p>\n<h2 class=\"wp-block-heading\" id=\"synchronous-fetch\"><a href=\"\/tt-net-sdk\/articles\/as-fetch-all.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.AlgoCatalog.html\">AlgoCatalog<\/a>&nbsp;object has been created, you can simply call the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.AlgoCatalog.html#tt_net_sdk_AlgoCatalog_Get\">Get()<\/a>&nbsp;method to perform a synchronous lookup of the algos 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\/as-fetch-all.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.AlgoCatalog.html#tt_net_sdk_AlgoCatalog_GetAsync.html\">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 the lookup. Whether any algos 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\/as-fetch-all.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.AlgoCatalog.html\">AlgoCatalog<\/a>&nbsp;class as follows:<\/p>\n<h2 class=\"wp-block-heading\" id=\"about-the-algoinfo-struct\"><a href=\"\/tt-net-sdk\/articles\/as-fetch-all.html#about-the-algoinfo-struct\"><\/a>About the AlgoInfo struct<\/h2>\n<p class=\"wp-block-paragraph\">The&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.AlgoInfo.html\">AlgoInfo<\/a>&nbsp;struct provides the basic data as it relates to a given algo. Its members include:<\/p>\n","protected":false},"author":2,"template":"wp-custom-template-single-doc-tt-net-sdk","meta":{"_acf_changed":true,"footnotes":""},"docs-category":[780],"class_list":["post-8094","doc","type-doc","status-publish","hentry","docs-category-algo-server"],"acf":[],"_links":{"self":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc\/8094","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\/8094\/revisions"}],"wp:attachment":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/media?parent=8094"}],"wp:term":[{"taxonomy":"docs-category","embeddable":true,"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/docs-category?post=8094"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}