class BacktestSignalResult(MongoModel): """OHLCV + signal + pos""" candle_begin_time = fields.DateTimeField(primary_key=True) open_price = fields.Decimal128Field(mongo_name='open') high_price = fields.Decimal128Field(mongo_name='high') low_price = fields.Decimal128Field(mongo_name='low') close_price = fields.Decimal128Field(mongo_name='close') volume = fields.Decimal128Field() signal = fields.FloatField() pos = fields.FloatField() class Meta: connection_alias = DB_BACKTEST_SIGNAL codec_options = CodecOptions(tz_aware=True) @classmethod def bulk_upsert_records(cls, json_list, key_name='_id'): """Bulk upsert candle records""" coll = cls._mongometa.collection bulkOp = coll.initialize_unordered_bulk_op() for doc in json_list: if isinstance(key_name, list): filter_dict = dict(map(lambda k: (k, doc[k]), key_name)) else: filter_dict = {key_name: doc[key_name]} doc['_cls'] = cls.__module__ + '.' + cls.__name__ bulkOp.find(filter_dict).upsert().update({'$set': doc}) results = bulkOp.execute() return results
class Station(MongoModel): code = fields.CharField(max_length=50) name = fields.CharField(max_length=100) lat = fields.Decimal128Field() lng = fields.Decimal128Field() objects = DefaultManager() class Meta: collection_name = 'Station' final = True
class CTRickshaw(MongoModel): name = fields.CharField(max_length=100) rickshawNumber = fields.CharField(max_length=100) lat = fields.Decimal128Field() lng = fields.Decimal128Field() objects = DefaultManager() class Meta: collection_name = 'CTRickshaw' final = True
class MatchRatioInfo(EmbeddedMongoModel): Type = fields.CharField(required=True, blank=False) Rate = fields.Decimal128Field() RateName = fields.CharField(required=True, blank=False) WebSiteMatchId = fields.CharField() CreateTime = fields.DateTimeField(required=True, blank=False) #MatchInfo = fields.ReferenceField(MatchInfo, required=True) # Verileri yazdırmak için kullanılan fonksiyon @property def print(self): print("Tipi : " + str(self.Type)) print("Oran Adı : " + str(self.Name)) print("Oran : " + str(self.Rate)) print("Oluşturulma Zamanı : " + str(self.CreateTime))