I have data for different traders (i.e) their ID's and whether the trade is buyer initiated or seller initiated.
I need to find the total number of trade packages which comprise of the set of trades which have been executed buy the same trader continuously in the same direction (i.e either selling or buying) without a gap of a single trading day. If any of these conditions is not satisfied, the package is completed till the previous record. could someone please assist me with the code?
the definition of a trade package is as follows:
Sequences of individual trades for each contract are classified as
packages if they are executed (i) from the same account, (ii) in the same
direction (e.g., buy trades), and (iii) successively without 1-day trading
break. an institution’s order execution is complete when it (i) begins
trading in the opposite direction, or (ii) stays out of the market in that
contract for more than one trading day.
I need do to calculate the number of such trade packages and the mean, median and std deviation of the volume of trades. Please help me asap. its very urgent.