How to use the mongoengine.FloatField function in mongoengine

To help you get started, we’ve selected a few mongoengine 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 dchaplinsky / unshred-tag / models / shreds.py View on Github external
StringField, IntField, DateTimeField, ListField, BooleanField,
    ReferenceField, EmbeddedDocument, EmbeddedDocumentField, FloatField,
    CASCADE, QuerySet)
from flask_mongoengine import Document

from .user import User


class Features(EmbeddedDocument):
    histogram_clean = ListField(IntField())
    height_mm = FloatField(required=True)
    histogram_full = ListField(IntField())
    width_mm = FloatField(required=True)
    area = IntField(required=True)
    dominant_colours = ListField(StringField())
    solidity = FloatField(required=True)
    colour_names = ListField(StringField())
    ratio = FloatField(required=True)
    width = IntField(required=True)
    height = IntField(required=True)


class ShredTags(EmbeddedDocument):
    user = ReferenceField(User)
    tags = ListField(StringField())
    recognizable_chars = StringField()
    angle = IntField(default=0)
    pages = ListField(ReferenceField("Pages"))


# Immutable once imported from CV.
class Shred(Document):
github UWFlow / rmc / models / rating.py View on Github external
import json
import logging

import mongoengine as me

import rmc.shared.util as util


class AggregateRating(me.EmbeddedDocument):
    rating = me.FloatField(min_value=0.0, max_value=1.0, default=0.0)
    count = me.IntField(min_value=0, default=0)
    sorting_score_positive = me.FloatField(
        min_value=0.0, max_value=1.0, default=0.0)
    sorting_score_negative = me.FloatField(
        min_value=0.0, max_value=1.0, default=0.0)

    def debug_logging(self, func_name):
        # TODO(Sandy): Temporary debugging for over 100% average rating bug
        if self.rating > 1:
            logging.warn(
                "%s: update_sorting_score will fail" % (func_name) +
                " self.count=%s self.rating=%s" % (self.count, self.rating)
            )

    @property
    def num_approves(self):
        """Returns the number of users who selected "yes" for this rating."""
        return int(round(self.rating * self.count))
github DurianStallSingapore / Zilliqa-Mining-Proxy / zilpool / database / zilnode.py View on Github external
import mongoengine as mg
from mongoengine import Q

from .basemodel import ModelMixin


class ZilNodeOwner(ModelMixin, mg.Document):
    meta = {"collection": "zil_nodes_owner", "strict": False}

    email = mg.StringField(max_length=128, required=True, unique=True)
    password_hash = mg.StringField(max_length=128)
    email_verified = mg.BooleanField(default=False)
    join_date = mg.DateTimeField()

    pow_fee = mg.FloatField(default=0.0)
    balance = mg.FloatField(default=0.0)

    pending_nodes = mg.ListField()

    @classmethod
    def create(cls, email):
        return cls(email=email, email_verified=False,
                   pow_fee=0.0, balance=0.0,
                   join_date=datetime.utcnow(),
                   pending_nodes=[]).save()

    def register_node(self, pub_key):
        node = ZilNode.get_by_pub_key(pub_key, authorized=None)
        if not node:
            node = ZilNode(pub_key=pub_key, authorized=False,
                           email=self.email, pow_fee=self.pow_fee)
            node.save()
github kingofhawks / stocktrace / portfolio / models.py View on Github external
# 期权账户本金
    cost_option = FloatField(default=7000+3000+5000+5000+10000)
    # ZS账户当年(真实)本金
    cost_zs = FloatField(default=463000+4000+10000+15000+8000)
    # 融资利息江苏银行(2018年7月至2019年1月1日)
    js_interest = FloatField(default=2600+735+830)
    # 券商融资+江苏银行
    financing = FloatField(default=170710 + 160000)
    # HT1账户当年资金变动(老婆)
    ht1_changes = 17000 + 5000 + 5000 + 20000 + 20000
    # HT2账户当年资金变动(老妈)
    ht2_changes = 20000
    cost_ht1 = FloatField()
    cost_ht2 = FloatField()
    cost_ht1_real = FloatField()
    cost_ht2_real = FloatField()
    position_ratio = FloatField()
    lever = FloatField()
    cash = FloatField()
    profit = FloatField()
    profit_ratio = FloatField()
    profit_today = FloatField()
    profit_ratio_today = FloatField()

    def compute(self):
        # HT1账户当年本金
        self.cost_ht1 = 277461+self.ht1_changes
        # HT1账户真实本金
        self.cost_ht1_real = 226000+self.ht1_changes
        # HT2账户当年本金
        self.cost_ht2 = 218579+self.ht2_changes
        # HT2账户真实本金
github mushfiq / rssi-system / RESTApi / restApp / documents.py View on Github external
class mapRecords(InheritableDocument):
    """ mapRecords document is extended from InheritableDocument
        it holds the fields for mapRecords collection for mongoDB."""
        
    height = FloatField()
    image = FileField()
    mapId = IntField()
    offsetX = IntField()
    offsetY = IntField()
    offset2X = IntField()
    offset2Y = IntField()
    receiverId = IntField()
    scalingX = FloatField()
    scalingY = FloatField()
    updateTime = DateTimeField()
    width = FloatField()
    title = StringField()
    
    
class receiverRecords(InheritableDocument):
    """ receiverRecords document is extended from InheritableDocument
        it holds the fields for receiverRecords collection for mongoDB."""
        
    receiverId = IntField()
    mapId = IntField()
    x = FloatField()
    y = FloatField()
    angle = FloatField()
github physercoe / starquant / source / data / database_mongo.py View on Github external
"""

    symbol: str = StringField()
    exchange: str = StringField()
    datetime: datetime = DateTimeField()

    name: str = StringField()
    volume: float = FloatField()
    open_interest: float = FloatField()
    last_price: float = FloatField()
    last_volume: float = FloatField()
    limit_up: float = FloatField()
    limit_down: float = FloatField()

    open_price: float = FloatField()
    high_price: float = FloatField()
    low_price: float = FloatField()
    close_price: float = FloatField()
    pre_close: float = FloatField()

    bid_price_1: float = FloatField()
    bid_price_2: float = FloatField()
    bid_price_3: float = FloatField()
    bid_price_4: float = FloatField()
    bid_price_5: float = FloatField()

    ask_price_1: float = FloatField()
    ask_price_2: float = FloatField()
    ask_price_3: float = FloatField()
    ask_price_4: float = FloatField()
    ask_price_5: float = FloatField()
github physercoe / starquant / source / data / database_mongo.py View on Github external
symbol: str = StringField()
    exchange: str = StringField()
    datetime: datetime = DateTimeField()

    name: str = StringField()
    volume: float = FloatField()
    open_interest: float = FloatField()
    last_price: float = FloatField()
    last_volume: float = FloatField()
    limit_up: float = FloatField()
    limit_down: float = FloatField()

    open_price: float = FloatField()
    high_price: float = FloatField()
    low_price: float = FloatField()
    close_price: float = FloatField()
    pre_close: float = FloatField()

    bid_price_1: float = FloatField()
    bid_price_2: float = FloatField()
    bid_price_3: float = FloatField()
    bid_price_4: float = FloatField()
    bid_price_5: float = FloatField()

    ask_price_1: float = FloatField()
    ask_price_2: float = FloatField()
    ask_price_3: float = FloatField()
    ask_price_4: float = FloatField()
    ask_price_5: float = FloatField()

    bid_volume_1: float = FloatField()
github physercoe / starquant / source / data / database_mongo.py View on Github external
limit_down: float = FloatField()

    open_price: float = FloatField()
    high_price: float = FloatField()
    low_price: float = FloatField()
    close_price: float = FloatField()
    pre_close: float = FloatField()

    bid_price_1: float = FloatField()
    bid_price_2: float = FloatField()
    bid_price_3: float = FloatField()
    bid_price_4: float = FloatField()
    bid_price_5: float = FloatField()

    ask_price_1: float = FloatField()
    ask_price_2: float = FloatField()
    ask_price_3: float = FloatField()
    ask_price_4: float = FloatField()
    ask_price_5: float = FloatField()

    bid_volume_1: float = FloatField()
    bid_volume_2: float = FloatField()
    bid_volume_3: float = FloatField()
    bid_volume_4: float = FloatField()
    bid_volume_5: float = FloatField()

    ask_volume_1: float = FloatField()
    ask_volume_2: float = FloatField()
    ask_volume_3: float = FloatField()
    ask_volume_4: float = FloatField()
    ask_volume_5: float = FloatField()
github davidwilemski / openrunlog / openrunlog / models.py View on Github external
return '/g/{}'.format(self.url)

    def fetch_feed(self):
        feed = models.Run.objects(user__in=mrun.members)[:10]
        return feed


class Race(mongoengine.Document):
    """
    Stores info about a race that a user runs
    """
    user = mongoengine.ReferenceField(User)
    name = mongoengine.StringField(required=True)
    notes = mongoengine.StringField(default='')
    date = mongoengine.DateTimeField(required=True)
    distance = mongoengine.FloatField(default=0)
    distance_units = mongoengine.StringField(default='miles')
    time = mongoengine.IntField(default=0)  # in seconds

    @property
    def pretty_notes(self):
        return escape.xhtml_escape(self.notes).replace('\n', '<br>')

    @property
    def pretty_time(self):
        return seconds_to_time(self.time)

    @property
    def uri(self):
        return '{}/races/{}'.format(self.user.uri, str(self.id))
github DurianStallSingapore / Zilliqa-Mining-Proxy / zilpool / database / pow.py View on Github external
from . import miner
from .basemodel import ModelMixin


class PoWWindow(ModelMixin, mg.Document):
    meta = {"collection": "zil_pow_windows", "strict": False}

    create_time = mg.DateTimeField()
    block_num = mg.IntField(required=True)
    estimated_next_pow = mg.DateTimeField()

    pow_start = mg.DateTimeField(default=datetime.utcnow)
    pow_end = mg.DateTimeField(default=datetime.utcnow)
    pow_window = mg.FloatField(default=0)
    epoch_window = mg.FloatField(default=0)

    @classmethod
    def get_latest_record(cls):
        return cls.objects().order_by("-create_time").first()

    @classmethod
    def get_latest_block_num(cls):
        latest_record = cls.get_latest_record()
        if not latest_record:
            return -1
        return latest_record.block_num

    @classmethod
    def get_pow_window(cls, block_num=None):
        record = cls.objects(block_num=block_num).order_by("-create_time").first()
        if not record: