def import_pledged_detail():
    db=cx_Oracle.connect('c##stock','didierg160','myoracle')  #创建连接  
    cr=db.cursor()   
    
    sql = "delete tb_stock_pledged_detail"
    cr.execute(sql)
    
    df = ts.pledged_detail()
    
    for row in df.itertuples():
        sql = "insert into tb_stock_pledged_detail values (" 
        sql += "'" + str(getattr(row,"code"      )) + "',"            
        sql += "'" + str(getattr(row,"name"      )) + "',"        
        sql += "'" + str(getattr(row,"ann_date"  )) + "',"        
        sql += "'" + str(getattr(row,"pledgor"   )) + "',"        
        sql += "'" + str(getattr(row,"pledgee"   )) + "',"        
        sql += "'" + str(getattr(row,"volume"    )) + "',"        
        sql += "'" + str(getattr(row,"from_date" )) + "',"
        sql += "'" + str(getattr(row,"end_date"  )) + "',"          
        sql += "sysdate"
        sql += ")"        
        cr.execute(sql)         
    
    db.commit()        
    cr.close ()  
    db.close ()     
    print("pledged_detail done")
Ejemplo n.º 2
0
def pledged_detail():
	df=ts.pledged_detail()
	print(df.tail(10))
	# for stock in stocks:
	# 	if len(df[df['code']==stock])!=0:
	# 		print(df[df['code']==stock])
	# df.to_csv('pledge_all_stock.csv')
	df.to_sql('tb_pledged_detail',engine)
Ejemplo n.º 3
0
'''
Created on 2018年2月8日

@author: moonlit
'''

import tushare as ts

if __name__ == '__main__':
    df = ts.stock_pledged()
    print(df.columns)
    print(len(df))
    df = ts.pledged_detail()
    print(df.columns)
    print(len(df))    
Ejemplo n.º 4
0
 def get_all_stock_pledge_detail_bycode(self, code):
     data = tu.pledged_detail().sort_values(['from_date'], ascending=False)
     return data.loc[data['code'] == code]