Beispiel #1
0
    def scan_commands(self):
        self._commands = []

        if self.mod == None:
            return

        dic = self.mod.__dict__

        if '__root__' in dic:
            root = dic['__root__']
        else:
            root = []

        for k in dic:
            if k.startswith('_') or k in root:
                continue

            item = dic[k]

            if type(item) == types.FunctionType:
                bisect.insort(self._commands, method.Method(item, k, self))
            elif type(item) == types.ModuleType and utils.is_commander_module(
                    item):
                mod = Module(k, item, self)
                bisect.insort(self._commands, mod)

                # Insert root functions into this module
                for r in mod.roots():
                    bisect.insert(self._commands, r)
Beispiel #2
0
def betUnderdog(data, fair=True, margin="basic", odds=None, bet_choices=3, asian=False,results = None):
    generating = method.Method(data, bet_choices=bet_choices)
    if results is not None:
        generating.results = results
    if odds is None:
        odds = find_correct_odds(fair, margin, generating)
    underdog = np.argmax(odds, axis=1)
    return generating.evaluate(bets=underdog, odds=odds, asian=asian)
Beispiel #3
0
 def add_default_init(self):
     init = method.Method(clazz=self,
                          mods=[C.mod.PB],
                          typ=self._name,
                          name=self._name)
     if self._sup and self._sup != C.J.OBJ:
         init.body = st.to_statements(init, u"super();")
     self._mtds.append(init)
     return init
Beispiel #4
0
 def bet(self, odds):
     generation = method.Method(self.data, bet_choices=3)
     np_results = pandas.DataFrame.to_numpy(self.data['results'])
     count = 0
     for i in range(self.iterations):
         count += 1
         my_bet = np.random.choice(generation.bet_choices)
         bet_amount = self.fraction * self.bankroll
         self.bankroll = (1 - self.fraction) * self.bankroll
         if my_bet == np_results[i]:
             self.bankroll = self.bankroll + bet_amount * odds[i, my_bet]
         if self.bankroll < self.threshold:
             self.bankroll = 0
             break
     return count
Beispiel #5
0
def devide_bet(data=None, margin="basic", prob=None, bet_choices=3,results = None,odds = None):
    results = pandas.Series.to_numpy(results, dtype=np.int)
    generating = method.Method(data, bet_choices=bet_choices)
    if odds is None:
        odds = generating.find_fair_odds(margin)
    if prob is None:
        prob = 1 / bet_choices * np.ones(
            odds.shape)  # prob = 1 / 3 * np.ones(odds.shape)  # prob = generating.get_probabilities()  # prob = 1/odds
    if results is None:
        n_bet = data['results'].count()
    else:
        n_bet = np.size(results)
    eval = np.zeros(prob.shape)
    for i in range(n_bet):
        eval[i, results[i]] = odds[i, results[i]] * prob[i, results[i]]
    return eval
	def roots(self):
		if self._roots == None:
			if not self.mod:
				return []

			dic = self.mod.__dict__

			if '__root__' in dic:
				root = dic['__root__']
			else:
				root = []

			root = filter(lambda x: x in dic and type(dic[x]) == types.FunctionType, root)
			self._roots = map(lambda x: method.Method(dic[x], x, self.mod), root)

		return self._roots
Beispiel #7
0
    def add_fld_init(self):
        if not self.mutable_flds: return None
        i_flds = list(enumerate(self.mutable_flds))
        params = map(lambda (i, fld): (fld.typ, u"p{}".format(i)), i_flds)
        init = method.Method(clazz=self,
                             mods=[C.mod.PB],
                             typ=self._name,
                             name=self._name,
                             params=params)

        def init_fld((i, fld)):
            return fld.name + u" = p{};".format(i)

        body = '\n'.join(map(init_fld, i_flds))
        init.body = st.to_statements(init, body)
        self._mtds.append(init)
        return init
Beispiel #8
0
from pydantic import BaseModel
import configparser
import json

import database_handler
import method

app = FastAPI()

config = configparser.ConfigParser()
config.read('db.conf')
info = config['DEFAULT']

dbh = database_handler.DatabaseHandler(db_name=info['db_name'],
                                       check_same_thread=False)
m = method.Method(conf_file='db.conf')


class Schedule(BaseModel):
    sid: str  # ID
    name: str  # 名称
    content: str  # 内容
    category: str  # 分类
    level: int  # 重要程度, 0: 未定义  1: 低  2: 中  3: 高
    status: float  # 当前进度, 0 <= status <= 1
    creation_time: str  # 创建时间
    start_time: str  # 开始时间
    end_time: str  # 结束时间


@app.get('/')
Beispiel #9
0
 def get_or_declare_clinit(self):
     if hasattr(self, C.J.CLINIT): return getattr(self, C.J.CLINIT)
     clinit = method.Method(clazz=self, mods=[C.mod.ST], name=C.J.CLINIT)
     self._mtds.append(clinit)
     setattr(self, C.J.CLINIT, clinit)
     return clinit