def daily_Repo_amt_prc_for_collateral(dir_name): """ 机构类型-债券类型 —— """ date = re.match(".*\\d{8}\\.",dir_name).group()[-9:-1] excel_io= input_path+"/质押式回购市场交易情况总结/日报/" + dir_name tmp = pd.read_excel(excel_io) # print(tmp.shape,date) if tmp.shape[0] == 206: h = 132; nr = 33 elif tmp.shape[0] == 178: h = 110; nr = 27 df=pd.read_excel(excel_io,header=h,nrows =nr).iloc[:,:6] df["date"]=date df["机构类型"].fillna(method="ffill",inplace=True) df.rename(columns={'债券类型':'抵押品类型'},inplace=True) df=df.replace("-",0) name = "Repo_amt_prc_for_collateral" columns_type=[#图表的数据口径 String(30), String(30), Float(4), Float(2), Float(4), Float(2), DateTime()] dtypelist = dict(zip(df.columns,columns_type))#变成字典形式 return df,name,dtypelist
def init_db(): metadata = MetaData() persons = Table( 'person', metadata, Column('id', Integer, Sequence('person_id_seq'), primary_key=True), Column('name', String(64)), Column('nickName', String(64)), Column('location', String(128))) goods = Table( 'goods', metadata, Column('id', Integer, Sequence('good_id_seq'), primary_key=True), Column('category', ARRAY(String())), Column('detail', String()), Column('name', String(128)), Column('price', Float()), Column('description', String()), Column('brand', String(64))) reviews = Table( 'reviews', metadata, Column('id', Integer, Sequence('review_id_seq'), primary_key=True), Column('review', String()), Column('stars', Float()), Column('title', String()), Column('date_review', DateTime()), Column('helpful', Float()), Column('person_id', ForeignKey('person.id')), Column('product_id', ForeignKey('goods.id'))) mapper(Persons, persons) mapper(Goods, goods) mapper(Reviews, reviews) metadata.create_all(bind=engine)
def futureGame2mysql(game): game = pd.DataFrame(game).T game['awayTeam'] = "nan" game['homeTeam'] = "nan" game['away_win_rate'] = 0.0 game['home_win_rate'] = 0.0 gameTeam = game.iloc[0]['gameTeam'] gameTeam = gameTeam.split("vs") game['awayTeam'] = gameTeam[0] game['homeTeam'] = gameTeam[1] game.drop(columns=['gameOver','gameTeam'], axis=1, inplace=True) game['gameId'] = game['gameId'].astype(int) dtype_dict = { game.columns[0]: Integer(), game.columns[1]: NVARCHAR(length=32), game.columns[2]: NVARCHAR(length=3), game.columns[3]: NVARCHAR(length=3), game.columns[4]: Float(precision=6, asdecimal=True), game.columns[5]: Float(precision=6, asdecimal=True), } try: game.to_sql(name='future_game', con=con, if_exists='append', index=False, dtype=dtype_dict) except: print('[futureGame2mysql] game ' + str(game['gameId']) + ' has existed, skip.')
class Donation(Base, CRUDMixin): __tablename__ = 'donations' id = Column('id', Integer, primary_key=True) name = Column('name', String()) url = Column('url', String()) twitter = Column('twitter', String()) comment = Column('comment', String()) amount = Column('amount', Float(precision=2)) amount_one = Column('amount_one', Float(precision=2)) amount_two = Column('amount_two', Float(precision=2)) amount_three = Column('amount_three', Float(precision=2)) time = Column('time', DateTime()) time_approved = Column('time_approved', DateTime()) approved = Column('approved', Boolean, default=False) ipn_hash = Column('ipn_hash', String()) user_id = Column('user_id', Integer, ForeignKey('users.id')) user = relationship('User') prize_id = Column('prize_id', Integer, ForeignKey('prizes.id')) prize = relationship('Prize') challenge_id = Column('challenge_id', Integer, ForeignKey('challenges.id')) challenge = relationship('Challenge') game_id = Column('game_id', Integer, ForeignKey('games.id')) game = relationship('Game') def __unicode__(self): return self.name
class User(Base): __tablename__ = 'users' id = Column(Integer, primary_key=True) rolename = Column(String(), ForeignKey("userroles.rolename"), nullable=False) role = relationship("UserRole", innerjoin=False) templates = relationship("Template", backref='users', primaryjoin="User.id==Template.user_id", order_by="Template.create_date", lazy='joined') username = Column(String(50), nullable=False, unique=True) password = Column(String(), nullable=False, default='') twitter_id = Column(String(), nullable=False) facebook_id = Column(String(), nullable=False) quote = Column(Float(), nullable=False, default=10.0) datasize = Column(Float(), nullable=False, default=0.0) email = Column(String(120), nullable=False)#, unique=True) create_date = Column(String(10), nullable=False) def __init__(self, username, role, password='', twitter_id='', facebook_id='', email=''): super(User, self).__init__() self.username = username self.role = role self.set_password(password) self.twitter_id = twitter_id self.facebook_id = facebook_id self.email = email self.create_date = datetime.datetime.now() def set_password(self, password): self.password = get_password_hash(SECRET_KEY, self.username, password)
def cash_amt_prc(): # 资金现券与成交量 name = 'cash_amt_prc' last_date = do.get_latest_date(name) today_date = dt.datetime.now() print('表{}的最近更新日期为{}'.format(name, last_date)) err, df = w.edb( "M0041652,M0041653,M0041655,M1004511,M1004515,M0220162,M0220163,M0330244,M0041739,M0041740", last_date, today_date, usedf=True) if df.shape[1] == 1: return [], name, [] df.columns = ['R001','R007','R021','GC001','GC007','DR001','DR007',\ '成交量:R001','成交量:银行间质押式回购','成交量:银行间债券现券'] df['date'] = df.index df = df.loc[(df.date > last_date) & (df.date < today_date.date())] columns_type = [ Float(), Float(), Float(), Float(), Float(), Float(), Float(), Float(), Float(), Float(), DateTime() ] dtypelist = dict(zip(df.columns, columns_type)) return df, name, dtypelist
class Grb(Base): __tablename__ = 'grb' tar_id = Column(Integer, ForeignKey('targets.tar_id'), nullable=False) grb_id = Column(Integer, primary_key=True, nullable=False) grb_seqn = Column(Integer, primary_key=True, nullable=False) grb_type = Column(Integer, primary_key=True, nullable=False) grb_ra = Column(Float(Precision=64)) grb_dec = Column(Float(Precision=64)) grb_is_grb = Column(Boolean, nullable=False) grb_date = Column(DateTime, nullable=False) grb_last_update = Column(DateTime, nullable=False) grb_errorbox = Column(Float(Precision=64)) grb_autodisabled = Column(Boolean, nullable=False) def __init__(self, tar_id=None, grb_ra=None, grb_dec=None, grb_is_grb=None, grb_date=None, grb_last_update=None, grb_errorbox=None, grb_autodisabled=None): self.tar_id = tar_id self.grb_ra = grb_ra self.grb_dec = grb_dec self.grb_is_grb = grb_is_grb self.grb_date = grb_date self.grb_last_update = grb_last_update self.grb_errorbox = grb_errorbox self.grb_autodisabled = grb_autodisabled def __repr__(self): return '<Grb({0},{1},{2},{3})>'.format(self.tar_id, self.grb_id, self.grb_seqn, self.grb_type)
class Relay(Base): "Relay settings" __tablename__ = 'relaysettings' __table_args__ = (UniqueConstraint('username', 'address'), {}) id = Column(Integer, primary_key=True) address = Column(Unicode(255), index=True) username = Column(Unicode(255)) __password = Column('password', Unicode(255)) enabled = Column(Boolean, default=True) description = Column(Unicode(255)) low_score = Column(Float(), default=0.0) high_score = Column(Float(), default=0.0) spam_actions = Column(SmallInteger, default=2) highspam_actions = Column(SmallInteger, default=2) ratelimit = Column(SmallInteger, default=250, server_default='250') org_id = Column(Integer, ForeignKey('organizations.id')) org = relationship('Group', backref=backref('relaysettings', order_by=id)) __mapper_args__ = {'order_by': id} def set_password(self, password): "sets the password to a hash" self.__password = bcrypt.hashpw(password, bcrypt.gensalt()) def apijson(self): """Return JSON for the API""" mdict = {} for attr in [ 'id', 'address', 'username', 'enabled', 'description', 'low_score', 'high_score', 'spam_actions', 'highspam_actions' ]: mdict[attr] = getattr(self, attr) return mdict
def fig_midstream(): # 中游 err,df = w.edb("S5705039,S0247603,S0181750,S5914515,S5907373,S5416650,M0067419,M0066359,\ M0066348,M0066350" , \ start, end, usedf = True) df.columns = [ 'Mylpic综合钢价指数', '库存:主要钢材品种:合计', '库存:螺纹钢(含上海全部仓库)', '水泥价格指数:全国', '中国玻璃价格指数', '中国盛泽化纤价格指数', '期货收盘价(活跃合约):PVC', '期货收盘价(活跃合约):天然橡胶', '期货收盘价(活跃合约):黄大豆1号', '期货收盘价(活跃合约):黄玉米' ] df['date'] = df.index name = 'fig_midstream' columns_type = [ Float(), Float(), Float(), Float(), Float(), Float(), Float(), Float(), Float(), Float(), DateTime() ] dtypelist = dict(zip(df.columns, columns_type)) return df, name, dtypelist
def fig_midstream(): name = 'fig_midstream' last_date = do.get_latest_date(name) today_date = dt.datetime.now() print('表{}的最近更新日期为{}'.format(name, last_date)) err,df = w.edb("S5705039,S0247603,S0181750,S5914515,S5907373,S5416650,M0067419,M0066359,\ M0066348,M0066350" , \ last_date, today_date, usedf = True) if df.shape[1] == 1: return [], name, [] df.columns = [ 'Mylpic综合钢价指数', '库存:主要钢材品种:合计', '库存:螺纹钢(含上海全部仓库)', '水泥价格指数:全国', '中国玻璃价格指数', '中国盛泽化纤价格指数', '期货收盘价(活跃合约):PVC', '期货收盘价(活跃合约):天然橡胶', '期货收盘价(活跃合约):黄大豆1号', '期货收盘价(活跃合约):黄玉米' ] df['date'] = df.index df = df.loc[(df.date > last_date) & (df.date < today_date.date())] columns_type = [ Float(), Float(), Float(), Float(), Float(), Float(), Float(), Float(), Float(), Float(), DateTime() ] dtypelist = dict(zip(df.columns, columns_type)) return df, name, dtypelist
def daily_Repo_price_for_investors(dir_name): """ From质押式回购市场交易情况总结日报 正/逆回购方-利率 """ date = re.match(".*\\d{8}\\.",dir_name).group()[-9:-1] excel_io= input_path+"/质押式回购市场交易情况总结/日报/" + dir_name df=pd.read_excel(excel_io,header=1,nrows = 5).iloc[:,1:7] df.columns.name="正回购方" df.rename(columns={'Unnamed: 1':'机构名称'},inplace=True) df["date"]=date df.reset_index(drop=True) df=df.replace('-',0) name = "Repo_price_for_investors" # 为了对应数据库table名字 columns_type=[#图表的数据口径 String(30), Float(), Float(), Float(), Float(), Float(), DateTime()] dtypelist = dict(zip(df.columns,columns_type))#变成字典形式 return df,name,dtypelist
class GridBasedData(Base): __tablename__ = 'grid_based_data' id = Column(UUID(as_uuid=True), primary_key=True, server_default=sqlalchemy.text("uuid_generate_v4()")) created_at = Column(DateTime, nullable=False) modified_at = Column(DateTime, nullable=False) date_time = Column(DateTime, nullable=False) epw_date_time = Column(DateTime, nullable=False) point_id = Column(UUID(as_uuid=True), ForeignKey('grid_points.id'), nullable=False) simulation_id = Column(UUID(as_uuid=True), ForeignKey('simulations.id'), nullable=False) job_id = Column(UUID(as_uuid=True), ForeignKey('jobs.id'), nullable=False) window_surface_id = Column(UUID(as_uuid=True), ForeignKey('analysis_surfaces.id'), nullable=False) state_name = Column(String, nullable=False) # is window surface state name unit = Column(String, nullable=False) is_direct = Column(Boolean, nullable=False) sky_total = Column(Float(precision=2)) sky_direct = Column(Float(precision=2)) sun = Column(Float(precision=2)) total = Column(Float(precision=2)) point = relationship('GridPoint', backref='datums') simulation = relationship('Simulation', backref='datums') window_surface = relationship('AnalysisSurface', backref='datums')
class Cpu(Base): __tablename__ = 'cpu_moniter' id = Column(Integer, primary_key=True, autoincrement=True) time = Column(DateTime, nullable=False) cpu1 = Column(Float(precision=2), nullable=False) cpu2 = Column(Float(precision=2), nullable=False) cpu3 = Column(Float(precision=2), nullable=False) cpu4 = Column(Float(precision=2), nullable=False)
def test_divide_columns_into_type_of_filters(): column_types_dict = { "col_1": Integer(), "col_2": Text(), "col_3": Float(), "col_4": DateTime(), "col_5": ARRAY("string"), "col_6": Boolean(), "col_7": Integer(), "col_8": Float(), "col_9": DateTime(), "col_10": Text(), "col_11": Boolean(), "col_12": ARRAY("string"), } unique_entries = { "col_1": [1 for i in range(MAX_ENTRIES_FOR_FILTER_SELECTOR + 1)], "col_2": ["Dream" for i in range(MAX_ENTRIES_FOR_FILTER_SELECTOR - 1)], "col_3": [2.5 for i in range(MAX_ENTRIES_FOR_FILTER_SELECTOR + 1)], "col_4": ["11/10/2013" for i in range(MAX_ENTRIES_FOR_FILTER_SELECTOR + 1)], "col_5": [[1, 4, 5] for i in range(MAX_ENTRIES_FOR_FILTER_SELECTOR - 1)], "col_6": [True for i in range(MAX_ENTRIES_FOR_FILTER_SELECTOR - 1)], "col_7": [1 for i in range(MAX_ENTRIES_FOR_FILTER_SELECTOR - 1)], "col_8": [3.5 for i in range(MAX_ENTRIES_FOR_FILTER_SELECTOR - 1)], "col_9": ["11/10/2014" for i in range(MAX_ENTRIES_FOR_FILTER_SELECTOR - 1)], "col_10": ["Dream" for i in range(MAX_ENTRIES_FOR_FILTER_SELECTOR + 1)], "col_11": [True for i in range(MAX_ENTRIES_FOR_FILTER_SELECTOR + 1)], "col_12": [[1, 4, 5] for i in range(MAX_ENTRIES_FOR_FILTER_SELECTOR + 1)], } ( filter_column_names, numerical_filter_column_names, unique_entries_dict, ) = divide_columns_into_type_of_filters(unique_entries, column_types_dict) assert set(numerical_filter_column_names) == { "col_1", "col_3", "col_4", "col_7", "col_8", "col_9", } filter_column_names_set = { "col_2", "col_5", "col_6", "col_7", "col_8", "col_9" } assert set(filter_column_names) == filter_column_names_set assert set(unique_entries_dict.keys()) == filter_column_names_set assert unique_entries_dict["col_2"] == unique_entries["col_2"] assert unique_entries_dict["col_5"] == unique_entries["col_5"] assert unique_entries_dict["col_6"] == unique_entries["col_6"] assert unique_entries_dict["col_7"] == unique_entries["col_7"] assert unique_entries_dict["col_8"] == unique_entries["col_8"] assert unique_entries_dict["col_9"] == unique_entries["col_9"]
class Academia(connector.Manager.Base): __tablename__ = 'academia' id = Column(Integer, Sequence('academia_id_seq'), primary_key=True) Nombre = Column(String(60), nullable=False) Direccion = Column(String(80), nullable=False) Descripcion = Column(String(80), nullable=False) Distrito = Column(String(40), nullable=False) Geo_x = Column(Float(53, 32), nullable=False) Geo_y = Column(Float(53, 32), nullable=False)
class Sentiments(Base): __tablename__ = 'sentiments' site = Column(String(500), primary_key=True) city = Column(String(100), primary_key=True) state = Column(String(50), primary_key=True) postTime = Column(DateTime(timezone=True), primary_key=True) NaiveBayes = Column(Float(precision=5)) Vader = Column(Float(precision=5))
class WEAData(Base): __tablename__ = 'wea_data' id = Column(UUID(as_uuid=True), primary_key=True, server_default=sqlalchemy.text("uuid_generate_v4()")) wea_id = Column(UUID(as_uuid=True), ForeignKey('weas.id'), nullable=False) date_time = Column(DateTime, nullable=False) direct_normal_radiation = Column(Float(precision=2)) diffuse_horizontal_radiation = Column(Float(precision=2))
def daily_fig_bond_leverage(): err, df = w.edb('M0041739,M5639029', start, end, usedf=True) df.columns = ['成交量:银行间质押式回购', '债券市场托管余额'] # df = df.dropna(axis = 0) df['date'] = df.index name = 'fig_bond_leverage' columns_type = [Float(4), Float(1), DateTime()] dtypelist = dict(zip(df.columns, columns_type)) return df, name, dtypelist
def mkt_rates(): # TODO 货币市场利率 err,df=w.edb("M1006336,M1006337,M0017142,M1006645",\ "2000-06-17", "2021-06-16",usedf=True) df.columns = ['DR001', 'DR007', 'shibor_3m', '存单_1y'] df['date'] = df.index name = 'mkt_rates' columns_type = [Float(), Float(), Float(), Float(), DateTime()] dtypelist = dict(zip(df.columns, columns_type)) return df, name, dtypelist
def daily_fig_liquidity_premium(): err, df = w.edb('M0017139,M0041653,M0220163,\ M0017142,M0048486,M1010889,M1010892,M0329545,\ M1011048', start, end, "Fill=Previous", usedf=True) df.columns = [ "shibor_7d", "质押回购利率_7天", "存款类质押回购利率_7天", "shibor_3m", "IRS:FR007:1y", "存单_AAA_3m", "存单_AAA_1y", "MLF:1年", "国股银票转贴现收益率_3m" ] df['date'] = df.index # df = df.dropna(axis = 0) name = 'fig_liquidity_premium' columns_type = [ Float(), Float(), Float(), Float(), Float(), Float(), Float(), Float(), Float(), DateTime() ] dtypelist = dict(zip(df.columns, columns_type)) return df, name, dtypelist
def ccl(): # 超储率 ## 2015年前无政府存款记录 err,df = w.edb("M0001528,M0062047,M0251905,M0043821,M0061518,M0043823,M0010096,\ M0001690,M0001380" ,\ "2010-01-01", "2021-06-16", usedf=True) df.columns=['住户存款','非金融企业存款','政府存款',\ '中小型准备金率','大型准备金率','超额准备金率','超储率_季度',\ '基础货币','M0'] df['date'] = df.index name = 'ccl_related' columns_type = [ Float(), Float(), Float(), Float(), Float(), Float(), Float(), Float(), Float(), DateTime() ] dtypelist = dict(zip(df.columns, columns_type)) return df, name, dtypelist
def pro_cache_data_daily(self, df, index, cached_end): dtypedict = { 'ts_code': NVARCHAR(length=10), 'trade_date': NVARCHAR(length=8), 'open': Float(), 'high': Float(), 'low': Float(), 'close': Float(), 'pre_close': Float(), 'change': Float(), 'pct_chg': Float(), 'vol': Float(), 'amount': Float() } if cached_end is None: print('######## cache new trade daily ############') new = df else: new = df[df.trade_date > cached_end] if index: new.to_sql(self.tables['index_trade_daily'], con=self.conn, if_exists='append', index=False, dtype=dtypedict) else: new.to_sql(self.tables['stock_trade_daily'], con=self.conn, if_exists='append', index=False, dtype=dtypedict)
def save_probability_to_sql(df_probability, name): dtypedict = {'draw': Float(), 'lose': Float(), 'win': Float()} yconnect = create_engine( 'mysql+mysqldb://root:@127.0.0.1:3306/zucai?charset=utf8') pd.io.sql.to_sql(df_probability, name, yconnect, schema='zucai', if_exists='replace', dtype=dtypedict)
def save_dataframe_to_db(df, table_name): """ Save data to the table """ df1 = df[(df['question_id_1'] == 1) & (df['question_id_2'] == 2) & (df['answer_id_1'] == 1)] #print(df) pd.options.display.float_format = '{:,.9f}'.format print(df1[['answer_id_1', 'answer_id_2', 'abs_coeff', 'abs_test_coeff']]) #sys.exit(0) if NO_WRITING_DB: print("Data wasn't saved to BD, because the option -nw is set.") return print(df.info()) df_no_nan = df.dropna() CONFIG = database_connect.CONFIG from sqlalchemy.pool import NullPool from sqlalchemy.orm.session import sessionmaker #sudo apt install python3-mysqldb #str_connect = 'mysql+mysqlconnector://{0}:{1}@{2}/{3}'\ # .format(CONFIG['user'], CONFIG['password'], CONFIG['host'], CONFIG['database']) str_connect = 'mysql+mysqldb://{0}:{1}@{2}/{3}'\ .format(CONFIG['user'], CONFIG['password'], CONFIG['host'], CONFIG['database']) engine = create_engine(str_connect, echo=DEBUG, poolclass=NullPool) Session = sessionmaker() Session.configure(bind=engine) session = Session() # создаем объект сессии logging.debug('Try to write to sql {0} rows (from df)'.format( len(df_no_nan))) #if DEBUG: print(df_no_nan) dtype_dict = { 'coeff': Float(), 'abs_coeff': Float(), 'abs_test_coeff': Float() } df_no_nan.to_sql(name=table_name, con=engine, index=False, dtype=dtype_dict, if_exists='append', chunksize=20000) #df.to_sql(name='matrix_corr_qa', con=conn, if_exists = 'replace', index=False) session.close() engine.dispose() logging.info('Data was written in table {0}'.format(table_name))
def define_columns(data_dict, class_name): """Dynamically define the class attributes for the ORM Parameters ---------- data_dict : dict A dictionary containing the ORM definitions class_name : str The name of the class/ORM. Returns ------- data_dict : dict A dictionary containing the ORM definitions, now with header definitions added. """ special_keywords = [ 'RULEFILE', 'FWERROR', 'FW2ERROR', 'PROPTTL1', 'TARDESCR', 'QUALCOM2' ] with open( os.path.join( os.path.split(__file__)[0], 'table_definitions', class_name.lower() + '.txt'), 'r') as f: data = f.readlines() keywords = [item.strip().split(', ') for item in data] for keyword in keywords: if keyword[0] in special_keywords: data_dict[keyword[0].lower()] = get_special_column(keyword[0]) elif keyword[1] == 'Integer': data_dict[keyword[0].lower()] = Column(Integer()) elif keyword[1] == 'String': data_dict[keyword[0].lower()] = Column(String(50)) elif keyword[1] == 'Float': data_dict[keyword[0].lower()] = Column(Float(precision=32)) elif keyword[1] == 'Decimal': data_dict[keyword[0].lower()] = Column(Float(precision='13,8')) elif keyword[1] == 'Date': data_dict[keyword[0].lower()] = Column(Date()) elif keyword[1] == 'Time': data_dict[keyword[0].lower()] = Column(Time()) elif keyword[1] == 'DateTime': data_dict[keyword[0].lower()] = Column(DateTime) elif keyword[1] == 'Bool': data_dict[keyword[0].lower()] = Column(Boolean) else: raise ValueError('unrecognized header keyword type: {}:{}'.format( keyword[0], keyword[1])) if 'aperture' in data_dict: data_dict['aperture'] = Column(String(50), index=True) return data_dict
def interbank_deposit(): # 同业存单价格与净融资量 err,df = w.edb('M1006645,M0329545', start,end,usedf=True) df.columns = ['存单_股份行_1y', 'MLF:1y'] df['date'] = df.index name = 'interbank_deposit' columns_type=[Float(),Float(), DateTime()] dtypelist = dict(zip(df.columns,columns_type)) return df, name , dtypelist
def local(): name = 'localbond_issue' err, df = w.edb("M5658453,M6191591", "2003-12-01", "2021-06-30", usedf=True) df.columns = ['地方专项债限额', '地方专项债累计发行额'] df['date'] = df.index columns_type = [Float(), Float(), DateTime()] dtypelist = dict(zip(df.columns, columns_type)) return df, name, dtypelist
class Targets(Base): __tablename__ = 'targets' tar_id = Column(Integer, primary_key=True) tar_name = Column(String(150)) tar_ra = Column(Float(Precision=64)) tar_dec = Column(Float(Precision=64)) tar_comment = Column(Text) tar_enabled = Column(Boolean) tar_priority = Column(Integer) tar_bonus = Column(Integer) tar_bonus_time = Column(DateTime) tar_next_observable = Column(DateTime) tar_info = Column(String(2000)) interruptible = Column(Boolean) tar_pm_ra = Column(Float(Precision=64)) tar_pm_dec = Column(Float(Precision=64)) tar_telescope_mode = Column(Integer) def __init__(self, tar_name=None, tar_ra=None, tar_dec=None, tar_comment=None, tar_enabled=None, tar_priority=None, tar_bonus=None, tar_bonus_time=None, tar_next_observable=None, tar_info=None, interruptible=None, tar_pm_ra=None, tar_pm_dec=None, tar_telescope_mode=None): self.tar_name = tar_name self.tar_ra = tar_ra self.tar_dec = tar_dec self.tar_comment = tar_comment self.tar_enabled = tar_enabled self.tar_priority = tar_priority self.tar_bonus = tar_bonus self.tar_bonus_time = tar_bonus_time self.tar_next_observable = tar_next_observable self.tar_info = tar_info self.interruptible = interruptible self.tar_pm_ra = tar_pm_ra self.tar_pm_dec = tar_pm_dec self.tar_telescope_mode = tar_telescope_mode def __repr__(self): return '<Target({0},{1},{2},{3})>'.format(self.tar_id, self.tar_name, self.tar_ra, self.tar_dec)
def cash_cost(): err, df=w.edb('M1006336,M1006337,M1004515,M0017142', start,end,usedf=True) df.columns = ['DR001','DR007','GC007','shibor_3m'] df['date'] = df.index df = df.dropna(axis = 0) name = 'cash_cost' columns_type=[Float(2),Float(2),Float(2),Float(2), DateTime()] dtypelist = dict(zip(df.columns,columns_type)) return df, name, dtypelist
def hs300(): err,df1 = w.wsd("000300.SH", "dividendyield2", \ "2002-01-01", "2021-06-30", usedf=True) df1.columns = ['股息率'] err, df2 = w.edb("M0058003", "2010-01-01", "2021-06-30", usedf=True) df2.columns = ['一般贷款'] df1['一般贷款'] = df2['一般贷款'] df1['date'] = df1.index name = 'hs300Div' df = df1 columns_type = [Float(), Float(), DateTime()] dtypelist = dict(zip(df.columns, columns_type)) return df, name, dtypelist