app.backbone.entities.bot
1from sqlalchemy import Column, ForeignKey, Integer, Float, String 2from . import Base 3from sqlalchemy.orm import relationship 4 5# Clase que representa una tabla en la base de datos 6class Bot(Base): 7 __tablename__ = 'Bots' # Nombre de la tabla en la BD 8 9 Id = Column(Integer, primary_key=True, autoincrement=True) 10 StrategyId = Column(Integer, ForeignKey('Strategies.Id')) 11 TickerId = Column(Integer, ForeignKey('Tickers.Id')) 12 TimeframeId = Column(Integer, ForeignKey('Timeframes.Id')) 13 Name = Column(String, nullable=False) 14 Risk = Column(Float, nullable=False) 15 16 Strategy = relationship('Strategy', back_populates='Bot', lazy='joined') 17 Ticker = relationship('Ticker', back_populates='Bot', lazy='joined') 18 Timeframe = relationship('Timeframe', back_populates='Bot', lazy='joined') 19 BotPerformance = relationship('BotPerformance', back_populates='Bot', lazy='joined') 20 21 22 def __repr__(self): 23 return f"<Bot(id={self.Id}, strategy_name='{self.Strategy.Id}'>" 24
class
Bot(sqlalchemy.orm.decl_api._DynamicAttributesType, sqlalchemy.inspection.Inspectable[sqlalchemy.orm.mapper.Mapper[typing.Any]]):
7class Bot(Base): 8 __tablename__ = 'Bots' # Nombre de la tabla en la BD 9 10 Id = Column(Integer, primary_key=True, autoincrement=True) 11 StrategyId = Column(Integer, ForeignKey('Strategies.Id')) 12 TickerId = Column(Integer, ForeignKey('Tickers.Id')) 13 TimeframeId = Column(Integer, ForeignKey('Timeframes.Id')) 14 Name = Column(String, nullable=False) 15 Risk = Column(Float, nullable=False) 16 17 Strategy = relationship('Strategy', back_populates='Bot', lazy='joined') 18 Ticker = relationship('Ticker', back_populates='Bot', lazy='joined') 19 Timeframe = relationship('Timeframe', back_populates='Bot', lazy='joined') 20 BotPerformance = relationship('BotPerformance', back_populates='Bot', lazy='joined') 21 22 23 def __repr__(self): 24 return f"<Bot(id={self.Id}, strategy_name='{self.Strategy.Id}'>"
The base class of the class hierarchy.
When called, it accepts no arguments and returns a new featureless instance that has no instance attributes and cannot be given any.
Bot(**kwargs)
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and
values in kwargs
.
Only keys that are present as attributes of the instance's class are allowed. These could be, for example, any mapped columns or relationships.