【dai报错】dai.DataSource.save_view报错
由smartian创建,最终由yangduoduo05 被浏览 7 用户
sql = """
select date,instrument,
volume, -- 成交股数
free_float_shares, --自由流通股数
total_assets_lf, --总资产最新一期
total_assets_yoy_lf, --总资产同比
total_current_assets_lf, --流动资产最新一期
total_liabilities_lf, --总负债最新一期
total_current_liabilities_lf, --流动负债最新一期
total_assets_lf-total_liabilities_lf as net_assets_lf, --净资产
bps_lf, --每股净资产
net_assets_yoy_lf, --净资产同比
total_market_cap, -- 总市值
float_market_cap, -- 流通市值
ebitda_lf, -- 息税折旧摊销前利润
net_profit_ttm, --净利润TTM
net_profit_lf, --净利润最新一期
net_profit_lf_yoy, --净利润同比
net_profit_ttm_yoy, --净利润(滚动十二期,同比增长)
net_profit_to_parent_shareholders_ttm, --归母净利润TTM
net_profit_to_parent_shareholders_lf, --归母净利润最新一期
operating_profit_ttm, --营业利润
net_profit_yoy_lf, -- 净利润同比增长率
operating_revenue_lf, --营业收入
operating_revenue_ttm, --营业收入TTM
operating_revenue_yoy_ttm, --营业收入同比
net_cffoa_lf, -- 经营活动产生的现金流量净额(最新一期)
net_cffoa_ttm, -- 经营现金流净额
accounts_receivable_turnover_days_lf, --应收账款周转天数
inventory_turnover_days_lf, --存货周转天数
accounts_payable_turnover_days_lf, --应付账款周转天数
pe_ttm,
net_assets_lf/total_market_cap as BP,
net_profit_ttm/total_market_cap as EP,
operating_revenue_ttm/total_market_cap as SP,
net_cffoa_ttm/total_market_cap as CFP,
pe_ttm/net_profit_ttm_yoy as PE_ProfitGrowRateTTM,
(total_market_cap + total_liabilities - moneytary_assets_lf) AS EV, -- 企业价值
ebitda_lf/EV as ebitda_ev,
m_avg(volume, 22)/m_avg(free_float_shares, 22) as hsl22,
close/m_lag(close,22)-1 as stockzf22,
SUM(close * volume) OVER (PARTITION BY instrument ORDER BY date ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) /
SUM(volume) OVER (PARTITION BY instrument ORDER BY date ROWS BETWEEN 4 PRECEDING AND CURRENT ROW) AS _vwap_5d,
SUM(close * volume) OVER (PARTITION BY instrument ORDER BY date ROWS BETWEEN 59 PRECEDING AND CURRENT ROW) /
SUM(volume) OVER (PARTITION BY instrument ORDER BY date ROWS BETWEEN 59 PRECEDING AND CURRENT ROW) AS _vwap_60d,
_vwap_5d/_vwap_60d as stockpjcj5_60 ,
roa_avg_lf,
roe_avg_lf,
roa_period_lf,
roe_period_lf,
net_cffoa_ttm/net_profit_ttm as OCFprofitratio,
net_profit_to_parent_shareholders_ttm/operating_revenue_ttm as profitsalesratio,
net_profit_to_parent_shareholders_lf/operating_revenue_lf as profitsalesratio1,
operating_profit_ttm/net_cffoa_ttm as opsalesratio,
operating_profit_lf/net_cffoa_lf as opsalesratio1,
net_cffoa_ttm/total_assets as assetturnover,
total_current_assets_lf/total_current_liabilities as liquidratio,
net_cffoa_ttm/total_current_liabilities as CashAssetRatio,
total_liabilities_lf/total_assets_lf as debt2asset,
accounts_receivable_turnover_days_lf+inventory_turnover_days_lf-accounts_payable_turnover_days_lf as daysofturnover,
operating_revenue_yoy_ttm as salesgrowrate1,
net_profit_lf_yoy as ProfitGrowRate1,
net_assets_yoy_lf as equitygrowrate,
total_assets_yoy_lf as assetgrowrate,
net_profit_ttm_yoy as ProfitGrowRateTTM,
from cn_stock_prefactors
where date>='2017-01-01' and date<='2017-01-31'
"""
dai.DataSource.save_view("my_stock_factors", sql)
您可以去社区论坛问答交流板块反馈咨询 去发帖>>
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
Cell In[5], line 1
----> 1 dai.DataSource.save_view("my_stock_factors", sql)
File /var/app/enabled/dai/_datasource.py:462, in save_view(cls, id, sql, update_if_exists, docs, timeout, extra)
File /var/app/enabled/dai/_storage/datasource.py:175, in create_in_data_manager(self, metadocs, docs, update_if_exists, **kwargs)
Exception: 创建 DataSource(my_stock_factors) 失败: 您没有权限将cn_stock_bar1d保存为view的子数据
\