Example #1
0
 def get_k(cls, stock_code, sampleNo, kline, date, index_profit):
     # print(len(date))
     kline = "simulation_" + kline
     profit = Stochastic.get_random(sigma=0.01, sampleNo=sampleNo)
     high_increse = np.abs(
         Stochastic.get_random(sigma=0.005, sampleNo=sampleNo))
     low_increase = np.abs(
         Stochastic.get_random(sigma=0.005, sampleNo=sampleNo))
     resel = []
     reselh = []
     resell = []
     r = 1
     for i, ss in enumerate(profit):
         r *= 1 + profit[i] + index_profit[i]
         h = (r *
              1.1) if (1 +
                       high_increse[i]) > 1.1 else r * (1 + high_increse[i])
         l = (r * 0.9) if r * (1 - low_increase[i]) < 0.9 else r * (
             1 - low_increase[i])
         resel.append(r)
         reselh.append(h)
         resell.append(l)
     dd = pd.DataFrame({
         'stock_code': stock_code,
         'date': date,
         'low': resell,
         'high': reselh,
         'close': resel,
         'open': resel
     })
     ModelData.insert_data(table_name=kline, data=dd)
Example #2
0
 def get_stock_basics(cls):  #上市公司基本情况
     data = ts.get_stock_basics()
     data['code'] = data.index
     data.reset_index(drop=True, inplace=True)
     ModelData.remove_data(table_name='stock_basics')
     print('remove success')
     ModelData.insert_data(table_name='stock_basics', data=data)
     print('write success')
Example #3
0
 def get_cashflow_data(cls, year, quarter):
     data = ts.get_cashflow_data(year, quarter)
     data['year'] = year
     data['quarter'] = quarter
     data.reset_index(drop=True, inplace=True)
     ModelData.remove_data(table_name='cashflow_data',
                           year=year,
                           quarter=quarter)
     print('remove success')
     ModelData.insert_data(table_name='cashflow_data', data=data)
     print('write success')
Example #4
0
 def get_profit_data(cls, year, quarter):  #反应盈利能力的
     data = ts.get_profit_data(year, quarter)
     data['year'] = year
     data['quarter'] = quarter
     data.reset_index(drop=True, inplace=True)
     ModelData.remove_data(table_name='profit_data',
                           year=year,
                           quarter=quarter)
     print('remove success')
     ModelData.insert_data(table_name='profit_data', data=data)
     print('write success')
     print(data.head(5))