{"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":"2025-09-04T17:17:28","modified_gmt":"2025-09-04T22:17:28","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>Position Reserve (PR) orders are discussed in detail in the <a href=\"\/tt-core-sdk\/of-position-reserve-orders.html\">Position Reserve Orders<\/a> 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&#8217;s Start() method.<\/p>\n\n<div class=\"language-plaintext highlighter-rouge\">\n    <div class=\"highlight\">\n        <pre class=\"highlight\"><code>\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    <\/div>\n<\/div>\n\n    <p>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<div class=\"language-plaintext highlighter-rouge\">\n    <div class=\"highlight\">\n        <pre class=\"highlight\"><code>\n\nvoid SDKAlgoManager::OnRiskReserved(ttsdk::SDKAlgoPtr algoOrder, const uint64_t instrumentId, const uint64_t accountId,\nconst ttsdk::RiskSide side, const ttsdk::AlgoResponseCode code)\n{\nstd::cout GetOrderId()  strategy(nullptr);\n{\n    std::unique_lock<:mutex> lock(this-&gt;mutexStrategies_);\n    auto iter = strategies_.find(algoOrder-&gt;GetOrderId());\n    if (iter != strategies_.end())\n    {\n        strategy = iter-&gt;second;\n    }\n}\nif (strategy)\n{\n    return strategy-&gt;OnRiskReserved(instrumentId, accountId, side, code);\n}\n}\n\n\n\n<\/:mutex><\/code><\/pre>\n    <\/div>\n<\/div>\n\n    <p>To process this call, you must override the BaseStrategy:: OnRiskReserved() method in your specific strategy.  For example:<\/p>\n\n\n<div class=\"language-plaintext highlighter-rouge\">\n    <div class=\"highlight\">\n        <pre class=\"highlight\"><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 [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 [instrumentId: %llu accountId: %llu side: %s]\", GetOrderId(), instrumentId, accountId, ttsdk::ToString(side));\n    }\n}\n\n\n\n<\/code><\/pre>\n    <\/div>\n<\/div>\n\n    <p>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.\n    <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Position Reserve (PR) orders are discussed in detail in the Position Reserve Orders section. If you plan to ut [&hellip;]<\/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":0,"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/doc\/7030\/revisions"}],"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}]}}