-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.cpp
More file actions
39 lines (35 loc) · 1.07 KB
/
Copy pathstats.cpp
File metadata and controls
39 lines (35 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <vector>
#include "order_book_entry.h"
using namespace std;
// some functions for summary
double computeAveragePrice(vector<order_book_entry> &entires);
double computeLowPrice(vector<order_book_entry> &entries);
double computeHighPrice(vector<order_book_entry> &entries);
// computing average price.
double computeAveragePrice(vector<order_book_entry> &entries) {
double total = 0;
double average = 0;
for (const order_book_entry &e: entries) {
total = total + e.price;
}
average = total / entries.size();
return average;
}
// computing lowest price.
double computeLowPrice(vector<order_book_entry> &entries) {
double lowest = entries[0].price;
for (const order_book_entry &e: entries) {
if (e.price < lowest)
lowest = e.price;
}
return lowest;
}
// computing highest price.
double computeHighPrice(vector<order_book_entry> &entries) {
double highest = entries[0].price;
for (const order_book_entry &e: entries) {
if (e.price > highest)
highest = e.price;
}
return highest;
}