Ejemplo n.º 1
0
    # 402006	贵金属
    # 402007	封闭式
    # 投资标的类型编码
    underlying_asset_type_id = Column(Integer)
    # 投资标的类型
    underlying_asset_type = Column(String(length=32))

    @classmethod
    def get_stocks(cls,
                   code=None,
                   codes=None,
                   ids=None,
                   timestamp=now_pd_timestamp(),
                   provider=None):
        from zvt.api.portfolio import get_fund_stocks
        return get_fund_stocks(code=code,
                               codes=codes,
                               ids=ids,
                               timestamp=timestamp,
                               provider=provider)


class FundStock(FundMetaBase, PortfolioStockHistory):
    __tablename__ = 'fund_stock'


register_schema(providers=['joinquant'],
                db_name='fund_meta',
                schema_base=FundMetaBase)
# the __all__ is generated
__all__ = ['Fund', 'FundStock']
Ejemplo n.º 2
0
    code = Column(String(length=32))
    name = Column(String(length=32))

    # 净流入
    net_inflows = Column(Float)
    # 净流入率
    net_inflow_rate = Column(Float)

    # 主力=超大单+大单
    net_main_inflows = Column(Float)
    net_main_inflow_rate = Column(Float)
    # 超大单
    net_huge_inflows = Column(Float)
    net_huge_inflow_rate = Column(Float)
    # 大单
    net_big_inflows = Column(Float)
    net_big_inflow_rate = Column(Float)

    # 中单
    net_medium_inflows = Column(Float)
    net_medium_inflow_rate = Column(Float)
    # 小单
    net_small_inflows = Column(Float)
    net_small_inflow_rate = Column(Float)


register_schema(providers=['sina', 'joinquant'], db_name='money_flow', schema_base=MoneyFlowBase)

# the __all__ is generated
__all__ = ['BlockMoneyFlow', 'StockMoneyFlow', 'IndexMoneyFlow']
Ejemplo n.º 3
0
# -*- coding: utf-8 -*-
# this file is generated by gen_kdata_schema function, dont't change it
from sqlalchemy.ext.declarative import declarative_base

from zvt.contract.register import register_schema
from zvt.domain.quotes import IndexKdataCommon

KdataBase = declarative_base()


class Index1dKdata(KdataBase, IndexKdataCommon):
    __tablename__ = 'index_1d_kdata'


register_schema(providers=['sina', 'joinquant'],
                db_name='index_1d_kdata',
                schema_base=KdataBase)

__all__ = ['Index1dKdata']
Ejemplo n.º 4
0
# -*- coding: utf-8 -*-
# this file is generated by gen_kdata_schema function, dont't change it
from sqlalchemy.orm import declarative_base

from zvt.contract.register import register_schema
from zvt.domain.quotes import StockKdataCommon

KdataBase = declarative_base()


class Stock5mKdata(KdataBase, StockKdataCommon):
    __tablename__ = "stock_5m_kdata"


register_schema(providers=["joinquant", "em"], db_name="stock_5m_kdata", schema_base=KdataBase, entity_type="stock")

# the __all__ is generated
__all__ = ["Stock5mKdata"]
Ejemplo n.º 5
0
# -*- coding: utf-8 -*-
# this file is generated by gen_kdata_schema function, dont't change it
from sqlalchemy.ext.declarative import declarative_base

from zvt.contract.register import register_schema
from zvt.domain.quotes import IndexKdataCommon

KdataBase = declarative_base()


class Index1wkKdata(KdataBase, IndexKdataCommon):
    __tablename__ = 'index_1wk_kdata'


register_schema(providers=['joinquant', 'sina'],
                db_name='index_1wk_kdata',
                schema_base=KdataBase,
                entity_type='index')

# the __all__ is generated
__all__ = ['Index1wkKdata']
Ejemplo n.º 6
0
    # 净流入
    net_inflows = Column(Float)
    # 净流入率
    net_inflow_rate = Column(Float)

    # 主力=超大单+大单
    net_main_inflows = Column(Float)
    net_main_inflow_rate = Column(Float)
    # 超大单
    net_huge_inflows = Column(Float)
    net_huge_inflow_rate = Column(Float)
    # 大单
    net_big_inflows = Column(Float)
    net_big_inflow_rate = Column(Float)

    # 中单
    net_medium_inflows = Column(Float)
    net_medium_inflow_rate = Column(Float)
    # 小单
    net_small_inflows = Column(Float)
    net_small_inflow_rate = Column(Float)


register_schema(providers=["joinquant", "sina"],
                db_name="money_flow",
                schema_base=MoneyFlowBase,
                entity_type="stock")

# the __all__ is generated
__all__ = ["BlockMoneyFlow", "StockMoneyFlow", "IndexMoneyFlow"]
Ejemplo n.º 7
0
# -*- coding: utf-8 -*-
from sqlalchemy import Column, String
from sqlalchemy.orm import declarative_base

from zvt.contract import Mixin
from zvt.contract.register import register_schema

NewsBase = declarative_base()


class StockNews(NewsBase, Mixin):
    __tablename__ = "stock_news"

    #: 新闻标题
    news_title = Column(String)


register_schema(providers=["em"],
                db_name="stock_news",
                schema_base=NewsBase,
                entity_type="stock")
# the __all__ is generated
__all__ = ["StockNews"]
Ejemplo n.º 8
0
    code = Column(String(length=32))

    spo_issues = Column(Float)
    spo_price = Column(Float)
    spo_raising_fund = Column(Float)


class RightsIssueDetail(DividendFinancingBase, Mixin):
    __tablename__ = "rights_issue_detail"

    provider = Column(String(length=32))
    code = Column(String(length=32))

    # 配股
    rights_issues = Column(Float)
    rights_issue_price = Column(Float)
    rights_raising_fund = Column(Float)


register_schema(regions=[Region.CHN, Region.US],
                providers={
                    Region.CHN: [Provider.EastMoney],
                    Region.US: [Provider.Default]
                },
                db_name='dividend_financing',
                schema_base=DividendFinancingBase)

__all__ = [
    'DividendFinancing', 'DividendDetail', 'SpoDetail', 'RightsIssueDetail'
]
Ejemplo n.º 9
0

# 委托单
class Order(TraderBase, Mixin):
    __tablename__ = 'order'

    # 机器人名字
    trader_name = Column(String(length=128))
    # 订单价格
    order_price = Column(Float)
    # 订单数量
    order_amount = Column(Float)
    # 订单类型
    order_type = Column(String(length=64))
    # 订单状态
    status = Column(String(length=64))

    # 产生订单的selector/factor level
    level = Column(String(length=32))


register_schema(regions=[Region.CHN, Region.US],
                providers={
                    Region.CHN: [Provider.ZVT],
                    Region.US: [Provider.ZVT]
                },
                db_name='trader_info',
                schema_base=TraderBase)

__all__ = ['TraderInfo', 'AccountStats', 'Position', 'Order']
Ejemplo n.º 10
0
# -*- coding: utf-8 -*-
# this file is generated by gen_kdata_schema function, dont't change it
from sqlalchemy.orm import declarative_base

from zvt.contract.register import register_schema
from zvt.domain.quotes import BlockKdataCommon

KdataBase = declarative_base()


class Block1wkKdata(KdataBase, BlockKdataCommon):
    __tablename__ = 'block_1wk_kdata'


register_schema(providers=['eastmoney'],
                db_name='block_1wk_kdata',
                schema_base=KdataBase,
                entity_type='block')

# the __all__ is generated
__all__ = ['Block1wkKdata']
Ejemplo n.º 11
0
    provider = Column(String(length=32))
    code = Column(String(length=32))

    spo_issues = Column(Float)
    spo_price = Column(Float)
    spo_raising_fund = Column(Float)


class RightsIssueDetail(DividendFinancingBase, Mixin):
    __tablename__ = "rights_issue_detail"

    provider = Column(String(length=32))
    code = Column(String(length=32))

    # 配股
    rights_issues = Column(Float)
    rights_issue_price = Column(Float)
    rights_raising_fund = Column(Float)


register_schema(providers=["eastmoney"],
                db_name="dividend_financing",
                schema_base=DividendFinancingBase,
                entity_type="stock")

# the __all__ is generated
__all__ = [
    "DividendFinancing", "DividendDetail", "SpoDetail", "RightsIssueDetail"
]
Ejemplo n.º 12
0
    fi_net_capital = Column(Float)
    # 专项指标(保险)
    #
    # 总投资收益率
    insurance_roi = Column(Float)
    # 净投资收益率
    insurance_net_investment_yield = Column(Float)
    # 已赚保费
    insurance_earned_premium = Column(Float)
    # 赔付支出
    insurance_payout = Column(Float)
    # 退保率
    insurance_surrender_rate = Column(Float)
    # 偿付能力充足率
    insurance_solvency_adequacy_ratio = Column(Float)
    # 专项指标(券商)
    #
    # 净资本
    broker_net_capital = Column(Float)
    # 净资产
    broker_net_assets = Column(Float)
    # 净资本/净资产
    broker_net_capital_assets_ratio = Column(Float)
    # 自营固定收益类证券规模/净资本
    broker_self_operated_fixed_income_securities_net_capital_ratio = Column(Float)


register_schema(providers=['eastmoney'], db_name='finance', schema_base=FinanceBase)

__all__ = ['FinanceFactor', 'BalanceSheet', 'IncomeStatement', 'CashFlowStatement']
Ejemplo n.º 13
0
# -*- coding: utf-8 -*-
# this file is generated by gen_kdata_schema function, dont't change it
from sqlalchemy.ext.declarative import declarative_base

from zvt.contract.register import register_schema
from zvt_ccxt.domain.quotes import CoinKdataCommon

KdataBase = declarative_base()


class Coin15mKdata(KdataBase, CoinKdataCommon):
    __tablename__ = 'coin_15m_kdata'


register_schema(providers=['ccxt'],
                db_name='coin_15m_kdata',
                schema_base=KdataBase)

__all__ = ['Coin15mKdata']
Ejemplo n.º 14
0
# -*- coding: utf-8 -*-
from sqlalchemy.ext.declarative import declarative_base

from zvt.contract.register import register_schema
from zvt.factors.ma.domain.common import MaStatsFactorCommon

Stock1dMaStatsFactorBase = declarative_base()


class Stock1dMaStatsFactor(Stock1dMaStatsFactorBase, MaStatsFactorCommon):
    __tablename__ = "stock_1d_ma_stats_factor"


register_schema(providers=["zvt"],
                db_name="stock_1d_ma_stats_factor",
                schema_base=Stock1dMaStatsFactorBase)
# the __all__ is generated
__all__ = ["Stock1dMaStatsFactor"]
Ejemplo n.º 15
0
FactorBase = declarative_base()


# 用于保存factor的状态
class FactorState(FactorBase, Mixin):
    __tablename__ = 'factor_state'
    # 因子名字
    factor_name = Column(String(length=128))

    # json string
    state = Column(Text())


register_schema(providers=['zvt'],
                db_name='factor_info',
                schema_base=FactorBase)


class Factor(DataReader, DataListener):
    factor_type: FactorType = None

    # define the schema for persist,its columns should be same as indicators in transformer or accumulator
    factor_schema: Type[Mixin] = None

    transformer: Transformer = None
    accumulator: Accumulator = None

    def __init__(
            self,
            data_schema: Type[Mixin],
Ejemplo n.º 16
0
    code = Column(String(length=32))
    name = Column(String(length=32))
    # 静态pe
    pe = Column(Float)
    # 加权
    pe1 = Column(Float)
    # 动态pe
    pe_ttm = Column(Float)
    # 加权
    pe_ttm1 = Column(Float)
    # 市净率
    pb = Column(Float)
    # 加权
    pb1 = Column(Float)
    # 市销率
    ps = Column(Float)
    # 加权
    ps1 = Column(Float)
    # 市现率
    pcf = Column(Float)
    # 加权
    pcf1 = Column(Float)


register_schema(providers=['joinquant'],
                db_name='valuation',
                schema_base=ValuationBase,
                entity_type='stock')

# the __all__ is generated
__all__ = ['StockValuation', 'EtfValuation']
Ejemplo n.º 17
0
class InstitutionalInvestorHolder(HolderBase, Mixin):
    __tablename__ = 'institutional_investor_holder'

    provider = Column(String(length=32))
    code = Column(String(length=32))

    report_period = Column(String(length=32))
    report_date = Column(DateTime)

    # 机构类型
    institutional_investor_type = Column(String(length=64))
    # 股东代码
    holder_code = Column(String(length=32))
    # 股东名称
    holder_name = Column(String(length=32))
    # 持股数
    shareholding_numbers = Column(Float)
    # 持股比例
    shareholding_ratio = Column(Float)


register_schema(providers=['eastmoney', 'joinquant'],
                db_name='holder',
                schema_base=HolderBase,
                entity_type='stock')

# the __all__ is generated
__all__ = [
    'HkHolder', 'TopTenTradableHolder', 'TopTenHolder',
    'InstitutionalInvestorHolder'
]
Ejemplo n.º 18
0
# -*- coding: utf-8 -*-
# this file is generated by gen_kdata_schema function, dont't change it
from sqlalchemy.orm import declarative_base

from zvt.contract.register import register_schema
from zvt.domain.quotes import StockKdataCommon

KdataBase = declarative_base()


class Stock5mHfqKdata(KdataBase, StockKdataCommon):
    __tablename__ = 'stock_5m_hfq_kdata'


register_schema(providers=['joinquant'],
                db_name='stock_5m_hfq_kdata',
                schema_base=KdataBase,
                entity_type='stock')

# the __all__ is generated
__all__ = ['Stock5mHfqKdata']
Ejemplo n.º 19
0
    net_out_dep1_money_out = Column(Float)
    net_out_dep1_rate = Column(Float)

    net_out_dep2 = Column(String(length=128))
    net_out_dep2_money_in = Column(Float)
    net_out_dep2_money_out = Column(Float)
    net_out_dep2_rate = Column(Float)

    net_out_dep3 = Column(String(length=128))
    net_out_dep3_money_in = Column(Float)
    net_out_dep3_money_out = Column(Float)
    net_out_dep3_rate = Column(Float)

    net_out_dep4 = Column(String(length=128))
    net_out_dep4_money_in = Column(Float)
    net_out_dep4_money_out = Column(Float)
    net_out_dep4_rate = Column(Float)

    net_out_dep5 = Column(String(length=128))
    net_out_dep5_money_in = Column(Float)
    net_out_dep5_money_out = Column(Float)
    net_out_dep5_rate = Column(Float)


register_schema(regions=[Region.CHN, Region.US], 
                providers={Region.CHN: [Provider.EastMoney, Provider.JoinQuant], 
                           Region.US: [Provider.Default]}, 
                db_name='trading', schema_base=TradingBase)

__all__ = ['ManagerTrading', 'HolderTrading', 'MarginTrading', 'BigDealTrading', 'DragonAndTiger']
Ejemplo n.º 20
0
    profit = Column(Float)
    # 市值 或者 占用的保证金(方便起见,总是100%)
    value = Column(Float)
    # 交易类型(0代表T+0,1代表T+1)
    trading_t = Column(Integer)


# 委托单
class Order(TraderBase, Mixin):
    __tablename__ = 'order'

    # 机器人名字
    trader_name = Column(String(length=128))
    # 订单价格
    order_price = Column(Float)
    # 订单数量
    order_amount = Column(Float)
    # 订单类型
    order_type = Column(String(length=64))
    # 订单状态
    status = Column(String(length=64))

    # 产生订单的selector/factor level
    level = Column(String(length=32))


register_schema(providers=['zvt'], db_name='trader_info', schema_base=TraderBase)

__all__ = ['TraderInfo', 'AccountStats', 'Position', 'Order']
Ejemplo n.º 21
0
Archivo: holder.py Proyecto: zvtvz/zvt
    __tablename__ = "institutional_investor_holder"

    provider = Column(String(length=32))
    code = Column(String(length=32))

    report_period = Column(String(length=32))
    report_date = Column(DateTime)

    # 机构类型
    institutional_investor_type = Column(String(length=64))
    # 股东代码
    holder_code = Column(String(length=32))
    # 股东名称
    holder_name = Column(String(length=32))
    # 持股数
    shareholding_numbers = Column(Float)
    # 持股比例
    shareholding_ratio = Column(Float)


register_schema(providers=["eastmoney", "joinquant"],
                db_name="holder",
                schema_base=HolderBase,
                entity_type="stock")

# the __all__ is generated
__all__ = [
    "HkHolder", "TopTenTradableHolder", "TopTenHolder",
    "InstitutionalInvestorHolder"
]
Ejemplo n.º 22
0
from sqlalchemy import Column, String, Float
from sqlalchemy.orm import declarative_base

from zvt.contract import Portfolio, PortfolioStockHistory
from zvt.contract.register import register_schema, register_entity

IndexMetaBase = declarative_base()


# 指数
@register_entity(entity_type="index")
class Index(IndexMetaBase, Portfolio):
    __tablename__ = "index"

    # 发布商
    publisher = Column(String(length=64))
    # 类别
    # see IndexCategory
    category = Column(String(length=64))
    # 基准点数
    base_point = Column(Float)


class IndexStock(IndexMetaBase, PortfolioStockHistory):
    __tablename__ = "index_stock"


register_schema(providers=["exchange"], db_name="index_meta", schema_base=IndexMetaBase)
# the __all__ is generated
__all__ = ["Index", "IndexStock"]
Ejemplo n.º 23
0

class Stock1dMaFactor(Stock1dMaFactorBase, Mixin):
    __tablename__ = 'Stock1dMaFactor'

    level = Column(String(length=32))
    code = Column(String(length=32))
    name = Column(String(length=128))

    open = Column(Float)
    close = Column(Float)
    high = Column(Float)
    low = Column(Float)

    ma5 = Column(Float)
    ma10 = Column(Float)

    ma34 = Column(Float)
    ma55 = Column(Float)
    ma89 = Column(Float)
    ma144 = Column(Float)

    ma120 = Column(Float)
    ma250 = Column(Float)


register_schema(regions=[Region.CHN, Region.US], 
                providers={Region.CHN: [Provider.ZVT], 
                           Region.US: [Provider.ZVT]}, 
                db_name='stock_1d_ma_factor', schema_base=Stock1dMaFactorBase)
Ejemplo n.º 24
0
    report_period = Column(String(length=32))
    report_date = Column(DateTime)

    #: 变动比例
    change_ratio = Column(Float)
    #: 是否完成
    is_complete = Column(Boolean)
    #: 持股市值
    actor_type = Column(String)
    actor_count = Column(Integer)

    #: 持股数
    holding_numbers = Column(Float)
    #: 持股比例
    holding_ratio = Column(Float)
    #: 持股市值
    holding_values = Column(Float)


register_schema(providers=["em"],
                db_name="stock_actor",
                schema_base=StockActorBase,
                entity_type="stock")

# the __all__ is generated
__all__ = [
    "StockTopTenFreeHolder", "StockTopTenHolder",
    "StockInstitutionalInvestorHolder", "StockActorSummary"
]
Ejemplo n.º 25
0
# -*- coding: utf-8 -*-
# this file is generated by gen_kdata_schema function, dont't change it
from sqlalchemy.ext.declarative import declarative_base

from zvt.contract.register import register_schema
from zvt.domain.quotes import StockEmotionFactorCommon

FactorBase = declarative_base()


class StockEmotionFactor(FactorBase, StockEmotionFactorCommon):
    @classmethod
    def important_cols(cls):
        return [
            'AR', 'ARBR', 'ATR14', 'ATR6', 'BR', 'DAVOL10', 'DAVOL20',
            'DAVOL5', 'MAWVAD', 'money_flow_20', 'PSY', 'turnover_volatility',
            'TVMA20', 'TVMA6', 'TVSTD20', 'TVSTD6', 'VDEA', 'VDIFF', 'VEMA10',
            'VEMA12', 'VEMA26', 'VEMA5', 'VMACD', 'VOL10', 'VOL120', 'VOL20',
            'VOL240', 'VOL5', 'VOL60', 'VOSC', 'VR', 'VROC12', 'VROC6',
            'VSTD10', 'VSTD20', 'WVAD'
        ]

    __tablename__ = 'stock_emotion_factor'


register_schema(providers=['joinquant'],
                db_name='stock_emotion_factor',
                schema_base=FactorBase)

__all__ = ['StockEmotionFactor']
Ejemplo n.º 26
0
# -*- coding: utf-8 -*-

from sqlalchemy import Column, String
from sqlalchemy.orm import declarative_base

from zvt.contract import Portfolio, PortfolioStock
from zvt.contract.register import register_schema, register_entity

BlockMetaBase = declarative_base()


# 板块
@register_entity(entity_type="block")
class Block(BlockMetaBase, Portfolio):
    __tablename__ = "block"

    # 板块类型,行业(industry),概念(concept)
    category = Column(String(length=64))


class BlockStock(BlockMetaBase, PortfolioStock):
    __tablename__ = "block_stock"


register_schema(providers=["eastmoney", "sina"],
                db_name="block_meta",
                schema_base=BlockMetaBase)
# the __all__ is generated
__all__ = ["Block", "BlockStock"]
Ejemplo n.º 27
0
class Stock5mKdata(KdataBase, StockKdataCommon):
    __tablename__ = 'stock_5m_kdata'


class Stock5mHfqKdata(KdataBase, StockKdataCommon):
    __tablename__ = 'stock_5m_hfq_kdata'


class Stock5mBfqKdata(KdataBase, StockKdataCommon):
    __tablename__ = 'stock_5m_bfq_kdata'


register_schema(regions=[Region.CHN, Region.US],
                providers={
                    Region.CHN: [Provider.JoinQuant, Provider.BaoStock],
                    Region.US: [Provider.Yahoo]
                },
                db_name='stock_5m_kdata',
                schema_base=KdataBase)

register_schema(regions=[Region.CHN, Region.US],
                providers={
                    Region.CHN: [Provider.JoinQuant, Provider.BaoStock],
                    Region.US: [Provider.Yahoo]
                },
                db_name='stock_5m_hfq_kdata',
                schema_base=KdataBase)

register_schema(regions=[Region.CHN, Region.US],
                providers={
                    Region.CHN: [Provider.JoinQuant, Provider.BaoStock],
Ejemplo n.º 28
0
    industry_indices = Column(String)
    concept_indices = Column(String)
    area_indices = Column(String)

    # 成立日期
    date_of_establishment = Column(DateTime)
    # 公司简介
    profile = Column(String(length=1024))
    # 主营业务
    main_business = Column(String(length=512))
    # 发行量(股)
    issues = Column(BigInteger)
    # 发行价格
    price = Column(Float)
    # 募资净额(元)
    raising_fund = Column(Float)
    # 发行市盈率
    issue_pe = Column(Float)
    # 网上中签率
    net_winning_rate = Column(Float)


register_schema(providers=['joinquant', 'eastmoney', 'exchange', 'sina'],
                db_name='stock_meta',
                schema_base=StockMetaBase)

__all__ = [
    'Stock', 'Index', 'Block', 'Etf', 'IndexStock', 'BlockStock', 'EtfStock',
    'StockDetail'
]
Ejemplo n.º 29
0
# -*- coding: utf-8 -*-
# this file is generated by gen_kdata_schema function, dont't change it
from sqlalchemy.ext.declarative import declarative_base

from zvt.contract.register import register_schema
from zvt.domain.quotes import StockKdataCommon

KdataBase = declarative_base()


class Stock1hHfqKdata(KdataBase, StockKdataCommon):
    __tablename__ = 'stock_1h_hfq_kdata'


register_schema(providers=['joinquant'],
                db_name='stock_1h_hfq_kdata',
                schema_base=KdataBase)

__all__ = ['Stock1hHfqKdata']
Ejemplo n.º 30
0
    # 投资标的类型编码
    underlying_asset_type_id = Column(Integer)
    # 投资标的类型
    underlying_asset_type = Column(String(length=32))

    @classmethod
    def get_stocks(cls,
                   code=None,
                   codes=None,
                   ids=None,
                   timestamp=now_pd_timestamp(),
                   provider=None):
        from zvt.api.portfolio import get_fund_stocks

        return get_fund_stocks(code=code,
                               codes=codes,
                               ids=ids,
                               timestamp=timestamp,
                               provider=provider)


class FundStock(FundMetaBase, PortfolioStockHistory):
    __tablename__ = "fund_stock"


register_schema(providers=["joinquant"],
                db_name="fund_meta",
                schema_base=FundMetaBase)
# the __all__ is generated
__all__ = ["Fund", "FundStock"]