from rest_framework import serializers


class StockDailySerializer(serializers.Serializer):
    """日线行情（stockbasic）"""
    ts_code = serializers.CharField()
    trade_date = serializers.CharField()
    open = serializers.FloatField()
    high = serializers.FloatField()
    low = serializers.FloatField()
    close = serializers.FloatField()
    pre_close = serializers.FloatField()
    change = serializers.FloatField()
    pct_chg = serializers.FloatField()
    vol = serializers.FloatField()
    amount = serializers.FloatField()


class StockInfoSerializer(serializers.Serializer):
    """个股基本信息（stockinfo）"""
    ts_code = serializers.CharField()
    symbol = serializers.CharField()
    name = serializers.CharField()
    area = serializers.CharField()
    industry = serializers.CharField()
    market = serializers.CharField()
    list_date = serializers.CharField()
    fullname = serializers.CharField()
    enname = serializers.CharField()
    exchange = serializers.CharField()
    curr_type = serializers.CharField()
    list_status = serializers.CharField()
    is_hs = serializers.CharField()


class IndustryStockSerializer(serializers.Serializer):
    """行业股票列表（industrys）"""
    ts_code = serializers.CharField()
    name = serializers.CharField()


class StockParamSerializer(serializers.Serializer):
    """个股参数（stockparam）"""
    ts_code = serializers.CharField()
    trade_date = serializers.CharField()
    close = serializers.FloatField()
    turnover_rate = serializers.FloatField()
    turnover_rate_f = serializers.FloatField()
    volume_ratio = serializers.FloatField()
    pe = serializers.FloatField()
    pe_ttm = serializers.FloatField()
    pb = serializers.FloatField()
    ps = serializers.FloatField()
    ps_ttm = serializers.FloatField()
    dv_ratio = serializers.FloatField()
    dv_ttm = serializers.FloatField()
    total_share = serializers.FloatField()
    float_share = serializers.FloatField()
    free_share = serializers.FloatField()
    total_mv = serializers.FloatField()
    circ_mv = serializers.FloatField()


class StockEpSerializer(serializers.Serializer):
    """TTM EPS（stockep）"""
    ts_code = serializers.CharField()
    trade_date = serializers.CharField()
    eps_ttm = serializers.FloatField()


class QuarterlyEpsSerializer(serializers.Serializer):
    """季度 EPS（quarterlyEps）"""
    ts_code = serializers.CharField()
    trade_date = serializers.CharField()
    eps = serializers.FloatField()
    report_date = serializers.CharField()


class IndexInfoSerializer(serializers.Serializer):
    """指数信息（indexByName）"""
    index_code = serializers.CharField()
    name = serializers.CharField()
    fullname = serializers.CharField()
    market = serializers.CharField()
    publisher = serializers.CharField()
    index_type = serializers.CharField()
    category = serializers.CharField()
    list_date = serializers.CharField()


class IndexDailySerializer(serializers.Serializer):
    """指数日行情（indexDatas）"""
    ts_code = serializers.CharField()
    trade_date = serializers.CharField()
    close = serializers.FloatField()
    open = serializers.FloatField()
    high = serializers.FloatField()
    low = serializers.FloatField()
    pre_close = serializers.FloatField()
    change = serializers.FloatField()
    pct_chg = serializers.FloatField()
    vol = serializers.FloatField()
    amount = serializers.FloatField()


class MarginDailySerializer(serializers.Serializer):
    """每日融资融券汇总（dailyMargin）"""
    trade_date = serializers.CharField()
    exchange_id = serializers.CharField()
    rzye = serializers.FloatField()
    rqye = serializers.FloatField()
    rzrqye = serializers.FloatField()


class StockMarginSerializer(serializers.Serializer):
    """个股融资融券（stockMargin）"""
    ts_code = serializers.CharField()
    trade_date = serializers.CharField()
    rzye = serializers.FloatField()
    rqye = serializers.FloatField()
    rzrqye = serializers.FloatField()


class FinanceDataSerializer(serializers.Serializer):
    """财务报表分析（finance）"""
    ts_code = serializers.CharField()
    period = serializers.CharField()


class DividendSerializer(serializers.Serializer):
    """股息率（getdiv）"""
    ts_code = serializers.CharField()
    trade_date = serializers.CharField()
    close = serializers.FloatField()
    cash_div_tax = serializers.FloatField()
    cash_div_year = serializers.FloatField()
    div_yield = serializers.FloatField()


class XwlbNewsSerializer(serializers.Serializer):
    """新闻联播（xwlbNews / xwlbFine）"""
    news_days = serializers.CharField()
    daily_sub_id = serializers.IntegerField()
    news_improve = serializers.CharField()
    news_title = serializers.CharField()
