def __init__(self, user="******", password="******", zuhe="ZH1008383"): self.user = easytrader.use('xq') self.user.prepare(user=user, password=password, portfolio_code=zuhe) self.buylist = [] self.selllist = [] self.limitnum = 20 self.m = MongoDB()
def __init__(self, startdate=(2011, 1, 1), enddate=[]): self.startdate = datetime.datetime(*startdate, 0, 0, 0, 0) self.enddate = enddate self.m = MongoDB(DB_SERVER, DB_PORT, USER, PWD, AUTHDBNAME) self.formatlist = [ "date", "volume", "close", "high", "low", "open", "pre_close" ] self.savevols = [ "stock", "buy_date", "sell_date", "holddays", "profit", "features" ] self.looplist = [] self.trading_records = [] self.holding_records = [] self.datalst = [] self.collection = None self.tempstatus = [] self.lateststatus = []
def connetdb(self): self.m = MongoDB(DB_SERVER, DB_PORT, USER, PWD, AUTHDBNAME) return self.m
def __init__(self, stock="600455.SH"): self.m = MongoDB(DB_SERVER, DB_PORT, USER, PWD, AUTHDBNAME)
def __init__(self): self.db = MongoDB(DB_SERVER, DB_PORT, USER, PWD, AUTHDBNAME) self.looplist = []
def __init__(self): self.m = MongoDB(DB_SERVER, DB_PORT, USER, PWD, AUTHDBNAME) self.formatlist = [ "date", "volume", "close", "high", "low", "open", "pre_close" ] return
def __init__(self, stock="600455.SH"): self.m = MongoDB()
c_preclose = line[6] if c_preclose != close: reh = [[i[0], i[1] * c_preclose / close] for i in reh] reh.append([c, c_preclose / close]) close = line[2] c += 1 result = [] sc = 0 ec = 0 for idx in range(len(reh)): weight = reh[idx][1] ec = reh[idx][0] piece = self.recount(lst, sc, ec, weight) result.extend(piece) sc = ec result.extend(lst[sc:]) return result def recount(self, lst, sc, ec, weight): rst = [] for line in lst[sc:ec]: rst.append([line[0], line[1], *[i * weight for i in line[2:]]]) return rst if __name__ == '__main__': db = MongoDB(DB_SERVER, DB_PORT, USER, PWD, AUTHDBNAME) s = StockIndicator(mdb=db) s.setlooplist() s.updateallstocks2db()
def import_data(self,stock, start, end ): query = MongoDB() df = query.format2dataframe(query.read_data("ml_fund_table",stock)) df['change'] = (df['close'] - df['close'].shift(1))/df['close'].shift(1) df['code'] = stock return df