384 lines
42 KiB
Python
384 lines
42 KiB
Python
from tortoise import Model, fields
|
||
|
||
|
||
class Aerich(Model):
|
||
app = fields.CharField(max_length=100, )
|
||
content = fields.JSONField()
|
||
id = fields.IntField(pk=True, )
|
||
version = fields.CharField(max_length=255, )
|
||
|
||
|
||
class BackObservedData(Model):
|
||
id = fields.IntField(pk=True, description='id表', )
|
||
key = fields.CharField(max_length=255, null=True, description='key', )
|
||
observed_data = fields.BinaryField(null=True, description='格式化后的json数据', )
|
||
|
||
|
||
class BackObservedDataDetail(Model):
|
||
back_observed_data = fields.BinaryField(null=True, )
|
||
id = fields.IntField(pk=True, )
|
||
key = fields.CharField(max_length=255, )
|
||
|
||
|
||
class BackPosition(Model):
|
||
back_position_data = fields.BinaryField(null=True, )
|
||
id = fields.IntField(pk=True, )
|
||
key = fields.CharField(max_length=25, null=True, )
|
||
|
||
|
||
class BackResultIndicator(Model):
|
||
id = fields.IntField(pk=True, )
|
||
indicator = fields.BinaryField(null=True, )
|
||
key = fields.CharField(max_length=25, null=True, )
|
||
|
||
|
||
class BackTrandInfo(Model):
|
||
id = fields.IntField(pk=True, )
|
||
key = fields.CharField(max_length=25, null=True, )
|
||
trade_info = fields.BinaryField(null=True, )
|
||
|
||
|
||
class Backtest(Model):
|
||
backtest_at = fields.DatetimeField(description='回测时间', )
|
||
backtest_code = fields.TextField(description='回测代码', )
|
||
deleted_at = fields.DatetimeField(null=True, description='删除时间', )
|
||
id = fields.IntField(pk=True, )
|
||
is_active = fields.BooleanField(default=True, description='是否可用', )
|
||
is_running = fields.BooleanField(default=True, description='回测状态', )
|
||
key = fields.CharField(unique=True, max_length=20, description='回测key', )
|
||
key = fields.CharField(unique=True, max_length=20, description='回测key', )
|
||
strategy_id = fields.IntField(index=True, )
|
||
updated_at = fields.DatetimeField(description='修改时间', )
|
||
user_id = fields.IntField(description='回测用户', )
|
||
|
||
|
||
class Backtesting(Model):
|
||
id = fields.IntField(pk=True, description='主键id', )
|
||
key = fields.CharField(max_length=30, description='回测key', )
|
||
|
||
|
||
class Entrust(Model):
|
||
account_type = fields.SmallIntField(description='账户类型', )
|
||
deal_number = fields.IntField(description='成家数量', )
|
||
deal_price = fields.FloatField(null=True, description='成交价格', )
|
||
entrust_date = fields.DateField(null=True, description='委托日期', )
|
||
entrust_money = fields.FloatField(description='委托金额', )
|
||
entrust_number = fields.IntField(description='委托数量', )
|
||
entrust_time = fields.TimeField(null=True, )
|
||
fund_account = fields.IntField(description='资金账户', )
|
||
id = fields.IntField(pk=True, description='主键id', )
|
||
is_repair = fields.BooleanField(default=False, description='是否补单', )
|
||
limit_price = fields.FloatField(description='委托价', )
|
||
order_type = fields.CharField(max_length=30, description='操作', )
|
||
securities_alias = fields.CharField(max_length=30, null=True, description='账户别名', )
|
||
stock_code = fields.CharField(max_length=30, description='证券代码', )
|
||
stock_name = fields.CharField(max_length=30, description='证券名称', )
|
||
|
||
|
||
class Login(Model):
|
||
login_at = fields.DatetimeField(null=True, description='登录时间', )
|
||
mobile = fields.CharField(index=True, max_length=30, null=True, description='手机号', )
|
||
password = fields.CharField(max_length=255, null=True, description='密码', )
|
||
user_id = fields.IntField(pk=True, )
|
||
wx_openid = fields.CharField(unique=True, max_length=255, null=True, description='微信ID', )
|
||
|
||
|
||
class Orders(Model):
|
||
entrust_date = fields.DatetimeField(null=True, description='委托日期', )
|
||
entrust_time = fields.TimeField(null=True, )
|
||
id = fields.IntField(pk=True, description='订单ID', )
|
||
limit_price = fields.FloatField(description='限价', )
|
||
order_amount = fields.FloatField(description='委托金额', )
|
||
order_quantity = fields.IntField(description='委托数量', )
|
||
order_type = fields.CharField(max_length=20, description='订单类型', )
|
||
position = fields.CharField(max_length=30, description='仓位', )
|
||
stock_code = fields.CharField(max_length=30, description='股票代码', )
|
||
stock_name = fields.CharField(max_length=30, description='股票名称', )
|
||
user_id = fields.IntField(description='用户Id', )
|
||
|
||
|
||
class Position(Model):
|
||
adjbase = fields.FloatField(description='复权基数', )
|
||
date = fields.CharField(max_length=255, description='日期', )
|
||
id = fields.IntField(pk=True, description='主键', )
|
||
key = fields.CharField(max_length=30, description='键', )
|
||
name = fields.CharField(max_length=30, description='名称', )
|
||
price = fields.FloatField(description='价格', )
|
||
profit = fields.FloatField(description='利润', )
|
||
size = fields.IntField(description='数量', )
|
||
|
||
|
||
class SecurityAccount(Model):
|
||
account_alias = fields.CharField(max_length=30, description='账户别名', )
|
||
available_money = fields.FloatField(null=True, description='可用金额', )
|
||
available_proportion = fields.FloatField(null=True, description='可用资金占比', )
|
||
freeze = fields.FloatField(null=True, description='冻结金额', )
|
||
fund_account = fields.BigIntField(description='资金账户', )
|
||
id = fields.IntField(pk=True, description='主键', )
|
||
money = fields.FloatField(null=True, description='账户金额', )
|
||
securities_name = fields.CharField(max_length=30, description='证券公司名字昵称', )
|
||
|
||
|
||
class Smsname(Model):
|
||
gender = fields.CharField(max_length=45, default=0, description='是否删除', )
|
||
id = fields.IntField(pk=True, description='自增ID', )
|
||
mobile = fields.CharField(max_length=45, default=0, description='创建时间', )
|
||
student_name = fields.CharField(max_length=45, description='状态', )
|
||
student_no = fields.CharField(max_length=20, description='唯一编码,前台使用', )
|
||
|
||
|
||
class Snowball(Model):
|
||
id = fields.IntField(pk=True, description='主键', )
|
||
snowball_token = fields.CharField(max_length=10000, null=True, description='雪球用户的token', )
|
||
|
||
|
||
class Stock(Model):
|
||
id = fields.IntField(pk=True, description='主键', )
|
||
stock_code = fields.CharField(max_length=30, description='股票代码', )
|
||
stock_name = fields.CharField(max_length=30, null=True, description='股票名称', )
|
||
stock_pinyin = fields.CharField(max_length=30, description='股票拼音', )
|
||
type = fields.CharField(max_length=2, null=True, description='类型', )
|
||
|
||
|
||
class StockBtHistory(Model):
|
||
bt_benchmark_code = fields.CharField(max_length=6, null=True, description='股票基准代码', )
|
||
bt_stock_code = fields.CharField(max_length=6, null=True, description='回测股票代码', )
|
||
bt_stock_data = fields.BinaryField(null=True, description='回测股票数据', )
|
||
bt_stock_name = fields.CharField(max_length=10, null=True, description='回测股票名称', )
|
||
bt_stock_period = fields.CharField(max_length=10, null=True, description='回测类型', )
|
||
bt_strategy_name = fields.CharField(max_length=10, null=True, description='回测策略名称', )
|
||
end_bt_time = fields.CharField(max_length=8, null=True, description='回测最终时间', )
|
||
id = fields.IntField(pk=True, )
|
||
|
||
|
||
class StockDataProcessing(Model):
|
||
bt_benchmark_code = fields.CharField(max_length=6, null=True, description='基准代码', )
|
||
bt_stock_period = fields.CharField(max_length=10, null=True, description='数据类型', )
|
||
bt_strategy_name = fields.CharField(max_length=10, null=True, description='回测策略名', )
|
||
id = fields.IntField(pk=True, )
|
||
processing_data = fields.BinaryField(null=True, description='清洗后的数据', )
|
||
prosessing_date = fields.CharField(max_length=10, null=True, description='当前回测时间', )
|
||
stock_name = fields.CharField(max_length=10, null=True, )
|
||
stocke_code = fields.CharField(max_length=10, null=True, )
|
||
|
||
|
||
class StockDetails(Model):
|
||
id = fields.IntField(pk=True, description='主键', )
|
||
latest_price = fields.FloatField(null=True, description='最新价', )
|
||
rise_fall = fields.FloatField(null=True, description='跌涨幅', )
|
||
stock_code = fields.CharField(max_length=30, description='股票代码', )
|
||
stock_name = fields.CharField(max_length=30, null=True, description='股票名称', )
|
||
stock_pinyin = fields.CharField(max_length=30, description='股票拼音', )
|
||
type = fields.CharField(max_length=2, null=True, description='类型', )
|
||
|
||
|
||
class StockHistory(Model):
|
||
end_bt_time = fields.CharField(max_length=10, null=True, description='最终回测时间', )
|
||
id = fields.IntField(pk=True, )
|
||
start_time_to_market = fields.CharField(max_length=10, null=True, description='股票上市时间', )
|
||
stock_code = fields.IntField(description='股票代码', )
|
||
stock_name = fields.CharField(max_length=10, null=True, )
|
||
symbol_data = fields.BinaryField(null=True, description='股票数据', )
|
||
|
||
|
||
class Strategy(Model):
|
||
backtest_count = fields.IntField(description='回测次数', )
|
||
backtest_keys = fields.JSONField(null=True, description='回测key列表', )
|
||
created_at = fields.DatetimeField(description='创建时间', )
|
||
deleted_at = fields.DatetimeField(null=True, description='删除时间', )
|
||
id = fields.IntField(pk=True, description='主键', )
|
||
is_deleted = fields.BooleanField(default=False, description='是否删除', )
|
||
strategy_hash = fields.CharField(max_length=255, description='策略版本号', )
|
||
strategy_name = fields.CharField(max_length=255, description='策略名称', )
|
||
strategy_type = fields.CharField(max_length=255, null=True, description='策略类型', )
|
||
updated_at = fields.DatetimeField(description='修改时间', )
|
||
user_id = fields.IntField(description='所属用户', )
|
||
|
||
|
||
class TranObserverData(Model):
|
||
id = fields.IntField(pk=True, )
|
||
key = fields.CharField(max_length=255, )
|
||
tran_observer_data = fields.BinaryField(null=True, description='存储大量数据', )
|
||
|
||
|
||
class TranPosition(Model):
|
||
id = fields.IntField(pk=True, )
|
||
key = fields.CharField(max_length=25, null=True, )
|
||
tran_position_data = fields.BinaryField(null=True, )
|
||
|
||
|
||
class TranReturn(Model):
|
||
id = fields.IntField(pk=True, )
|
||
key = fields.CharField(max_length=255, null=True, )
|
||
tran_return_data = fields.BinaryField(null=True, )
|
||
|
||
|
||
class TranTradeInfo(Model):
|
||
id = fields.IntField(pk=True, )
|
||
key = fields.CharField(max_length=25, null=True, )
|
||
tran_trade_info = fields.BinaryField(null=True, )
|
||
|
||
|
||
class TrandInfo(Model):
|
||
id = fields.IntField(pk=True, description='id', )
|
||
key = fields.CharField(max_length=255, null=True, description='唯一索引', )
|
||
tran_info_data = fields.BinaryField(null=True, )
|
||
|
||
|
||
class Tranorders(Model):
|
||
id = fields.IntField(pk=True, )
|
||
key = fields.CharField(max_length=255, null=True, )
|
||
order_return = fields.BinaryField(null=True, )
|
||
|
||
|
||
class Transaction(Model):
|
||
bar = fields.CharField(max_length=10, null=True, description='频率K线', )
|
||
cash = fields.FloatField(null=True, description='资金', )
|
||
created_at = fields.DatetimeField(description='创建时间', )
|
||
deleted_at = fields.DatetimeField(null=True, description='删除时间', )
|
||
id = fields.IntField(pk=True, description='主键', )
|
||
is_deleted = fields.BooleanField(default=False, description='是否删除', )
|
||
is_running = fields.BooleanField(default=True, description='运行状态', )
|
||
key = fields.CharField(max_length=20, description='key,数据标识', )
|
||
process_id = fields.IntField(description='进程号', )
|
||
stopped_at = fields.DatetimeField(null=True, description='停止时间', )
|
||
strategy_id = fields.IntField(index=True, )
|
||
transaction_name = fields.CharField(max_length=255, description='交易名称', )
|
||
transaction_type = fields.CharField(max_length=255, null=True, description='交易类型', )
|
||
updated_at = fields.DatetimeField(description='修改时间', )
|
||
user_id = fields.IntField(description='用户id', )
|
||
|
||
|
||
class UserCombinationHistory(Model):
|
||
combination_list = fields.JSONField(null=True, )
|
||
id = fields.IntField(pk=True, )
|
||
last_time = fields.CharField(max_length=10, null=True, description='最后一次使用的时间', )
|
||
stock_weights = fields.JSONField(null=True, description='权重存储', )
|
||
strategy_name = fields.CharField(max_length=50, null=True, description='用户使用的策略', )
|
||
strategy_parame = fields.JSONField(null=True, description='用户使用的策略参数', )
|
||
user_id = fields.IntField(description='用户的id', )
|
||
|
||
|
||
class UserStrategy(Model):
|
||
create_time = fields.DatetimeField(null=True, )
|
||
deleted_stock = fields.JSONField(null=True, )
|
||
id = fields.IntField(pk=True, )
|
||
strategy_name = fields.CharField(max_length=30, null=True, )
|
||
strategy_request = fields.BinaryField()
|
||
user_id = fields.IntField(index=True, )
|
||
|
||
|
||
class Users(Model):
|
||
avatar_url = fields.CharField(max_length=255, null=True, description='头像', )
|
||
beta_account_type = fields.CharField(max_length=30, null=True, description='内测账号类型', )
|
||
created_at = fields.DatetimeField(description='创建时间', )
|
||
created_user_id = fields.IntField(description='创建人id', )
|
||
dedicated_id = fields.IntField(description='专属客服id', )
|
||
deleted_at = fields.DatetimeField(null=True, description='删除时间', )
|
||
id = fields.IntField(pk=True, description='主键', )
|
||
invited_user_id = fields.IntField(description='邀请人id', )
|
||
is_deleted = fields.BooleanField(default=False, description='是否删除', )
|
||
login_at = fields.DatetimeField(null=True, description='最后一次登录时间', )
|
||
member_type = fields.IntField(description='会员类型', )
|
||
nickname = fields.CharField(max_length=30, null=True, description='用户昵称', )
|
||
pre_cost_time = fields.IntField(description='预支付时间(单位年)', )
|
||
qr_code = fields.CharField(max_length=255, null=True, description='专属客服二维码', )
|
||
updated_at = fields.DatetimeField(description='修改时间', )
|
||
|
||
|
||
class WanceDataStock(Model):
|
||
financial_asset_value = fields.FloatField(null=True, default=0, description='每股净资产', )
|
||
financial_cash_flow = fields.FloatField(null=True, default=0, description='每股现金流', )
|
||
financial_dividend = fields.FloatField(null=True, default=0, description='分红率', )
|
||
financial_ex_gratia = fields.FloatField(null=True, default=0, description='扣非后每股收益', )
|
||
financial_reserve_per = fields.FloatField(null=True, default=0, description='每股资本公积金', )
|
||
financial_undistributed_profit = fields.FloatField(null=True, default=0, description='每股未分配利润', )
|
||
growth_attributable_rate = fields.FloatField(null=True, default=0, description='归母净利润同比增长率', )
|
||
growth_growth_rate = fields.FloatField(null=True, default=0, description='营业利润同比增长率', )
|
||
growth_Income_rate = fields.FloatField(null=True, default=0, description='营业总收入同比增长率', )
|
||
growth_nonnet_profit = fields.FloatField(null=True, default=0, description='扣非净利润增长率', )
|
||
id = fields.IntField(pk=True, )
|
||
market_indicator = fields.FloatField(null=True, default=0, description='行情指标', )
|
||
market_sector = fields.CharField(max_length=20, null=True, description='所属市场', )
|
||
profit_asset_value = fields.FloatField(null=True, default=0, description='净资产收益率', )
|
||
profit_business_increase = fields.FloatField(null=True, default=0, description='营业收入增长率', )
|
||
profit_dividend_rate = fields.FloatField(null=True, default=0, description='股息率', )
|
||
profit_gross_rate = fields.FloatField(null=True, default=0, description='销售毛利率', )
|
||
profit_sale_ratio = fields.FloatField(null=True, default=0, description='盈利销售净利率', )
|
||
stock_code = fields.CharField(max_length=50, null=True, description='股票代码', )
|
||
stock_name = fields.CharField(max_length=50, null=True, description='股票名称', )
|
||
stock_sector = fields.JSONField(null=True, description='股票板块', )
|
||
stock_type = fields.JSONField(null=True, description='股票类型', )
|
||
time_end = fields.CharField(max_length=10, null=True, description='上一次回测结束时间', )
|
||
time_expire = fields.CharField(max_length=10, null=True, description='退市时间', )
|
||
time_start = fields.CharField(max_length=10, null=True, description='上市时间', )
|
||
valuation_market_percentile = fields.FloatField(null=True, default=0, description='市现率百分比', )
|
||
valuation_market_TTM = fields.FloatField(null=True, default=0, description='市现率TTM', )
|
||
valuation_PB_percentile = fields.FloatField(null=True, default=0, description='市净率百分比', )
|
||
valuation_PB_TTM = fields.FloatField(null=True, default=0, description='市净率TTM', )
|
||
valuation_PEG_percentile = fields.FloatField(null=True, default=0, description='市盈率百分位', )
|
||
valuation_PEGTTM_ratio = fields.FloatField(null=True, default=0, description='市盈率TTM', )
|
||
valuation_PTS_percentile = fields.FloatField(null=True, default=0, description='市销率百分位', )
|
||
valuation_PTS_TTM = fields.FloatField(null=True, default=0, description='市销率TTM', )
|
||
|
||
|
||
class WanceDataStorageBacktest(Model):
|
||
avg_down_month = fields.FloatField(null=True, default=0, description='回测期间每个月下跌时的平均损失', )
|
||
avg_drawdown = fields.FloatField(null=True, default=0, description='平均回撤,表示每次回撤的平均幅度', )
|
||
avg_drawdown_days = fields.FloatField(null=True, default=0, description='平均回撤持续的天数', )
|
||
avg_up_month = fields.FloatField(null=True, default=0, description='回测期间每个月上涨时的平均收益', )
|
||
backtest_end_time = fields.IntField(description='回测结束时间', )
|
||
backtest_name = fields.CharField(max_length=100, null=True, )
|
||
best_day = fields.FloatField(null=True, default=0, description='回测期间单日的最大回报', )
|
||
best_month = fields.FloatField(null=True, default=0, description='回测期间的最佳月份回报', )
|
||
best_year = fields.FloatField(null=True, default=0, description='回测期间的最佳年度回报(若为空,表示回测不足一年)', )
|
||
cagr = fields.FloatField(null=True, default=0, description='年化复合增长率,表示投资在整个回测期间的年均增长率', )
|
||
calmar = fields.FloatField(null=True, default=0, description='Calmar 比率,表示年化收益率与最大回撤的比率,用于衡量风险调整后的收益。Calmar 比率越高,意味着风险调整后的表现越好', )
|
||
daily_kurt = fields.FloatField(null=True, default=0, description='每日回报的峰度,表示回报分布的尖锐程度', )
|
||
daily_mean = fields.FloatField(null=True, default=0, description='每日的平均回报率', )
|
||
daily_price = fields.JSONField(null=True, description='每日的价格', )
|
||
daily_sharpe = fields.FloatField(null=True, default=0, description='日频率的夏普比率,表示每单位风险所获得的超额收益', )
|
||
daily_skew = fields.FloatField(null=True, default=0, description='每日回报的偏度,表示回报分布的对称性', )
|
||
daily_sortino = fields.FloatField(null=True, default=0, description='日频率的 Sortino 比率,衡量投资组合的下行风险,考虑的是负波动率', )
|
||
daily_vol = fields.FloatField(null=True, default=0, description='每日回报率的标准差(波动率),表示收益的波动性', )
|
||
data_end_time = fields.CharField(max_length=10, null=True, description='回测数据结束时间', )
|
||
data_start_time = fields.CharField(max_length=10, null=True, description='回测数据开始时间', )
|
||
five_year = fields.FloatField(null=True, default=0, description='过去五年的回报', )
|
||
id = fields.IntField(pk=True, )
|
||
incep = fields.FloatField(null=True, default=0, description='自策略开始运行以来的年化回报率(如果策略没有完整的一年,则等于 cagr)', )
|
||
indicator_information = fields.JSONField(null=True, description='指标信息', )
|
||
indicator_type = fields.CharField(max_length=20, null=True, description='指标类型', )
|
||
max_drawdown = fields.FloatField(null=True, default=0, description='最大回撤,表示投资组合在回测期间从最高点到最低点的最大亏损百分比', )
|
||
monthly_kurt = fields.FloatField(null=True, default=0, description='月度回报的峰度', )
|
||
monthly_mean = fields.FloatField(null=True, default=0, description='月度平均回报率', )
|
||
monthly_sharpe = fields.FloatField(null=True, default=0, description='月频率的夏普比率', )
|
||
monthly_skew = fields.FloatField(null=True, default=0, description='月度回报的偏度', )
|
||
monthly_sortino = fields.FloatField(null=True, default=0, description='月频率的 Sortino 比率', )
|
||
monthly_vol = fields.FloatField(null=True, default=0, description='月度回报率的标准差(波动率)', )
|
||
mtd = fields.FloatField(null=True, default=0, description='月内截至目前的回报', )
|
||
one_year = fields.FloatField(null=True, default=0, description='的回报', )
|
||
position = fields.JSONField(null=True, description='持仓记录', )
|
||
price = fields.JSONField(null=True, description='每日的余额', )
|
||
returns = fields.JSONField(null=True, description='每日的回报率', )
|
||
rf = fields.FloatField(null=True, default=0, description='无风险收益率,通常用来计算夏普比率等指标,通常为0表示忽略无风险收益', )
|
||
six_month = fields.FloatField(null=True, default=0, description='过去六个月的回报(如果为空,表示无相关数据', )
|
||
stock_close_price = fields.JSONField(null=True, description='股票收盘价', )
|
||
stock_code = fields.CharField(max_length=20, null=True, )
|
||
strategy_name = fields.CharField(max_length=50, null=True, description='回测的策略名称', )
|
||
ten_year = fields.IntField(description='过去十年的回报', )
|
||
three_month = fields.FloatField(null=True, default=0, description='过去三个月的回报', )
|
||
three_year = fields.FloatField(null=True, default=0, description='过去三年的回报', )
|
||
total_return = fields.FloatField(null=True, default=0, description='总回报率', )
|
||
twelve_month_win_perc = fields.FloatField(null=True, default=0, description='过去12个月的胜率,表示在过去12个月中有多少月的回报为正', )
|
||
win_year_perc = fields.FloatField(null=True, default=0, description='策略年度胜率,表示回测期间策略表现优于无风险收益率的年份百分比', )
|
||
worst_day = fields.FloatField(null=True, default=0, description='回测期间单日的最差回报', )
|
||
worst_month = fields.FloatField(null=True, default=0, description='回测期间的最差月份回报', )
|
||
worst_year = fields.FloatField(null=True, default=0, description='回测期间的最差年度回报(若为空,表示回测不足一年)', )
|
||
yearly_kurt = fields.FloatField(null=True, default=0, description='年度的峰度', )
|
||
yearly_mean = fields.FloatField(null=True, default=0, description='年度的平均回报', )
|
||
yearly_sharpe = fields.FloatField(null=True, default=0, description='年度的夏普比率', )
|
||
yearly_skew = fields.FloatField(null=True, default=0, description='年度的偏度', )
|
||
yearly_sortino = fields.FloatField(null=True, default=0, description='年度的Sortino 比率', )
|
||
yearly_vol = fields.FloatField(null=True, default=0, description='年度的波动率', )
|
||
ytd = fields.FloatField(null=True, default=0, description='年初至今的回报', )
|