{"id":8083,"date":"2025-09-04T23:21:48","date_gmt":"2025-09-05T04:21:48","guid":{"rendered":"https:\/\/librarytestdev.wpenginepowered.com\/?post_type=doc&#038;p=8083"},"modified":"2025-09-04T23:23:50","modified_gmt":"2025-09-05T04:23:50","slug":"position-and-p-l","status":"publish","type":"doc","link":"https:\/\/library-staging.tradingtechnologies.com\/apis\/tt-net-sdk\/working-with-orders-and-fills-tt-net-sdk\/position-and-p-l\/","title":{"rendered":"Position and P &amp; L"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">TT .NET SDK allows you to obtain a snapshot of your positions and P&amp;L at any point after the API has successfully synchronized the order books by calling either the&nbsp;<strong>TTAPI.GetPositionSnapshot()<\/strong>&nbsp;or&nbsp;<strong>TTAPI.GetPositionSnapshots()<\/strong>&nbsp;methods.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The former will return a single Position object for the&nbsp;<strong>AccountKey<\/strong>&nbsp;and&nbsp;<strong>InstrumentKey<\/strong>&nbsp;that are provided. The latter returns a collection of Position objects for all unique AccountKey \/ InstrumentKey pairs that you have at least one fill. For example,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private TTAPI m_api;\n\n        public void ttNetApiInitHandler(TTAPI api, ApiCreationException ex)\n        {\n            if (ex == null)\n            {\n                Console.WriteLine(\"TT.NET SDK INITIALIZED\");\n\n                \/\/ Authenticate your credentials\n                m_api = api;\n                m_api.TTAPIStatusUpdate += new EventHandler&lt;TTAPIStatusUpdateEventArgs&gt;(m_api_TTAPIStatusUpdate);\n                m_api.OrderbookSynced += m_api_OrderbookSynced;\n                m_api.Start();\n            }\n            else if (ex.IsRecoverable)\n            {\n                \/\/ Initialization failed but retry is in progress...\n            }\n            else\n            {\n                Console.WriteLine(\"TT.NET SDK Initialization Failed: {0}\", ex.Message);\n                Dispose();\n            }\n        }\n\n        private void m_api_OrderbookSynced(object sender, EventArgs e)\n        {\n            IList&lt;Position&gt; lists = m_api.GetPositionSnapshots();\n        }\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Note<\/strong>: You must also set the&nbsp;<strong>TTAPIOptions.EnablePositions<\/strong>&nbsp;property to&nbsp;<strong>true<\/strong>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can also subscribe for position and P&amp;L updates by registering for&nbsp;<strong>TTAPI.ProfitLossChanged<\/strong>&nbsp;events as follows.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>private TTAPI m_api;\n\n        public void ttNetApiInitHandler(TTAPI api, ApiCreationException ex)\n        {\n            if (ex == null)\n            {\n                Console.WriteLine(\"TT.NET SDK INITIALIZED\");\n\n                \/\/ Authenticate your credentials\n                m_api = api;\n                m_api.TTAPIStatusUpdate += new EventHandler&lt;TTAPIStatusUpdateEventArgs&gt;(m_api_TTAPIStatusUpdate);\n                m_api.OrderbookSynced += m_api_OrderbookSynced;\n                m_api.ProfitLossChanged += new EventHandler&lt;ProfitLossChangedEventArgs&gt;(m_api_ProfitLossChanged);\n                m_api.Start();\n            }\n            else if (ex.IsRecoverable)\n            {\n                \/\/ Initialization failed but retry is in progress...\n            }\n            else\n            {\n                Console.WriteLine(\"TT.NET SDK Initialization Failed: {0}\", ex.Message);\n                Dispose();\n            }\n        }\n\n        private void m_api_ProfitLossChanged(object sender, ProfitLossChangedEventArgs e)\n        {\n            \/\/ \u2026\n        }\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>TT .NET SDK allows you to obtain a snapshot of your positions and P&amp;L at any point after the API has succe [&hellip;]<\/p>\n","protected":false},"author":2,"template":"wp-custom-template-single-doc-tt-net-sdk","meta":{"_acf_changed":true,"footnotes":""},"docs-category":[773],"class_list":["post-8083","doc","type-doc","status-publish","hentry","docs-category-working-with-orders-and-fills-tt-net-sdk"],"acf":[],"_links":{"self":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc\/8083","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\/8083\/revisions"}],"wp:attachment":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/media?parent=8083"}],"wp:term":[{"taxonomy":"docs-category","embeddable":true,"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/docs-category?post=8083"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}