Oops! Something went wrong while submitting the form

Register

2

Project-Budget

$10-$30

Active

Project Description:

You are given a series of trades. Each trade has a key, a value, a quantity, and a sequence number. For each trade, print the weighted moving average of all the trades for that particular key. Round your average to two decimal places. If the sequence number for any trade TT is less than the sequence number for any previous trade, throw out TT. Do not print anything for TT or factor it into your WMA.

M_{x+1} = {(M_x * Q_x)+(v_{x+1} * q_{x+1}) \over Q_{x+1}}Mx+1=Qx+1(MxQx)+(vx+1qx+1)

Where M = weighted moving average, Q = total quantity, q = current quantity, and v = current value.