-
Notifications
You must be signed in to change notification settings - Fork 2
/
temp
executable file
·42 lines (36 loc) · 1.67 KB
/
temp
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
40
41
42
//loads market events and price changes from dropbox CSVs
//basic CSV parsing with string.split
function loadCSVs () {
//Load market events
$http.get($scope.config.marketEventsURL).then(function(response) {
var rows = response.data.split("\n");
//Parse first market events CSV
for (var i = 0; i < rows.length-1; i++) {
$scope.marketEvents[i] = [];
}
for (var i = 0; i < rows.length-1; i++) {
if (rows[i] === "") continue;
var cells = rows[i].split(",");
for (var j = 0; j < cells.length; j++) {
$scope.marketEvents[i][j] = isNaN (cells[j]) ? cells[j] : parseFloat (cells[j]);
}
}
//once market events has been loaded and parsed, load price changes
$http.get($scope.config.priceChangesURL).then(function(response) {
var rows = response.data.split("\n");
//Parse price changes CSV
for (var i = 0; i < rows.length-1; i++) {
$scope.priceChanges[i] = [];
}
for (var i = 0; i < rows.length-1; i++) {
if (rows[i] === "") continue;
var cells = rows[i].split(",");
for (var j = 0; j < cells.length; j++) {
$scope.priceChanges[i][j] = parseFloat(cells[j]);
}
}
//once price changes have finished loading, initialize the experiment
rs.synchronizationBarrier("init_round_" + rs.period).then(initExperiment());
});
});
}