示例#1
0
class CountryAllocation(Base):
    __tablename__ = "country_allocation"

    id = Column('ROWID', Integer, primary_key=True)
    instrument_id = Column('instrument', Integer, ForeignKey('instrument.id'))
    instrument = relationship("Instrument", backref='country_allocation')

    country_id = Column('country', Integer, ForeignKey('country.id'))
    country = relationship("Country")
    ratio = Column('ratio', Float)
示例#2
0
class AssetAllocation(Base):
    __tablename__ = "asset_allocation"

    id = Column('ROWID', Integer, primary_key=True)
    instrument_id = Column('instrument', Integer, ForeignKey('instrument.id'))
    instrument = relationship("Instrument", backref='asset_allocation')

    asset_id = Column('asset', Integer, ForeignKey('asset.id'))
    asset = relationship("Asset")
    ratio = Column('ratio', Float)
示例#3
0
class Cash(Base):
    __tablename__ = "cash"

    id = Column('ROWID', Integer, primary_key=True)
    currency_id = Column('ccy', Integer, ForeignKey('currency.id'))
    currency = relationship('Currency')

    broker_id = Column('broker', Integer, ForeignKey('broker.id'))
    broker = relationship("Broker")

    balance = Column(Float)
示例#4
0
class PortfolioAllocation(Base):
    __tablename__ = "portfolio_allocation"

    id = Column(Integer, primary_key=True)

    portfolio_id = Column('portfolio', Integer, ForeignKey('portfolio.id'))
    portfolio = relationship("Portfolio", backref='allocations')

    instrument_id = Column('instrument', Integer, ForeignKey('instrument.id'))
    instrument = relationship('Instrument')

    percentage = Column('percentage', Float)

    def __repr__(self):
        return "%s-%s" % (self.portfolio.name, self.instrument.name)
示例#5
0
class StockTransaction(Base):
    __tablename__ = "transaction"

    id = Column('ROWID', Integer, primary_key=True)
    instrument_id = Column('instrument', Integer, ForeignKey('instrument.id'))
    instrument = relationship("Instrument")

    broker_id = Column('broker', Integer, ForeignKey('broker.id'))
    broker = relationship("Broker")

    type = Column(String)

    price = Column(Float)
    shares = Column(Float)
    fee = Column(Float)
    date = Column(MyEpochType)
示例#6
0
class FundPerformance(Base):
    __tablename__ = "fund"

    id = Column('ROWID', Integer, primary_key=True)
    instrument_id = Column('instrument', Integer, ForeignKey('instrument.id'))
    instrument = relationship("Instrument")

    broker_id = Column('broker', Integer, ForeignKey('broker.id'))
    broker = relationship("Broker")

    amount = Column(Integer)
    price = Column(Float)
    value = Column(Float)
    capital = Column(Float)
    profit = Column(Float)
    date = Column(MyEpochType)
示例#7
0
class CountryByRegion(Base):
    __tablename__ = "regions"

    id = Column('ROWID', Integer, primary_key=True)

    country_id = Column('country', Integer, ForeignKey('country.id'))
    region_id = Column('region', Integer, ForeignKey('region.id'))

    country = relationship("Country",
                           foreign_keys=[country_id],
                           backref='regions')
    region = relationship("Region",
                          foreign_keys=[region_id],
                          backref='regions')

    def __repr__(self):
        return ("%s/%s") % (self.country, self.region)
示例#8
0
class Quote(Base):
    __tablename__ = "quote"

    id = Column('ROWID', Integer, primary_key=True)
    instrument_id = Column('instrument', Integer, ForeignKey('instrument.id'))
    instrument = relationship("Instrument")

    price = Column(Float)
    date = Column(MyEpochType)
示例#9
0
class Instrument(Base):
    __tablename__ = 'instrument'

    id = Column('id', Integer, primary_key=True)
    # override schema elements like Columns
    name = Column('name', String)

    instrument_type_id = Column('type', Integer,
                                ForeignKey('instrument_type.id'))
    instrument_type = relationship("InstrumentType", backref='instrument')

    currency_id = Column('currency', Integer, ForeignKey('currency.id'))
    currency = relationship("Currency", backref='instrument')

    url = Column('url', String)
    expense = Column('expense_ratio', Float)

    def __repr__(self):
        return self.name