{"id":7016,"date":"2025-08-28T22:11:57","date_gmt":"2025-08-29T03:11:57","guid":{"rendered":"https:\/\/librarytestdev.wpenginepowered.com\/?post_type=doc&#038;p=7016"},"modified":"2026-06-29T11:17:47","modified_gmt":"2026-06-29T16:17:47","slug":"extracting-time-and-sales-values","status":"publish","type":"doc","link":"https:\/\/library-test.tradingtechnologies.com\/apis\/tt-core-sdk\/subscribing-for-market-data\/extracting-time-and-sales-values\/","title":{"rendered":"Extracting Time and Sales Values"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">After the subscription starts, TT Core SDK invokes the event handler method you registered with the subscription for every Time &amp; Sales update passing an instance of a\u00a0<strong>TimeSales<\/strong>\u00a0struct. The\u00a0<strong>TimeSales<\/strong>\u00a0struct contains an array of Trade struct instances where each contains the data corresponding to a trade that occurred in the market, including:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>        \ndouble last_trade_price = NAN; \ndouble last_trade_quantity = NAN;  \nttsdk::TradeType trade_side;\nuint64_t epoch_transact_time_nano;\nuint64_t exchange_transact_time_ns;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In other words, you will receive data for one or more trades when this callback is fired. The following code snippet demonstrates how to process a price subscription update.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\nstd::string to_string(const ttsdk::TimeSales&amp; ts)\n{\n  std::ostringstream ss;\n\n  if (ts.event_type == ttsdk::PriceEventType::DIRECT)\n      ss &lt;&lt; \"TimeSales:     &#91;direct event]\\n\";\n  else if (ts.event_type == ttsdk::PriceEventType::CALCULATED_IMPLIEDS)\n      ss &lt;&lt; \"TimeSales:     &#91;calulcated implieds event]\\n\";\n  else if (ts.event_type == ttsdk::PriceEventType::SIMULATED)\n      ss &lt;&lt; \"TimeSales:     &#91;simulated event]\\n\";\n  else\n      ss &lt;&lt; \"TimeSales:     &#91;unknown event]\\n\";\n\n  for (size_t i=0; i&lt; ts.count;++i) \n  {\n      ss &lt;&lt;  \"side=\" &lt;&lt; (int)ts.trades&#91;i].trade_side &lt;&lt; '\\n'\n          &lt;&lt; \"ltp=\" &lt;&lt; ts.trades&#91;i].last_trade_price &lt;&lt; '\\n'\n          &lt;&lt; \"ltq=\" &lt;&lt; ts.trades&#91;i].last_trade_quantity &lt;&lt; '\\n'\n          &lt;&lt; \"trade_indicator=\" &lt;&lt; (int)ts.trades&#91;i].indicator &lt;&lt; '\\n'\n          &lt;&lt; \"trade_qualifier=\" &lt;&lt; (int)ts.trades&#91;i].qualifier &lt;&lt; '\\n'\n          &lt;&lt; \"otc_type=\" &lt;&lt; (int)ts.trades&#91;i].otc_type &lt;&lt; '\\n';\n  }\n  \n  return ss.str();\n}\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p class=\"wp-block-paragraph\">After the subscription starts, TT Core SDK invokes the event handler method you registered with the subscription for every Time &amp; Sales update passing an instance of a\u00a0<strong>TimeSales<\/strong>\u00a0struct. The\u00a0<strong>TimeSales<\/strong>\u00a0struct contains an array of Trade struct instances where each contains the data corresponding to a trade that occurred in the market, including:<\/p>\n<p class=\"wp-block-paragraph\">In other words, you will receive data for one or more trades when this callback is fired. The following code snippet demonstrates how to process a price subscription update.<\/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-7016","doc","type-doc","status-publish","hentry","docs-category-subscribing-for-market-data"],"acf":[],"_links":{"self":[{"href":"https:\/\/library-test.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc\/7016","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/library-test.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc"}],"about":[{"href":"https:\/\/library-test.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/types\/doc"}],"author":[{"embeddable":true,"href":"https:\/\/library-test.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/users\/2"}],"version-history":[{"count":0,"href":"https:\/\/library-test.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc\/7016\/revisions"}],"wp:attachment":[{"href":"https:\/\/library-test.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/media?parent=7016"}],"wp:term":[{"taxonomy":"docs-category","embeddable":true,"href":"https:\/\/library-test.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/docs-category?post=7016"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}