{"id":1493,"date":"2007-12-24T18:28:54","date_gmt":"2007-12-24T18:28:54","guid":{"rendered":"http:\/\/www.amibroker.org\/userkb\/2007\/12\/24\/high-frequency-automated-trading-hfat-part-2\/"},"modified":"2007-12-26T21:37:48","modified_gmt":"2007-12-26T21:37:48","slug":"high-frequency-automated-trading-hfat-part-2","status":"publish","type":"post","link":"http:\/\/www.amibroker.org\/editable_userkb\/2007\/12\/24\/high-frequency-automated-trading-hfat-part-2\/","title":{"rendered":"High-Frequency Automated Trading (HFAT); part 2"},"content":{"rendered":"

Interactive Brokers\u2019 Real-Time Volume Data<\/h3>\n

Just like with price data, volume data are subject to delays and BF (Backfill) corrections. Moreover, IB (Interactive Brokers) reports volume data in a manner that could cause major performance differences between backtesting and actual trading. <\/p>\n

This post outlines simple procedures to collect RT and BF data for comparison. No effort is made to explain the differences or to perform statistical analysis. The views expressed here are based on personal experiences and\/or may be anecdotal; not everything that happens in real-time trading is easy to explain. As always, if you have technical insight and\/or see inaccuracies, please comment for the benefit of future readers. <\/p>\n

As expected, IB RT volume data contain the usual bad ticks and delays that are corrected during backfill. However, and this is very important to the RT trader, IB adjusts live volumes at about 30-second intervals. This means that the volumes IB reports during RT trading do not accurately reflect market activity. This means also that volume data may be delayed by up to 30 seconds, instead of by the typical snapshot delay, which is about 300 milliseconds for price data. Comparing backfilled with real-time volume, it appears that the real-time periodic volume adjustments are re-distributed across individual snapshots during backfill. This post is intended to help you perform your own data analysis. The methods outlined below are intended to get you started. <\/p>\n

To collect and save real-time data: <\/p>\n

    \n
  1. Create a new database in the 5-second interval.\n
  2. Embed \u201cRD\u201d, for Raw Data, when naming the database.\n
  3. In Database Settings select the Interactive Brokers plugin.\n
  4. Pick a high volume stock, for example, AAPL (used in this post).\n
  5. Connect to the TWS (Trader Work Station), signing in to your Paper Trading account. Do not use the eDemo account.\n
  6. Collect about an hour\u2019s worth of real-time data. <\/li>\n<\/ol>\n

    The first thing that will happen when you connect to the TWS is that AmiBroker backfills approximately 2000 bars of 5-second data. This cannot be prevented and you must be careful to note the time where backfill ends and raw data collection starts. The simplest way is to place a vertical line on your chart and label it \u201cStart of real-time data\u201d. <\/p>\n

    To save the database: <\/p>\n

      \n
    1. Disconnect the IB plugin (see Plugin menu at right bottom of chart).\n
    2. Open Database Settings and set the database to Local.\n
    3. Place another vertical line to indicate where data collection stopped.\n
    4. Go to the File menu and save the database. <\/li>\n<\/ol>\n

      Be sure to set the Database Settings -> Data Source -> Local<\/i> before saving. If you do not do this the database will backfill on the next startup and this may corrupt your RT data sample. <\/p>\n

      The next step is to collect a sample of BF data that overlaps the previously collected real-time sample. To do this, you need to create another database. Since IB backfills only about 2000 bars of 5-second data, you should do this as soon as possible after collecting raw data, else the collection periods may not overlap and you will not be able to compare the two types of data. The procedure is the same as above except that you want to embed \u201cBF\u201d (for backfilled data) instead of \u201cRD\u201d in the database name. <\/p>\n

      To visually compare the two databases you can open two instances of AmiBroker and load the RT database in one and the BF database in the other. You can then display the two databases at the same time and visually compare the respective charts. You may want to display both a price chart and a volume chart in separate panes, as shown in the captures below. <\/p>\n

      You can use the code below to inspect your price chart: <\/p>\n

      <\/span><<\/span>b<\/span>><\/span>Plot<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>C<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>"Close"<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>colorBlack<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>styleBar<\/span><\/<\/span>b<\/span>>); <<\/span>p<\/span>><\/span>TN<\/span>=<<\/span>b<\/span>><\/span>TimeNum<\/span><\/<\/span>b<\/span>>(); <<\/span>p<\/span>><\/span>Cursortime <\/span>= <<\/span>b<\/span>><\/span>SelectedValue<\/span><\/<\/span>b<\/span>>(<\/span>TN<\/span>); <<\/span>p<\/span>><\/span>CumHL <\/span>= <<\/span>b<\/span>><\/span>Cum<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>IIf<\/span><\/<\/span>b<\/span>>(<\/span>TN<\/span>&<\/span>gt<\/span>;=<\/span>CursorTime<\/span>,<<\/span>b<\/span>><\/span>H<\/span><\/<\/span>b<\/span>>-<<\/span>b<\/span>><\/span>L<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>0<\/span><\/<\/span>b<\/span>>)); <<\/span>p<\/span>><<\/span>b<\/span>><\/span>Plot<\/span><\/<\/span>b<\/span>>(<\/span>CumHL<\/span>,<<\/span>b<\/span>><\/span>""<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>4<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>styleArea<\/span><\/<\/span>b<\/span>>|<<\/span>b<\/span>><\/span>styleOwnScale<\/span><\/<\/span>b<\/span>>); <<\/span>p<\/span>><<\/span>b<\/span>><\/span>Title<\/span><\/<\/span>b<\/span>>=<<\/span>b<\/span>><\/span>Name<\/span><\/<\/span>b<\/span>>()+<<\/span>b<\/span>><\/span>" Interactive Brokers BackFilled price data - "<\/span><\/<\/span>b<\/span>>+<<\/span>b<\/span>><\/span>Interval<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>2<\/span><\/<\/span>b<\/span>>); <\/span><\/pre>\n

      And this code to inspect your Volume chart: <\/p>\n

      <\/span><<\/span>b<\/span>><\/span>Plot<\/span><\/<\/span>b<\/span>>( <<\/span>b<\/span>><\/span>Volume<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>""<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>2<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>styleOwnScale<\/span><\/<\/span>b<\/span>>|<<\/span>b<\/span>><\/span>styleHistogram<\/span><\/<\/span>b<\/span>>|<<\/span>b<\/span>><\/span>styleThick<\/span><\/<\/span>b<\/span>>); <<\/span>p<\/span>><\/span>TN<\/span>=<<\/span>b<\/span>><\/span>TimeNum<\/span><\/<\/span>b<\/span>>(); <<\/span>p<\/span>><\/span>Cursortime <\/span>= <<\/span>b<\/span>><\/span>SelectedValue<\/span><\/<\/span>b<\/span>>(<\/span>TN<\/span>); <<\/span>p<\/span>><\/span>CV <\/span>= <<\/span>b<\/span>><\/span>Cum<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>IIf<\/span><\/<\/span>b<\/span>>(<\/span>TN<\/span>&<\/span>gt<\/span>;=<\/span>CursorTime<\/span>,<<\/span>b<\/span>><\/span>V<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>0<\/span><\/<\/span>b<\/span>>)); <<\/span>p<\/span>><<\/span>b<\/span>><\/span>Plot<\/span><\/<\/span>b<\/span>>(<\/span>CV<\/span>,<<\/span>b<\/span>><\/span>""<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>4<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>styleArea<\/span><\/<\/span>b<\/span>>); \r<<\/span>p<\/span>><<\/span>b<\/span>><\/span>Title<\/span><\/<\/span>b<\/span>>=<<\/span>b<\/span>><\/span>"Backfilled Volume data - "<\/span><\/<\/span>b<\/span>>+<<\/span>b<\/span>><\/span>Interval<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>2<\/span><\/<\/span>b<\/span>>); <\/span><\/pre>\n

      The above formulas will display basic charts plus a cumulative value (red area) for any parameter you would like to test. In the price chart, high-low range (H-L) is summed while in the Volume chart plain Volume is summed. Summation starts with the cursor-selected bar. This feature is only provided to visually reveal data differences; it has no other significance. <\/p>\n

      The charts below were created using the above methods, which quickly reveal the difference between the two types of data. To explain why these difference occur is left up to the expert reader (because I don\u2019t have a clue!!). <\/p>\n

      \"clip_image002[16]\"<\/a><\/p>\n

      Figure 1 – Backfilled data <\/p>\n

      \"clip_image004[16]\"<\/a><\/p>\n

      Figure 2 – Real-Time Collected data <\/p>\n

      The following volume indicator can be used to display the RT volume periodicity more clearly: <\/p>\n

      Filename <\/span>= <<\/span>b<\/span>><\/span>StrLeft<\/span><\/<\/span>b<\/span>>(<\/span>_DEFAULT_NAME<\/span>(),<<\/span>b<\/span>><\/span>StrLen<\/span><\/<\/span>b<\/span>>(<\/span>_DEFAULT_NAME<\/span>())-<<\/span>b<\/span>><\/span>2<\/span><\/<\/span>b<\/span>>); <<\/span>p<\/span>><\/span>Vref <\/span>= <<\/span>b<\/span>><\/span>Ref<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>HHV<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>V<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>4<\/span><\/<\/span>b<\/span>>),-<<\/span>b<\/span>><\/span>1<\/span><\/<\/span>b<\/span>>); <<\/span>p<\/span>><\/span>VSpike <\/span>= <<\/span>b<\/span>><\/span>V<\/span><\/<\/span>b<\/span>> &<\/span>gt<\/span>; <\/span>Vref <\/span><<\/span>b<\/span>>AND<\/<\/span>b<\/span>> <<\/span>b<\/span>><\/span>V<\/span><\/<\/span>b<\/span>>&<\/span>gt<\/span>;<<\/span>b<\/span>><\/span>Ref<\/span><\/<\/span>b<\/span>>(<\/span>VRef<\/span>,-<<\/span>b<\/span>><\/span>1<\/span><\/<\/span>b<\/span>>)\/<<\/span>b<\/span>><\/span>2<\/span><\/<\/span>b<\/span>>; <<\/span>p<\/span>><\/span>BS<\/span>=<<\/span>b<\/span>><\/span>ValueWhen<\/span><\/<\/span>b<\/span>>(<\/span>VSpike<\/span>,<<\/span>b<\/span>><\/span>BarsSince<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>Ref<\/span><\/<\/span>b<\/span>>(<\/span>VSpike<\/span>,-<<\/span>b<\/span>><\/span>1<\/span><\/<\/span>b<\/span>>))+<<\/span>b<\/span>><\/span>1<\/span><\/<\/span>b<\/span>>); <<\/span>p<\/span>><<\/span>b<\/span>><\/span>Plot<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>V<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>""<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>2<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>styleHistogram<\/span><\/<\/span>b<\/span>>); <<\/span>p<\/span>><<\/span>b<\/span>><\/span>Plot<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>IIf<\/span><\/<\/span>b<\/span>>(<\/span>Vspike <\/span>,<<\/span>b<\/span>><\/span>V<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>Null<\/span><\/<\/span>b<\/span>>),<<\/span>b<\/span>><\/span>""<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>1<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>styleArea<\/span><\/<\/span>b<\/span>>); <<\/span>p<\/span>><\/span>FirstVisibleBar <\/span>= <<\/span>b<\/span>><\/span>Status<\/span><\/<\/span>b<\/span>>( <<\/span>b<\/span>><\/span>"FirstVisibleBar"<\/span><\/<\/span>b<\/span>> ); <<\/span>p<\/span>><\/span>Lastvisiblebar <\/span>= <<\/span>b<\/span>><\/span>Status<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>"LastVisibleBar"<\/span><\/<\/span>b<\/span>>); <<\/span>p<\/span>><\/span>TN<\/span>=<<\/span>b<\/span>><\/span>DateTime<\/span><\/<\/span>b<\/span>>(); <<\/span>p<\/span>><\/span>S<\/span>=<<\/span>b<\/span>><\/span>Second<\/span><\/<\/span>b<\/span>>(); <<\/span>p<\/span>><<\/span>b<\/span>>for<\/<\/span>b<\/span>>( <\/span>b <\/span>= <\/span>Firstvisiblebar<\/span>; <\/span>b <\/span>&<\/span>lt<\/span>;= <\/span>Lastvisiblebar <\/span><<\/span>b<\/span>>AND<\/<\/span>b<\/span>> <\/span>b <\/span>&<\/span>lt<\/span>; <<\/span>b<\/span>><\/span>BarCount<\/span><\/<\/span>b<\/span>>; <\/span>b<\/span>++) <<\/span>p<\/span>>{ <<\/span>p<\/span>><<\/span>b<\/span>>if<\/<\/span>b<\/span>>(<\/span>VSpike<\/span>[<\/span>b<\/span>]) <<\/span>b<\/span>><\/span>PlotText<\/span><\/<\/span>b<\/span>>( <<\/span>p<\/span>><<\/span>b<\/span>><\/span>"\\n"<\/span><\/<\/span>b<\/span>>+<<\/span>b<\/span>><\/span>NumToStr<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>V<\/span><\/<\/span>b<\/span>>[<\/span>b<\/span>]\/<<\/span>b<\/span>><\/span>100<\/span><\/<\/span>b<\/span>>*<<\/span>b<\/span>><\/span>Interval<\/span><\/<\/span>b<\/span>>(),<<\/span>b<\/span>><\/span>1.0<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>False<\/span><\/<\/span>b<\/span>>)+ <<\/span>p<\/span>><<\/span>b<\/span>><\/span>"\\n"<\/span><\/<\/span>b<\/span>>+<<\/span>b<\/span>><\/span>NumToStr<\/span><\/<\/span>b<\/span>>(<\/span>BS<\/span>[<\/span>b<\/span>],<<\/span>b<\/span>><\/span>1.0<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>False<\/span><\/<\/span>b<\/span>>)+ <<\/span>p<\/span>><<\/span>b<\/span>><\/span>"\\n"<\/span><\/<\/span>b<\/span>>+<<\/span>b<\/span>><\/span>NumToStr<\/span><\/<\/span>b<\/span>>(<\/span>S<\/span>[<\/span>b<\/span>],<<\/span>b<\/span>><\/span>1.0<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>False<\/span><\/<\/span>b<\/span>>),<\/span>b<\/span>,<<\/span>b<\/span>><\/span>V<\/span><\/<\/span>b<\/span>>[<\/span>b<\/span>],<<\/span>b<\/span>><\/span>2<\/span><\/<\/span>b<\/span>>); <<\/span>p<\/span>>} <<\/span>p<\/span>><<\/span>b<\/span>><\/span>Title<\/span><\/<\/span>b<\/span>> = <<\/span>b<\/span>><\/span>"\\nInteractive Brokers "<\/span><\/<\/span>b<\/span>>+<\/span>Filename <\/span>+ <<\/span>b<\/span>><\/span>" - Display Raw data in 5-Second time frame\\n"<\/span><\/<\/span>b<\/span>>+ <<\/span>p<\/span>><<\/span>b<\/span>><\/span>"Histogram labeling:\\n"<\/span><\/<\/span>b<\/span>>+ <<\/span>p<\/span>><<\/span>b<\/span>><\/span>" Volume\/100\\n Barssince last Volume update\\n Second Timestamp"<\/span>;<\/<\/span>b<\/span>> <\/span><\/pre>\n

      This code produced the next two charts below. A simple spike filter (see the VSpike definition in the code) is used to identify Volume spikes and make them stand out with a Black background. Since these volume spikes do not appear in backfilled data, we can assume that they do not reflect true market activity. The three numbers at the top of the histogram bars, from the top down, show the Volume\/100, number of bars since the last volume spike, and the Second count derived from the data time stamp. <\/p>\n

      \"clip_image006[16]\"<\/a><\/p>\n

      Figure 3 \u2013 Real-time collected volume data <\/p>\n

      Applying the code on backfilled data produces the chart below. Note that many of the low volume periods between the spikes have been filled in (it appears that the volume spikes have been retroactively distributed) and that there is no longer any visible volume periodicity. <\/p>\n

      \"clip_image008[16]\"<\/a><\/p>\n

      Figure 4 – Backfilled volume data <\/p>\n

      Comparing Data from different Databases<\/h3>\n

      You can compare data from different databases in a single chart. Overlaying two data arrays will immediately reveal differences and will also suggest more sophisticated analysis to be performed. The code below can be executed by itself, or it can be appended to any other program. In this case it is coded for Volume comparison. However, you can easily modify it to compare price, indicators, or any other array. The SetBarsRequired() statement is necessary for data alignment. You must use the same timeframe for both RT and BF charts and for composite creation. All tests in this post were performed in the 5 second timeframe. <\/p>\n

      <\/span><<\/span>b<\/span>>function<\/<\/span>b<\/span>> <\/span>StaticVarArraySet<\/span>( <\/span>Varname<\/span>, array ) <<\/span>p<\/span>>{ <<\/span>p<\/span>><<\/span>b<\/span>><\/span>AddToComposite<\/span><\/<\/span>b<\/span>>( array, <<\/span>b<\/span>><\/span>"~SA_"<\/span><\/<\/span>b<\/span>>+<\/span>VarName<\/span>, <<\/span>b<\/span>><\/span>"C"<\/span><\/<\/span>b<\/span>>, <<\/span>b<\/span>><\/span>atcFlagDefaults<\/span><\/<\/span>b<\/span>> | <<\/span>b<\/span>><\/span>atcFlagEnableInBacktest<\/span><\/<\/span>b<\/span>> | <<\/span>b<\/span>><\/span>atcFlagEnableInExplore<\/span><\/<\/span>b<\/span>> | <<\/span>b<\/span>><\/span>atcFlagEnableInIndicator<\/span><\/<\/span>b<\/span>> | <<\/span>b<\/span>><\/span>atcFlagEnableInPortfolio<\/span><\/<\/span>b<\/span>> ); <<\/span>p<\/span>>} <<\/span>p<\/span>><<\/span>b<\/span>>function<\/<\/span>b<\/span>> <\/span>StaticVarArrayGet<\/span>( <\/span>VarName <\/span>) <<\/span>p<\/span>>{ <<\/span>p<\/span>><<\/span>b<\/span>>return<\/<\/span>b<\/span>> <<\/span>b<\/span>><\/span>Foreign<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>"~SA_"<\/span><\/<\/span>b<\/span>>+<\/span>VarName<\/span>,<<\/span>b<\/span>><\/span>"C"<\/span><\/<\/span>b<\/span>>); <<\/span>p<\/span>>} <<\/span>p<\/span>><<\/span>b<\/span>><\/span>SetBarsRequired<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>1000000<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>1000<\/span><\/<\/span>b<\/span>>); <<\/span>p<\/span>><<\/span>b<\/span>><\/span>GraphZOrder<\/span><\/<\/span>b<\/span>> = <<\/span>b<\/span>><\/span>1<\/span><\/<\/span>b<\/span>>; <<\/span>p<\/span>><\/span>StaticArrayName <\/span>= <<\/span>b<\/span>><\/span>ParamList<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>"Static Array Name"<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>"RawDataSample|BackfillDataSample"<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>0<\/span><\/<\/span>b<\/span>>); <<\/span>p<\/span>><<\/span>b<\/span>>if<\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>ParamTrigger<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>"Create Volume Composite"<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>"CREATE"<\/span><\/<\/span>b<\/span>>) ) <<\/span>p<\/span>>{ <<\/span>p<\/span>><\/span>StaticVarArraySet<\/span>( <\/span>StaticArrayName<\/span>, <<\/span>b<\/span>><\/span>V<\/span><\/<\/span>b<\/span>>); <<\/span>p<\/span>>} <<\/span>p<\/span>><<\/span>b<\/span>>if<\/<\/span>b<\/span>>( <<\/span>b<\/span>><\/span>ParamToggle<\/span><\/<\/span>b<\/span>>(<<\/span>b<\/span>><\/span>"Overlay Composite"<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>"NO|YES"<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>0<\/span><\/<\/span>b<\/span>>) ) <<\/span>p<\/span>>{ <<\/span>p<\/span>><<\/span>b<\/span>><\/span>Plot<\/span><\/<\/span>b<\/span>>(<\/span>StaticVarArrayGet<\/span>( <\/span>StaticArrayName<\/span>),<<\/span>b<\/span>><\/span>""<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>colorYellow<\/span><\/<\/span>b<\/span>>,<<\/span>b<\/span>><\/span>styleStaircase<\/span><\/<\/span>b<\/span>>); <<\/span>p<\/span>>} <\/span><\/pre>\n

      To compare BF with RT volume arrays, you first create the composite for the BF volume and copy this to your RT database for comparison. The procedure is as follows: <\/p>\n

        \n
      1. Load up the database containing your BF data sample.\n
      2. Display the data and open the Param window:<\/li>\n<\/ol>\n

        \"clip_image010[16]\"<\/a><\/p>\n

          \n
        1. Select BackFillDataSample<\/i> for static variable name.\n
        2. Click CREATE.<\/i>\n
        3. In the Amibroker menu bar, click View -> Refresh All.<\/i>\n
        4. In the Indicator window, set Overlay Composite to YES. <\/i>The composite data should display as a Yellow staircase superimposed on your volume chart.\n
        5. Close AmiBroker.\n
        6. Use Windows Explore to find your BF database and copy the composite for BF volume from the \u201c_\u201d folder and paste it into the \u201c_\u201d folder of the RT database.\n
        7. Delete the Broker.Master<\/i> file from the RT database. This file will be recreated at next startup. This step is needed to include the new composite file in the database index.\n
        8. Start up AmiBroker and load up the RT database.\n
        9. Display the RT volume chart you were working with. If the Parameters are set as shown in the capture above you should now see the Yellow staircase for BF Volumes superimposed on the RT volume histogram. <\/li>\n<\/ol>\n

          At this point you can scroll back and forth in time to see how BF volume differs from RT collected volume. Do not click CREATE, or you will overwrite the BF composite.<\/b> The charts below show what your charts should look like. <\/p>\n

          \"clip_image012[16]\"<\/a><\/p>\n

          Figure 5 – BF composite (Yellow) on BF Volume Histogram <\/p>\n

          Figure 5 above shows a period where the composite covered backfilled volume (for example the backfill period before RT collection). Because the composite copied this BF data, they match perfectly. <\/p>\n

          \"clip_image014[16]\"<\/a><\/p>\n

          Figure 6 – BF Composite (Yellow) on RT collected Volume Histogram <\/p>\n

          Figure 6 above is for a period where the composite (backfilled volume) is superimposed on the real-time collected volume (histogram). Note the difference between the two types of data. <\/p>\n

          Developing a trading system should start with learning about the basics; delays and bad data quality can kill any HFAT trading system no matter how much time you spent developing it. The best way to understand and know what you are working with is to write a few small programs, like those that were included in this series. <\/p>\n

          Conclusion <\/h3>\n

          In the previous discussions, it became clear that developing an HFAT trading system might not be as easy as you think. Googling for information will reveal very few links to practical information; you\u2019ll be mostly on your own to discover the pitfalls. Developing with live data from your paper-trading account may be better than using backfilled data. However, since it is highly likely that IB executes paper trades subject to the reported price and volume you see, paper-trading results may not match actual trading results. Unless you are acutely aware of the various problems and can develop your system to work around them, it would appear futile to try and develop an HFAT trading system with 5-second IB data. The unique real-time volume patterns also occurred in data collected from the real-trading account. <\/p>\n

          Data from all sources will have their own unique problems, and it is prudent to perform some basic testing to get to know your RT data before spending considerable time on development. <\/p>\n

          Note<\/h3>\n

          IB Snapshots and data compression methods are relevant to the above discussion; even though there isn\u2019t much detail available, you may want to read the following threads to learn more about these topics. <\/p>\n

          AmiBroker user group: Interactive Brokers Plug-in dropping volume data<\/a>
          IB\u2019s Discussion Board: Globex Ticks snapshot or reality?<\/a>
          \n
          AmiBroker User Group: AB Tick Bar Analysis<\/a><\/p>\n

          Edited by Al Venosa.<\/p>\n","protected":false},"excerpt":{"rendered":"

          Interactive Brokers\u2019 Real-Time Volume Data Just like with price data, volume data are subject to delays and BF (Backfill) corrections. Moreover, IB (Interactive Brokers) reports volume data in a manner that could cause major performance differences between backtesting and actual trading. This post outlines simple procedures to collect RT and BF data for comparison. No […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[65],"tags":[],"_links":{"self":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts\/1493"}],"collection":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/comments?post=1493"}],"version-history":[{"count":0,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts\/1493\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/media?parent=1493"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/categories?post=1493"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/tags?post=1493"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}