-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsix.html
108 lines (104 loc) · 3.39 KB
/
six.html
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<html>
<head>
<title></title>
<script src="js/vendor/jquery-1.11.3.min.js"></script>
</head>
<body>
<div class="show"></div>
<script type="text/javascript">
var models;
var groups = ['group1-1', 'group1-2', 'group1-3', 'group1-4', 'group1-5', 'group1-6', 'group2-1', 'group2-2', 'group2-3', 'group2-4', 'group2-5', 'group2-6'];
var columnData = {
'group1-1': {},
'group1-2': {},
'group1-3': {},
'group1-4': {},
'group1-5': {},
'group1-6': {},
'group2-1': {},
'group2-2': {},
'group2-3': {},
'group2-4': {},
'group2-5': {},
'group2-6': {}
};
var month = '';
var cash;
var initcash = 10000;
var base;
$.ajax({
type: "get",
url: "http://120.79.255.191",
success: function(data) {
models = data.models;
console.log(models);
var six = [
["group1-1"], // 0.01
["group1-2"], // 0.13
//["group1-3"], // 0.01
["group1-1", "group1-3"], // 0.02
["group1-2", "group1-3", "group1-6"], // 0.01
];
var special = [
[Date.parse('2020-08-01'), 13749, 1, 10000],
[Date.parse('2020-08-01'), 122726, 12, 10000], // -1000
//[Date.parse('2020-08-01'), 17913, 1, 10000],
[Date.parse('2020-08-01'), 21662, 2, 10000],
[Date.parse('2020-09-01'), 20000, 1, 20000], // -200
/*[Date.parse('2020-04-01'), 10000, 1],
[Date.parse('2020-04-01'), 10000, 1],
[Date.parse('2020-04-01'), 10000, 1],
[Date.parse('2020-04-01'), 10000, 1],*/
];
var start = Date.parse('2020-04-01');
var specialDate = Date.parse('2020-04-01');
var specialCash = 10000;
var specialBase = 1;
for (var i = 0; i < six.length; i++) {
parseCsv(six[i], special[i][0], special[i][1], special[i][2], special[i][3]);
console.log(six[i], cash, base);
}
}
});
var parseCsv = function(targetGroup, startDate, startCash, startBase, unitCash) {
var tempMonth = '';
var quit = false;
month = '';
cash = startCash;
base = startBase;
$.each(models, function(k ,v){
if (quit) {
return false;
}
tempMonth = k.substring(0, 7);
if (Date.parse(k) < startDate) {
return true;
}
if (month == '') {
month = tempMonth;
} else if (month != tempMonth) {
month = tempMonth;
if (base < Math.floor(cash / unitCash)) {
base = Math.floor(cash / unitCash);
}
}
$.each(targetGroup, function(subk, subv) {
if (!v.hasOwnProperty(subv)) {
v[subv] = 0;
}
cash = (parseFloat(cash) + parseFloat(v[subv] * base)).toFixed(2);
if (cash < 0) {
console.log('boom');
quit = true;
return false;
}
});
//console.log(k, cash);
});
return !quit;
//console.log(cash);
};
</script>
</body>
</html>