{"id":7030,"date":"2025-08-28T22:12:00","date_gmt":"2025-08-29T03:12:00","guid":{"rendered":"https:\/\/librarytestdev.wpenginepowered.com\/?post_type=doc&#038;p=7030"},"modified":"2026-06-30T10:29:25","modified_gmt":"2026-06-30T15:29:25","slug":"using-position-reserve-orders","status":"publish","type":"doc","link":"https:\/\/library-staging.tradingtechnologies.com\/apis\/tt-core-sdk\/creating-a-tt-application-server\/using-position-reserve-orders\/","title":{"rendered":"Using Position Reserve Orders"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Position Reserve (PR) orders are discussed in detail in the&nbsp;<a href=\"https:\/\/library-staging.tradingtechnologies.com\/tt-core-sdk\/of-position-reserve-orders.html\">Position Reserve Orders<\/a>&nbsp;section. If you plan to utilize them when running as a TT Application Server, you would call the SDKAlgo::ReserveRisk() method, preferably from the strategy\u2019s Start() method.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><br>\n\nbool TrailingCrossStrategy::Start(ttsdk::SDKAlgoPtr algoOrder, ttsdk::SDKAlgoRequestPtr req)\n{\n    \/\/ ...\n\n    ttsdk::RiskSide side = ttsdk::RiskSide::Buy;\n    if (profile_.side == ttsdk::OrderSide::Sell)\n        side = ttsdk::RiskSide::Sell;\n\n    algoOrder-&gt;ReserveRisk(algoOrder-&gt;GetInstrument(), profile_.account_id, side, profile_.quantity, profile_.quantity);\n    algoOrder-&gt;OnPendingRequestCompleted(ttsdk::AlgoResponseCode::Ok);\n\n    \/\/ ...\n}\n\n\n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When the request to reserve risk returns, the SDKAlgoManager::OnRiskReserved() method will be called. You can then notify the strategy which made the request as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void SDKAlgoManager::OnRiskReserved(ttsdk::SDKAlgoPtr algoOrder, const uint64_t instrumentId, const uint64_t accountId,\nconst ttsdk::RiskSide side, const ttsdk::AlgoResponseCode code)\n{\nstd::cout &lt;&lt; \"SDKAlgoManager::OnRiskReserved \" &lt;&lt; algoOrder->GetOrderId() &lt;&lt; std::endl;\nstd::shared_ptr&lt;BaseStrategy> strategy(nullptr);\n{\n    std::unique_lock&lt;std::mutex> lock(this->mutexStrategies_);\n    auto iter = strategies_.find(algoOrder->GetOrderId());\n    if (iter != strategies_.end())\n    {\n        strategy = iter->second;\n    }\n}\nif (strategy)\n{\n    return strategy->OnRiskReserved(instrumentId, accountId, side, code);\n}\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To process this call, you must override the BaseStrategy:: OnRiskReserved() method in your specific strategy. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\n\n\nvoid TrailingCrossStrategy::OnRiskReserved(const uint64_t instrumentId, const uint64_t accountId, const ttsdk::RiskSide side, const ttsdk::AlgoResponseCode code)\n{\n    if (code != ttsdk::AlgoResponseCode::Ok)\n    {\n        ttsdk::TTLogWarning(\"TrailingCrossStrategy failed to reserve risk for algoId: %s &#91;instrumentId: %llu accountId: %llu side: %s]\", GetOrderId(), instrumentId, accountId, ttsdk::ToString(side));\n        algoOrder_-&gt;FailAlgo(\"Position reserve request failed.\");\n    }\n    else\n    {\n        ttsdk::TTLogInfo(\"TrailingCrossStrategy reserved risk for algoId: %s &#91;instrumentId: %llu accountId: %llu side: %s]\", GetOrderId(), instrumentId, accountId, ttsdk::ToString(side));\n    }\n}\n\n\n\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Similarly, you can then release Position Reserve orders by calling the SDKAlgo::ReleaseRisk() method. You can notify the strategy which made the request in the same way.<\/p>\n","protected":false},"excerpt":{"rendered":"<p class=\"wp-block-paragraph\">Position Reserve (PR) orders are discussed in detail in the&nbsp;<a href=\"https:\/\/library-staging.tradingtechnologies.com\/tt-core-sdk\/of-position-reserve-orders.html\">Position Reserve Orders<\/a>&nbsp;section. If you plan to utilize them when running as a TT Application Server, you would call the SDKAlgo::ReserveRisk() method, preferably from the strategy\u2019s Start() method.<\/p>\n<p class=\"wp-block-paragraph\">When the request to reserve risk returns, the SDKAlgoManager::OnRiskReserved() method will be called. You can then notify the strategy which made the request as follows:<\/p>\n<p class=\"wp-block-paragraph\">To process this call, you must override the BaseStrategy:: OnRiskReserved() method in your specific strategy. For example:<\/p>\n<p class=\"wp-block-paragraph\">Similarly, you can then release Position Reserve orders by calling the SDKAlgo::ReleaseRisk() method. You can notify the strategy which made the request in the same way.<\/p>\n","protected":false},"author":2,"template":"wp-custom-template-single-doc-tt-core-sdk","meta":{"_acf_changed":false,"footnotes":""},"docs-category":[449],"class_list":["post-7030","doc","type-doc","status-publish","hentry","docs-category-creating-a-tt-application-server"],"acf":[],"_links":{"self":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc\/7030","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":3,"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc\/7030\/revisions"}],"predecessor-version":[{"id":59710,"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc\/7030\/revisions\/59710"}],"wp:attachment":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/media?parent=7030"}],"wp:term":[{"taxonomy":"docs-category","embeddable":true,"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/docs-category?post=7030"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}