Good day. I am trying to store the prices and volumes for 10 levels of each the ask and bid side of the order book. This would provide 40 values at each time step. Say time step is 1 hour. Then I would like to (i) calculate various features such as %_return_ask from one time step to the next (t, t-1) and then (ii) average the %_return_ask over say the last 4 hours. Hence, I need to be able to pull such info from some sort of array. Any thoughts?,Good day. I am trying to store the prices and volumes for 10 levels of each the ask and bid side of the order book. This would provide 40 values at each time step. Say time step is 1 hour. Then I would like to (i) calculate various features such as %_return_ask from one time step to the next (t, t-1) and then (ii) average the %_return_ask over say the last 4 hours. Hence, I need to be able to pull such info from some sort of array. Any thoughts?

Comment

**Answer** by russelltromans-1
·
Oct 15, 2020 at 05:03 PM

The only way to store an array is to use a value bucket, more info on the value bucket can be found here: https://library.tradingtechnologies.com/adl/db-val...

It will depend on how exactly you wish to use the data which will dictate which configuration your logic will take. Below is a simplified example of how to collect data over multiple time periods and then access the data for use in your calculations.

The discrete message then passes into the Value Accumulator labelled 'Interval count', this is seeded with a value of '1' so that it counts the number of discrete messages that have passed through it. Each Value Bucket will reference this accumulator as it's storeKey and use a mode of 'Last'. As the value bucket is only able to have a single storeVal we use a separate Value Bucket for each piece of data we wish to collect.

Once the data collection is complete the discrete message will then pass into the Branch Block labelled 'Sufficient Data' which will check if the interval count is greater than or equal to the number of intervals required to perform our calculation. If our condition is met the discrete message will pass to the loop block where we will use the index output value to amend the lookup value of the Value Buckets allowing access to the array of data stored within them for the last x values.

For more information on working with data in this manner you may wish to refer to the following post: https://community.tradingtechnologies.com/question...

data-collection.png
(206.4 kB)

**Answer** by sphaasz
·
Oct 19, 2020 at 12:25 AM

Good day. Thanks so much for the response. Really helped. Very detailed and informative. Much appreciated. S.

Ask questions and share ideas about the TT^{®} and X_TRADER^{®} platforms.

First time here? See our Getting Started Guide and FAQs.

Follow
### Follow this Question

Quantity 0 in order block 1 Answer

Need some help with algos (loop & formulas) 1 Answer

Attaching an OMA to an OTA child order 2 Answers

Order Block fire more than once 3 Answers

Necessity of cover orders 1 Answer

© 2017 Trading Technologies International, Inc. All rights reserved.

Powered by AnswerHub