{"id":8081,"date":"2025-09-04T23:21:48","date_gmt":"2025-09-05T04:21:48","guid":{"rendered":"https:\/\/librarytestdev.wpenginepowered.com\/?post_type=doc&#038;p=8081"},"modified":"2025-09-04T23:23:50","modified_gmt":"2025-09-05T04:23:50","slug":"working-with-fills","status":"publish","type":"doc","link":"https:\/\/library-staging.tradingtechnologies.com\/apis\/tt-net-sdk\/working-with-orders-and-fills-tt-net-sdk\/working-with-fills\/","title":{"rendered":"Working with fills"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">TT .NET SDK offers two methods to receive fills.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The\u00a0<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.TradeSubscription.html\">TradeSubscription<\/a>\u00a0class provides events for fills that occurred since the TT .NET SDK application started running.<\/li>\n\n\n\n<li>The\u00a0<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillsSubscription.html\">FillsSubscription<\/a>\u00a0class provides events for fills that occurred since the beginning of the trading session as well as fills that occurred since the TT .NET SDK application started running.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"supported-update-events\"><a href=\"\/tt-net-sdk\/articles\/of-working-fills.html#supported-update-events\"><\/a>Supported update events<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillsSubscription.html\">FillsSubscription<\/a>&nbsp;object fires the following events.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillsSubscription.html#tt_net_sdk_FillsSubscription_FillAdded\">FillAdded<\/a>: Fired to deliver fills that occurred since the application started running<\/li>\n\n\n\n<li><a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillsSubscription.html#tt_net_sdk_FillsSubscription_FillAmended\">FillAmended<\/a>: Fired when a fill&#8217;s details have been modified<\/li>\n\n\n\n<li><a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillsSubscription.html#tt_net_sdk_FillsSubscription_FillBookDownload\">FillBookDownload<\/a>: Fired to deliver fills that occurred since the beginning of the trading session for a given market. Will not fire if fills have not occurred.<\/li>\n\n\n\n<li><a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillsSubscription.html#tt_net_sdk_FillsSubscription_FillConfirmed\">FillConfirmed<\/a>:Fired when a fill confirmation is received<\/li>\n\n\n\n<li><a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillsSubscription.html#tt_net_sdk_FillsSubscription_FillDeleted\">FillDeleted<\/a>: Fired when a fill is deleted<\/li>\n\n\n\n<li><a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillsSubscription.html#tt_net_sdk_FillsSubscription_FillListEnd\">FillListEnd<\/a>: Fired when the fill download for fills that occurred since the beginning of the trading session is completed for a given market<\/li>\n\n\n\n<li><a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillsSubscription.htmltt_net_sdk_FillsSubscription_FillListStart\">FillListStart<\/a>: Fired when the fill download for fills that occurred since the beginning of the trading session begins for a given market.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">If fills have not yet occurred, a&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillsSubscription.htmltt_net_sdk_FillsSubscription_FillListStart\">FillListStart<\/a>&nbsp;event will be received followed by a&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillsSubscription.html#tt_net_sdk_FillsSubscription_FillListEnd\">FillListEnd<\/a>&nbsp;event. A&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillsSubscription.html#tt_net_sdk_FillsSubscription_FillBookDownload\">FillBookDownload<\/a>&nbsp;does not fire if there are no fills.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"subscribing-for-update-events\"><a href=\"\/tt-net-sdk\/articles\/of-working-fills.html#subscribing-for-update-events\"><\/a>Subscribing for update events<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can subscribe for update events as follows before calling the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillsSubscription.html#tt_net_sdk_FillsSubscription_Start\">FillsSubscription.Start()<\/a>&nbsp;method. The following example demonstrates this process.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>m_api.StartFillFeed();\n\nFillSubscription m_fs = new FillsSubscription(tt_net_sdk.Dispatcher.Current);\nm_fs.FillAdded +=  m_fs_FillAdded;\nm_fs.FillBookDownload += m_fs_FillBookDownload;\nm_fs.FillListEnd += m_fs_FillListEnd;\nm_fs.FillListStart += m_fs_FillListStart;\nm_fs.Start()\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"defining-event-handlers\"><a href=\"\/tt-net-sdk\/articles\/of-working-fills.html#defining-event-handlers\"><\/a>Defining event handlers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The following code snippet shows the structure for these event handlers.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void m_fs_FillListStart(object sender, FillListEventArgs e)\n{\n}\n\nvoid m_fs_FillListEnd(object sender, FillListEventArgs e)\n{\n}\n\nvoid m_fs_FillBookDownload(object sender, FillBookDownloadEventArgs e)\n{\n\tforeach (Fill f in e.Fills)\n\t{\n\t\t\/\/ process fill\n\t}\n}\n\nvoid m_fs_FillAdded(object sender, FillAddedEventArgs e)\n{\n\t\/\/ process fill contained in e.Fill\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"publishing-manual-fills\"><a href=\"\/tt-net-sdk\/articles\/of-working-fills.html#publishing-manual-fills\"><\/a>Publishing Manual Fills<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">TT .NET SDK also allows publishing manual fills via the API as demonstrated in the following code snippet.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public bool send_ManualFill(out string response)\n{\n\tPrice price = Price.FromDecimal(instrument, Convert.ToDecimal(2986));\n\t\n\tm_fp = new FillProfile(instrument);\n\tm_fp.MarketId = MarketId.CME;\n\tm_fp.Quantity = Quantity.FromDecimal(instrument, Convert.ToDecimal(5));\n\tm_fp.Account = m_apiInstance.DefaultAccount;\n\tbool isPublishedManualFill = m_ts.PublishManualFill(m_fp, out response);\n\n\treturn isPublishedManualFill;\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"downloading-fills\"><a href=\"\/tt-net-sdk\/articles\/of-working-fills.html#downloading-fills\"><\/a>Downloading Fills<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can use the&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillDownload.html\">FillDownload<\/a>&nbsp;class to download fills for a specific period of time. The&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillDownload.html\">FillDownload<\/a>&nbsp;class allows you to select a start and end time, provided in nanos past the epoch. The download can be either synchronous via&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillDownload.html#tt_net_sdk_FillDownload_Get\">Get()<\/a>&nbsp;or asynchronous via&nbsp;<a href=\"\/tt-net-sdk\/api\/tt_net_sdk.FillDownload.html#tt_net_sdk_FillDownload_GetAsync\">GetAsync()<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public void DownloadFills()\n{\n    DateTime UtcEpochTimeStart_ = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);\n    \/\/ start and end times in nanos past the epoch\n    DateTime dt = new DateTime(2023, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);\n    UInt64 start = (UInt64)(from - UtcEpochTimeStart_).Ticks * 100;\t    \n    dt = new DateTime(2023, 2, 1, 0, 0, 0, 0, DateTimeKind.Utc);\n    UInt64 end = (UInt64)(from - UtcEpochTimeStart_).Ticks * 100;\n\n    FillDownload fd = new FillDownload(this.dispatcher, MarketId.CME, start, 0);\n    \/\/ synchronous retrieval \n    FillDownloadResult code = fd.Get();\n    if (code == FillDownloadResult.Success)\n    {\n\t\/\/ fd.Fills contains downloaded fills\n    }    \n}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>TT .NET SDK offers two methods to receive fills. Supported update events A&nbsp;FillsSubscription&nbsp;object  [&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-8081","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\/8081","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\/8081\/revisions"}],"wp:attachment":[{"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/media?parent=8081"}],"wp:term":[{"taxonomy":"docs-category","embeddable":true,"href":"https:\/\/library-staging.tradingtechnologies.com\/ja\/wp-json\/wp\/v2\/docs-category?post=8081"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}