How to use the peewee.DecimalField function in peewee

To help you get started, we’ve selected a few peewee examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github andrersp / controleEstoque / controle_estoque / CrudPeewee / Conexao.py View on Github external
valor_pendente = DecimalField(9, 2)
    entrega = ForeignKeyField(
        StatusEntrega, column_name='entrega', default='2')
    pagamento = ForeignKeyField(
        StatusPagamento, column_name='pagamento', default='2')

    class Meta:
        db_table = 'venda'


# Tabela relação de item comprados (carrinho de compra)
class RelacaoVenda(BaseModel):
    id = CharField(max_length=25, primary_key=True)
    id_venda = ForeignKeyField(Venda, column_name='id_venda')
    id_produto = ForeignKeyField(Produto, column_name='id_produto')
    qtde = DecimalField(9, 2)
    valor_unitario = DecimalField(9, 2)
    valor_total = DecimalField(9, 2)
    obs = CharField(max_length=80)

    class Meta:
        db_table = 'relacao_venda'


# Tabela Contas a Pagar
class ContaAPagar(BaseModel):
    id = PrimaryKeyField(null=False)
    id_compra = ForeignKeyField(Compra, column_name='id_compra', null=True)
    id_fornecedor = ForeignKeyField(Fornecedor, column_name='id_fornecedor')
    descricao = CharField(max_length=150)
    obs = CharField(max_length=150)
    categoria = ForeignKeyField(CatAPagar, column_name='categoria')
github TalaikisInc / blueblood / app / db / alphas.py View on Github external
class Alpha(BaseModel):
    name = CharField(unique=True)
    owner = ForeignKeyField(AlphaOwner, backref='alpha_models')

class Strategy(BaseModel):
    rule = SmallIntegerField()
    param = SmallIntegerField()
    alpha = ForeignKeyField(Alpha, backref='strategies')

class Stats(BaseModel):
    strategy = ForeignKeyField(Strategy, backref='stats')
    max_dd = DecimalField(decimal_places=2, auto_round=True, default=0)
    beta = DecimalField(decimal_places=2, auto_round=True, default=0)
    vol = DecimalField(decimal_places=2, auto_round=True, default=0)
    treynor = DecimalField(decimal_places=2, auto_round=True, default=0)
    sharpe_ratio = DecimalField(decimal_places=2, auto_round=True, default=0)
    ir = DecimalField(decimal_places=2, auto_round=True, default=0)
    modigliani = DecimalField(decimal_places=2, auto_round=True, default=0)
    var = DecimalField(decimal_places=2, auto_round=True, default=0)
    cvar = DecimalField(decimal_places=2, auto_round=True, default=0)
    excess_var = DecimalField(decimal_places=2, auto_round=True, default=0)
    conditional_sharpe = DecimalField(decimal_places=2, auto_round=True, default=0)
    omega_ratio = DecimalField(decimal_places=2, auto_round=True, default=0)
    sortino = DecimalField(decimal_places=2, auto_round=True, default=0)
    kappa_three = DecimalField(decimal_places=2, auto_round=True, default=0)
    gain_loss = DecimalField(decimal_places=2, auto_round=True, default=0)
    upside_potential = DecimalField(decimal_places=2, auto_round=True, default=0)
    calmar = DecimalField(decimal_places=2, auto_round=True, default=0)
    average_dd = DecimalField(decimal_places=2, auto_round=True, default=0)
    average_dd_squared = DecimalField(decimal_places=2, auto_round=True, default=0)
    sterling_ration = DecimalField(decimal_places=2, auto_round=True, default=0)
    burke_ratio = DecimalField(decimal_places=2, auto_round=True, default=0)
github andrersp / controleEstoque / controle_estoque / CrudPeewee / Conexao.py View on Github external
status_entrega = CharField(max_length=80)

    class Meta:
        db_table = 'status_entrega'


# Tabela Compras
class Compra(BaseModel):
    id = PrimaryKeyField(null=False)
    id_fornecedor = ForeignKeyField(Fornecedor, column_name='id_fornecedor')
    data_emissao = DateField()
    prazo_entrega = DateField()
    data_entrega = DateField()
    categoria = ForeignKeyField(CatAPagar, column_name='categoria')
    desconto = DecimalField(9, 2)
    frete = DecimalField(9, 2)
    valor_total = DecimalField(9, 2)
    valor_pago = DecimalField(9, 2)
    valor_pendente = DecimalField(9, 2)
    entrega = ForeignKeyField(
        StatusEntrega, column_name='entrega', default='2')
    pagamento = ForeignKeyField(
        StatusPagamento, column_name='pagamento', default='2')

    class Meta:
        db_table = 'compra'


# Tabela relação de item comprados (carrinho de compra)
class RelacaoCompra(BaseModel):
    id = CharField(max_length=25, primary_key=True)
    id_compra = ForeignKeyField(Compra, column_name='id_compra')
github andrersp / controleEstoque / controle_estoque / CrudPeewee / Models.py View on Github external
# Tabela Vendas
class Venda(BaseModel):
    id = PrimaryKeyField(null=False)
    id_cliente = ForeignKeyField(
        Cliente, column_name='id_cliente')
    data_emissao = DateField()
    prazo_entrega = DateField()
    data_entrega = DateField()
    categoria = ForeignKeyField(
        CatAReceber, column_name='categoria')
    desconto = DecimalField(9, 2)
    frete = DecimalField(9, 2)
    valor_total = DecimalField(9, 2)
    valor_recebido = DecimalField(9, 2)
    valor_pendente = DecimalField(9, 2)
    entrega = ForeignKeyField(
        StatusEntrega, column_name='entrega', default='2')
    pagamento = ForeignKeyField(
        StatusPagamento, column_name='pagamento', default='2')

    class Meta:
        db_table = 'venda'


# Tabela relação de item comprados (carrinho de compra)
class RelacaoVenda(BaseModel):
    id = CharField(max_length=25, primary_key=True)
    id_venda = ForeignKeyField(Venda, column_name='id_venda')
    id_produto = ForeignKeyField(Produto, column_name='id_produto')
    qtde = DecimalField(9, 2)
    valor_unitario = DecimalField(9, 2)
github TalaikisInc / blueblood / app / db / alphas.py View on Github external
monthly_vol = DecimalField(decimal_places=2, auto_round=True, default=0)
    monthly_skew = DecimalField(decimal_places=2, auto_round=True, default=0)
    monthly_kurt = DecimalField(decimal_places=2, auto_round=True, default=0)
    best_month = DecimalField(decimal_places=2, auto_round=True, default=0)
    worst_month = DecimalField(decimal_places=2, auto_round=True, default=0)
    yearly_sharpe = DecimalField(decimal_places=2, auto_round=True, default=0)
    yearly_mean = DecimalField(decimal_places=2, auto_round=True, default=0)
    yearly_vol = DecimalField(decimal_places=2, auto_round=True, default=0)
    yearly_skew = DecimalField(decimal_places=2, auto_round=True, default=0)
    yearly_kurt = DecimalField(decimal_places=2, auto_round=True, default=0)
    worst_year = DecimalField(decimal_places=2, auto_round=True, default=0)
    avg_drawdown_days = DecimalField(decimal_places=2, auto_round=True, default=0)
    avg_up_month = DecimalField(decimal_places=2, auto_round=True, default=0)
    avg_down_month = DecimalField(decimal_places=2, auto_round=True, default=0)
    win_year_perc = DecimalField(decimal_places=2, auto_round=True, default=0)
    twelve_month_win_perc = DecimalField(decimal_places=2, auto_round=True, default=0)
    capital_utilization = JSONField()
    rolling_sharpe = JSONField()
    returns_by_month = JSONField()
    returns_by_year = JSONField()
    percentiles = JSONField()
    drawdown_probability = JSONField()
    return_probability = JSONField()
github TalaikisInc / blueblood / app / db / alphas.py View on Github external
class Stats(BaseModel):
    strategy = ForeignKeyField(Strategy, backref='stats')
    max_dd = DecimalField(decimal_places=2, auto_round=True, default=0)
    beta = DecimalField(decimal_places=2, auto_round=True, default=0)
    vol = DecimalField(decimal_places=2, auto_round=True, default=0)
    treynor = DecimalField(decimal_places=2, auto_round=True, default=0)
    sharpe_ratio = DecimalField(decimal_places=2, auto_round=True, default=0)
    ir = DecimalField(decimal_places=2, auto_round=True, default=0)
    modigliani = DecimalField(decimal_places=2, auto_round=True, default=0)
    var = DecimalField(decimal_places=2, auto_round=True, default=0)
    cvar = DecimalField(decimal_places=2, auto_round=True, default=0)
    excess_var = DecimalField(decimal_places=2, auto_round=True, default=0)
    conditional_sharpe = DecimalField(decimal_places=2, auto_round=True, default=0)
    omega_ratio = DecimalField(decimal_places=2, auto_round=True, default=0)
    sortino = DecimalField(decimal_places=2, auto_round=True, default=0)
    kappa_three = DecimalField(decimal_places=2, auto_round=True, default=0)
    gain_loss = DecimalField(decimal_places=2, auto_round=True, default=0)
    upside_potential = DecimalField(decimal_places=2, auto_round=True, default=0)
    calmar = DecimalField(decimal_places=2, auto_round=True, default=0)
    average_dd = DecimalField(decimal_places=2, auto_round=True, default=0)
    average_dd_squared = DecimalField(decimal_places=2, auto_round=True, default=0)
    sterling_ration = DecimalField(decimal_places=2, auto_round=True, default=0)
    burke_ratio = DecimalField(decimal_places=2, auto_round=True, default=0)
    average_month_return = DecimalField(decimal_places=2, auto_round=True, default=0)
    average_trades_month = DecimalField(decimal_places=2, auto_round=True, default=0)
    trade_count = DecimalField(decimal_places=2, auto_round=True, default=0)
    alpha = DecimalField(decimal_places=2, auto_round=True, default=0)
    average_trade = DecimalField(decimal_places=2, auto_round=True, default=0)
    average_win = DecimalField(decimal_places=2, auto_round=True, default=0)
    average_loss = DecimalField(decimal_places=2, auto_round=True, default=0)
    total_wins = DecimalField(decimal_places=2, auto_round=True, default=0)
github coleifer / wtf-peewee / wtfpeewee / orm.py View on Github external
# Subclasses of other fields.
        (IPField, f.StringField),  # Subclass of BigIntegerField.
        (TimestampField, WPDateTimeField),  # Subclass of BigIntegerField.
        (AutoField, f.HiddenField),
        (BigIntegerField, f.IntegerField),
        (DoubleField, f.FloatField),
        (SmallIntegerField, f.IntegerField),

        # Base-classes.
        (BareField, f.StringField),
        (BlobField, f.TextAreaField),
        (BooleanField, f.BooleanField),
        (CharField, f.StringField),
        (DateField, WPDateField),
        (DateTimeField, WPDateTimeField),
        (DecimalField, f.DecimalField),
        (FloatField, f.FloatField),
        (IntegerField, f.IntegerField),
        (TextField, f.TextAreaField),
        (TimeField, WPTimeField),
        (UUIDField, f.StringField),
    ))
    coerce_defaults = {
        BigIntegerField: int,
        CharField: text_type,
        DoubleField: float,
        FloatField: float,
        IntegerField: int,
        SmallIntegerField: int,
        TextField: text_type,
        UUIDField: text_type,
    }
github dashpay / sentinel / lib / models.py View on Github external
value = CharField(default='')
    created_at = DateTimeField(default=datetime.datetime.utcnow())
    updated_at = DateTimeField(default=datetime.datetime.utcnow())

    class Meta:
        db_table = 'settings'


class Proposal(GovernanceClass, BaseModel):
    governance_object = ForeignKeyField(GovernanceObject, related_name='proposals', on_delete='CASCADE', on_update='CASCADE')
    name = CharField(default='', max_length=40)
    url = CharField(default='')
    start_epoch = IntegerField()
    end_epoch = IntegerField()
    payment_address = CharField(max_length=36)
    payment_amount = DecimalField(max_digits=16, decimal_places=8)
    object_hash = CharField(max_length=64)

    # src/governance-validators.cpp
    MAX_DATA_SIZE = 512

    govobj_type = DASHD_GOVOBJ_TYPES['proposal']

    class Meta:
        db_table = 'proposals'

    def is_valid(self):
        import dashlib

        printdbg("In Proposal#is_valid, for Proposal: %s" % self.__dict__)

        try:
github TalaikisInc / blueblood / app / db / alphas.py View on Github external
total_wins = DecimalField(decimal_places=2, auto_round=True, default=0)
    total_losses = DecimalField(decimal_places=2, auto_round=True, default=0)
    win_rate = DecimalField(decimal_places=2, auto_round=True, default=0)
    average_mae = DecimalField(decimal_places=2, auto_round=True, default=0)
    average_mfe = DecimalField(decimal_places=2, auto_round=True, default=0)
    max_mae = DecimalField(decimal_places=2, auto_round=True, default=0)
    min_mfe = DecimalField(decimal_places=2, auto_round=True, default=0)
    ulcer_index = DecimalField(decimal_places=2, auto_round=True, default=0)
    ulcer_performance_index = DecimalField(decimal_places=2, auto_round=True, default=0)
    max_dd_duration = DecimalField(decimal_places=2, auto_round=True, default=0)
    start = DateTimeField()
    end = DateTimeField()
    total_return = DecimalField(decimal_places=2, auto_round=True, default=0)
    daily_sharpe = DecimalField(decimal_places=2, auto_round=True, default=0)
    cagr = DecimalField(decimal_places=2, auto_round=True, default=0)
    mtd = DecimalField(decimal_places=2, auto_round=True, default=0)
    three_month = DecimalField(decimal_places=2, auto_round=True, default=0)
    six_month = DecimalField(decimal_places=2, auto_round=True, default=0)
    ytd = DecimalField(decimal_places=2, auto_round=True, default=0)
    three_year = DecimalField(decimal_places=2, auto_round=True, default=0)
    daily_mean = DecimalField(decimal_places=2, auto_round=True, default=0)
    daily_vol = DecimalField(decimal_places=2, auto_round=True, default=0)
    daily_skew = DecimalField(decimal_places=2, auto_round=True, default=0)
    daily_kurt = DecimalField(decimal_places=2, auto_round=True, default=0)
    best_day = DecimalField(decimal_places=2, auto_round=True, default=0)
    worst_day = DecimalField(decimal_places=2, auto_round=True, default=0)
    monthly_sharpe = DecimalField(decimal_places=2, auto_round=True, default=0)
    monthly_mean = DecimalField(decimal_places=2, auto_round=True, default=0)
    monthly_vol = DecimalField(decimal_places=2, auto_round=True, default=0)
    monthly_skew = DecimalField(decimal_places=2, auto_round=True, default=0)
    monthly_kurt = DecimalField(decimal_places=2, auto_round=True, default=0)
    best_month = DecimalField(decimal_places=2, auto_round=True, default=0)
github andrersp / controleEstoque / controle_estoque / CrudPeewee / Conexao.py View on Github external
class Meta:
        db_table = 'relacao_compra'


# Tabela Vendas
class Venda(BaseModel):
    id = PrimaryKeyField(null=False)
    id_cliente = ForeignKeyField(
        Cliente, column_name='id_cliente')
    data_emissao = DateField()
    prazo_entrega = DateField()
    data_entrega = DateField()
    categoria = ForeignKeyField(
        CatAReceber, column_name='categoria')
    desconto = DecimalField(9, 2)
    frete = DecimalField(9, 2)
    valor_total = DecimalField(9, 2)
    valor_recebido = DecimalField(9, 2)
    valor_pendente = DecimalField(9, 2)
    entrega = ForeignKeyField(
        StatusEntrega, column_name='entrega', default='2')
    pagamento = ForeignKeyField(
        StatusPagamento, column_name='pagamento', default='2')

    class Meta:
        db_table = 'venda'


# Tabela relação de item comprados (carrinho de compra)
class RelacaoVenda(BaseModel):
    id = CharField(max_length=25, primary_key=True)