{"id":7013,"date":"2025-08-28T22:11:57","date_gmt":"2025-08-29T03:11:57","guid":{"rendered":"https:\/\/librarytestdev.wpenginepowered.com\/?post_type=doc&#038;p=7013"},"modified":"2026-06-29T11:09:05","modified_gmt":"2026-06-29T16:09:05","slug":"working-with-price-subscriptions","status":"publish","type":"doc","link":"https:\/\/library-staging.tradingtechnologies.com\/apis\/tt-core-sdk\/subscribing-for-market-data\/working-with-price-subscriptions\/","title":{"rendered":"Working with Price Subscriptions"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong>\u00a0Market data subscriptions are throttled at 750 per second and applications are limited to making no more than 15,000 market data subscriptions.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To create a price subscription and start receiving updates, you:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Create a class that is derived from\u00a0<strong>ttsdk::IPriceEventHandler<\/strong>\u00a0and defines your event handler. You must provide implementations for:\n<ul class=\"wp-block-list\">\n<li>virtual void OnPriceUpdate(const uint64_t subId, const InstrumentPtr&amp; instrument, const PriceSnap&amp; snap) = 0;\n<ul class=\"wp-block-list\">\n<li>Callback delivering price updates<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>virtual void OnError(const uint64_t subId, const InstrumentPtr&amp; instrument, const SubscriptionError code, const char* error) = 0;\n<ul class=\"wp-block-list\">\n<li>Callback fired when an error occurs fulfilling a price subscription request<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>virtual void OnDisconnect(const uint64_t subId, const InstrumentPtr&amp; instrument, const PriceEventType type) = 0;\n<ul class=\"wp-block-list\">\n<li>Callback fired when an disconnection event happens<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>virtual void OnUnsubscribed(const uint64_t subId) = 0;\n<ul class=\"wp-block-list\">\n<li>Callback fired when the unsubscribe request is complete and it is safe to destroy the handler object<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Call the SubscribePrices() function passing your event handler instance variable.\n<ul class=\"wp-block-list\">\n<li>The SubscribePrices() function allows you to specify whether to wish to optionally receive:\n<ul class=\"wp-block-list\">\n<li>market depth<\/li>\n\n\n\n<li>exchange calculated and disseminated implied prices<\/li>\n\n\n\n<li>TT calculated and disseminated implied prices<\/li>\n\n\n\n<li>TT\u2019s simulation price stream<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">The following code snippet demonstrates an example of this process.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\nclass PriceObserver : public ttsdk::IPriceEventHandler\n{\n  public:\n        PriceObserver() {}\n\n      virtual void OnPriceUpdate(const uint64_t subId, \n              const ttsdk::InstrumentPtr&amp; instrument, const ttsdk::PriceSnap&amp; snap)\n      {\n              std::cout &lt;&lt; \u201cPrice snapshot received.\u201d &lt;&lt; std::endl;\n      }\n\n      virtual void OnError(const uint64_t subId, const ttsdk::InstrumentPtr&amp; instrument, \n              const ttsdk::SubscriptionError code, const char* error)\n      {\n              std::cout &lt;&lt; \"Error &#91;\" &lt;&lt; error  &lt;&lt; \"] occurred for instrument:\" \n                      &lt;&lt; instrument->GetAlias() &lt;&lt; \" subId=\" &lt;&lt; subId \n                      &lt;&lt; \" code=\" &lt;&lt; (int)code &lt;&lt; std::endl;\n      }\n\n      virtual void OnDisconnect(const uint64_t subId, \n              const ttsdk::InstrumentPtr&amp; instrument, const ttsdk::PriceEventType type)\n      {\n              std::cout &lt;&lt; \"Prices disconnected for subscription for instrument:\" \n                      &lt;&lt; instrument->GetAlias() &lt;&lt; \" subid=\" &lt;&lt; subId &lt;&lt; std::endl;\n      }\n\n      virtual void OnUnsubscribed(const uint64_t subId) \n      {\n              std::cout &lt;&lt; \"Price observer for subId=\" &lt;&lt; subId \n                      &lt;&lt; \" has been successfully unsubscribed. \" &lt;&lt; std::endl;\n      }        \n};\n\nvoid foo()\n{\n        \/\/ \u2026\n\n        PriceObserver prcObserver;\n\n        ttsdk::Instrument::ResponseCode respCode;\n        ttsdk::MarketId market = ttsdk::MarketId::CME;\n        std::string product = \u201cGE\u201d;\n        ttsdk::ProductType productType = ttsdk::ProductType::Future;\n        std::string alias = \"GE Sep28\";\n        ttsdk::InstrumentPtr instrument = ttsdk::GetInstrument(market, product.c_str(),\n                  productType, alias.c_str(), respCode);\n        if (!instrument)\n        {\n          std::cout &lt;&lt; \"Unable to find instrument with alias = \u201c &lt;&lt; alias &lt;&lt; std::endl;\n        }\n        else\n        {\n          uint64_t subId = 0;\n          subId = ttsdk::SubscribePrices(instrument, 10, true, true, false, &amp;prcObserver);\n          std::cout &lt;&lt; \"Subscription id=\" &lt;&lt; subId &lt;&lt; std::endl; \n        }\n\n          \/\/ ...\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p class=\"wp-block-paragraph\"><strong>Note:<\/strong>\u00a0Market data subscriptions are throttled at 750 per second and applications are limited to making no more than 15,000 market data subscriptions.<\/p>\n<p class=\"wp-block-paragraph\">To create a price subscription and start receiving updates, you:<\/p>\n<p class=\"wp-block-paragraph\">The following code snippet demonstrates an example of this process.<\/p>\n","protected":false},"author":2,"template":"wp-custom-template-single-doc-tt-core-sdk","meta":{"_acf_changed":false,"footnotes":""},"docs-category":[447],"class_list":["post-7013","doc","type-doc","status-publish","hentry","docs-category-subscribing-for-market-data"],"acf":[],"_links":{"self":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc\/7013","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\/7013\/revisions"}],"wp:attachment":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/media?parent=7013"}],"wp:term":[{"taxonomy":"docs-category","embeddable":true,"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/docs-category?post=7013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}