Quantlab 试题


This problem will require you to write an application that will take in
an input file ‘input.csv’ and write out a new file calculated from the inputs.

Technology Choice (In order of preference)
#1 – An object oriented language
#2 – A functional language

We are looking for an object oriented or functional solution.A procedural scripting
solution isn’t acceptable.


The input file represents a very simplified stream of trades on an exchange.
Each row represents a trade.If you don’t know what that means don’t worry.
The data can be thought of as a time series of values in columns:


Although the provided input file is small, the solution should be able to handle
a source dataset well beyond the amount memory and hard disk space on your machine.
Thus any solution that reads the entire file contents into memory at once is unacceptable.

– TimeStamp is value indicating the microseconds since midnight.
– Symbol is the 3 character unique identifier for a financial
instrument (Stock, future etc.)
– Quantity is the amount traded
– Price is the price of the trade for that financial instrument.

Safe Assumptions:
– TimeStamp is always for the same day and won’t roll over midnight.
– TimeStamp is increasing or same as previous tick (time gap will never be < 0). - Price - our currency is an integer based currency.No decimal points. - Price - Price is always > 0.

Example: here is a row for a trade of 10 shares of aaa stock at a price of 12

Find the following on a per symbol basis:
– Maximum time gap
(time gap = Amount of time that passes between consecutive trades of a symbol)
if only 1 trade is in the file then the gap is 0.
– Total Volume traded (Sum of the quantity for all trades in a symbol).
– Max Trade Price.
– Weighted Average Price.Average price per unit traded not per trade.
Result should be truncated to whole numbers.

Example: the following trades
20 shares of aaa @ 18
5 shares of aaa @ 7
Weighted Average Price = ((20 * 18) + (5 * 7)) / (20 + 5) = 15

Your solution should produce a file called ‘output.csv’.
file should be a comma separate file with this format:

The output should be sorted by symbol ascending (‘aaa’ should be first).

Sample Input:

Sample Output:
. more info on 1point3acres.comaaa,5786864,40,1161,1222

Send your source code and output.csv back for evaluation when complete.
Include the amount of time you spent working on the solution and
simple instructions for building and/or running your solution.

补充内容 (2016-1-5 04:40):
input.csv 是个20000多行的csv文件,格式与sample input一样