/
powerplant2.py
52 lines (38 loc) · 946 Bytes
/
powerplant2.py
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
from quantdsl.semantics import Choice, Market, TimeDelta, Wait, inline
def PowerPlant(start, end, duration_off):
if (start < end):
Wait(start,
Choice(
ProfitFromRunning(duration_off) + PowerPlant(
Tomorrow(start), end, Running()
),
PowerPlant(
Tomorrow(start), end, Stopped(duration_off)
)
)
)
else:
return 0
@inline
def ProfitFromRunning(duration_off):
if duration_off > 1:
return 0.75 * Power() - Gas()
elif duration_off == 1:
return 0.90 * Power() - Gas()
else:
return 1.00 * Power() - Gas()
@inline
def Power():
Market('POWER')
@inline
def Gas():
Market('GAS')
@inline
def Running():
return 0
@inline
def Stopped(duration_off):
return duration_off + 1
@inline
def Tomorrow(today):
return today + TimeDelta('1d')