-
Notifications
You must be signed in to change notification settings - Fork 17
/
samplebot.py
executable file
·51 lines (37 loc) · 1.35 KB
/
samplebot.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
import numpy as np
class Bot:
def _init_(self, game, nu):
self.Game = game
self.numSecurities = nu
self.iter = 0
def GetBalance(self):
return self.Game.GetBalance()
def GetPrice(self, security):
return self.Game.GetPrice(security)
def BuySecurity(self,security,quantity,price):
return self.Game.BuySecurity(security,quantity,price)
def SellSecurity(self,security,quantity,price):
return self.Game.SellSecurity(security,quantity,price)
def GetInterest(self):
return self.Game.GetInterest()
def GetBeta(self):
return self.Game.GetBeta()
def GetShareBalance(self,security):
return self.Game.GetShareBalance(security)
def GetFeatures(self, security):
return self.Game.GetFeatures(security)
def GetMostCorrelated(self, security):
return self.Game.GetMostCorrelated(security)
def GetLeastCorrelated(self, security):
return self.Game.GetLeastCorrelated(security)
try:
def Run(self):
for i in range(self.numSecurities):
p=self.GetPrice(i)
if self.iter%2==0:
self.BuySecurity(i,100,p+10)
else:
self.SellSecurity(i,100,p-10)
self.iter+=1
except:
print("exception")