class NasdaqPredictionDto(db.Model): __tablename__ = 'NASDAQ_prediction' __table_args__ = {'mysql_collate': 'utf8_general_ci'} id: int = db.Column(db.Integer, primary_key=True, index=True) ticker: str = db.Column(db.String(30)) date: str = db.Column(db.Date) pred_price: float = db.Column(db.Float) open: float = db.Column(db.Float) high: float = db.Column(db.Float) low: float = db.Column(db.Float) close: float = db.Column(db.Float) stock_id: int = db.Column(db.Integer, db.ForeignKey(YHFinanceDto.id)) covid_id: int = db.Column(db.Integer, db.ForeignKey(USCovidDto.id)) news_id: int = db.Column(db.Integer, db.ForeignKey(InvestingDto.id)) def __init__(self, ticker, date, pred_price, open, high, low, close, stock_id, covid_id, news_id): self.ticker = ticker self.date = date self.pred_price = pred_price self.open = open self.high = high self.low = low self.close = close self.stock_id = stock_id self.covid_id = covid_id self.news_id = news_id def __repr__(self): return f'NASDAQ_Prediction(id=\'{self.id}\',ticker=\'{self.ticker}\',date=\'{self.date}\', pred_price=\'{self.pred_price}\',\ open=\'{self.open}\',high=\'{self.high}\',low=\'{self.low}\',close=\'{self.close}\',\ stock_id=\'{self.stock_id}\',covid_id=\'{self.covid_id}\', news_id=\'{self.news_id}\' )' @property def json(self): return { 'id': self.id, 'ticker': self.ticker, 'date': self.date, 'pred_price': self.pred_price, 'open': self.open, 'high': self.high, 'low': self.low, 'close': self.close, 'stock_id': self.stock_id, 'covid_id': self.covid_id, 'news_id': self.news_id } def save(self): db.session.add(self) db.session.commit() def delete(self): db.session.delete(self) db.session.commint()
class KospiDto(db.Model): __tablename__ = 'kospi_pred' __table_args__ = {'mysql_collate': 'utf8_general_ci'} id: str = db.Column(db.Integer, primary_key=True, index=True) date: str = db.Column(db.DATE) ticker: str = db.Column(db.VARCHAR(30)) pred_price: int = db.Column(db.VARCHAR(30)) open: float = db.Column(db.Float) high: float = db.Column(db.Float) low: float = db.Column(db.Float) close: float = db.Column(db.Float) covid_id: str = db.Column(db.Integer, db.ForeignKey(KoreaDto.id)) stock_id: str = db.Column(db.Integer, db.ForeignKey(StockDto.id)) news_id: str = db.Column(db.Integer, db.ForeignKey(NewsDto.id)) def __init__(self, id, date, covid_id, stock_id, news_id, ticker, pred_price, open, high, low, close): self.id = id self.date = date self.covid_id = covid_id self.stock_id = stock_id self.news_id = news_id self.ticker = ticker self.pred_price = pred_price self.open = open self.high = high self.low = low self.cloese = close def __repr__(self): return f'id={self.id},date={self.date},covid_id ={self.covid_id },stock_id={self.stock_id},news_id={self.news_id}, ticker={self.ticker},\ pred_price={self.pred_price},open={self.open},high={self.high},low={self.low},close={self.close}' @property def json(self): return { 'id': self.id, 'date': self.date, 'covid_id': self.covid_id, 'stock_id': self.stock_id, 'news_id': self.news_id, 'ticker': self.ticker, 'pred_price': self.pred_price, 'open': self.open, 'low': self.low, 'high': self.high, 'close': self.close }
class CommentDto(db.Model): __tablename__ = "comments" __table_args__ = {"mysql_collate": "utf8_general_ci"} id: int = db.Column(db.Integer, primary_key=True, index=True) board_id: int = db.Column(db.Integer, db.ForeignKey(BoardDto.id), nullable=False) email: str = db.Column(db.String(100), db.ForeignKey(MemberDto.email), nullable=False) comment: str = db.Column(db.String(500), nullable=False) regdate: datetime = db.Column(db.String(1000), default=datetime.datetime.now(), nullable=False) comment_ref: int = db.Column(db.Integer, nullable=False) comment_level: int = db.Column(db.Integer, nullable=False) comment_step: int = db.Column(db.Integer, nullable=False) board = db.relationship('BoardDto', back_populates='comments') member = db.relationship('MemberDto', back_populates='comments') def __init__(self, board_id, email, comment, regdate, comment_ref, comment_level, comment_step): self.board_id = board_id self.email = email self.comment = comment self.regdate = regdate self.comment_ref = comment_ref self.comment_level = comment_level self.comment_step = comment_step def __repr__(self): return f'id={self.id}, board_id={self.board_id}, email={self.email}, comment={self.comment}, regdate={self.regdate}, ref={self.comment_ref}, level={self.comment_level}, step={self.comment_step}' @property def json(self): return { 'id': self.id, 'board_id': self.board_id, 'email': self.email, 'comment': self.comment, 'regdate': self.regdate, 'comment_ref': self.comment_ref, 'comment_level': self.comment_level, 'comment_step': self.comment_step }
class RecommendStockDto(db.Model): __tablename__ = 'recommend_stocks' __table_args__ = {'mysql_collate': 'utf8_general_ci'} id: int = db.Column(db.Integer, primary_key=True, index=True) email: str = db.Column(db.String(100), db.ForeignKey(MemberDto.email), nullable=False) stock_type: str = db.Column(db.String(50), nullable=False) stock_ticker: str = db.Column(db.String(100), nullable=False) def __init__(self, email, stock_type, stock_ticker): self.email = email self.stock_type = stock_type self.stock_ticker = stock_ticker def __repr__(self): return f'id={self.id}, email={self.email}, stock_type={self.stock_type}, stock_ticker={self.stock_ticker}' @property def json(self): return { 'id': self.id, 'email': self.email, 'stock_type': self.stock_type, 'stock_ticker': self.stock_ticker }
class MemberChurnPredDto(db.Model): __tablename__ = 'member_churn_preds' __table_args__ = {'mysql_collate': 'utf8_general_ci'} id: int = db.Column(db.Integer, primary_key=True, index=True) email: str = db.Column(db.String(100), db.ForeignKey(MemberDto.email), nullable=False) probability_churn: float = db.Column(db.FLOAT, nullable=False) def __init__(self, id, email, probability_churn): self.id = id self.email = email self.prob_churn = probability_churn def __repr__(self): return f'MemberChurnPred(id={self.id}, email={self.email}, prob_churn={self.prob_churn})' @property def json(self): return { 'id': self.id, 'email': self.email, 'prob_churn': self.probability_churn }
class PredictionDto(db.Model): __tablename__ = 'NASDAQ_prediction' __table_args__ = {'mysql_collate': 'utf8_general_ci'} id: int = db.Column(db.Integer, primary_key=True, index=True) date: str = db.Column(db.Date) ticker: str = db.Column(db.String(30)) pred_price: float = db.Column(db.Float) stock_id: int = db.Column(db.Integer, db.ForeignKey(YHFinanceDto.id)) covid_id: int = db.Column(db.Integer, db.ForeignKey(USCovidDto.id)) news_id: int = db.Column(db.Integer, db.ForeignKey(YHNewsDto.id)) def __init__(self, ticker, date, pred_price, stock_id, covid_id, news_id): self.date = date self.ticker = ticker self.pred_price = pred_price self.stock_id = stock_id self.covid_id = covid_id self.news_id = news_id def __repr__(self): return f'Prediction(id=\'{self.id}\',date=\'{self.date}\',\ ticker=\'{self.ticker}\',date=\'{self.date}\',pred_price=\'{self.pred_price}\',\ stock_id=\'{self.stock_id}\',covid_id=\'{self.covid_id}\', news_id=\'{self.news_id}\' )' @property def json(self): return { 'id': self.id, 'date': self.date, 'ticker': self.ticker, 'pred_price': self.pred_price, 'stock_id': self.stock_id, 'covid_id': self.covid_id, 'news_id': self.news_id } def save(self): db.session.add(self) db.session.commit() def delete(self): db.session.delete(self) db.session.commint()
class KospiDto(db.Model): __tablename__ = 'kospi_pred' __table_args__ = {'mysql_collate': 'utf8_general_ci'} id: int = db.Column(db.Integer, primary_key=True, index=True) date: str = db.Column(db.DATETIME) stock: int = db.Column(db.VARCHAR(30)) price: int = db.Column(db.VARCHAR(30)) covid_id: int = db.Column(db.Integer, db.ForeignKey(KoreaDto.id)) stock_id: int = db.Column(db.Integer, db.ForeignKey(StockDto.id)) news_id: int = db.Column(db.Integer, db.ForeignKey(NewsDto.id)) def __init__(self, id, date, covid_id, stock_id, news_id, stock, price): self.id = id self.date = date self.covid_id = covid_id self.stock_id = stock_id self.news_id = news_id self.stock = stock self.price = price def __repr__(self): return f'id={self.id},date={self.date},covid_id ={self.covid_id },stock_id={self.sstock_id},news_id={self.news_id}, stock={self.stock},\ price={self.price}' @property def json(self): return { 'id': self.id, 'date': self.date, 'covid_id': self.covid_id, 'stock_id': self.stock_id, 'news_id': self.news_id, 'stock': self.stock, 'price': self.price } def save(self): db.session.add(self) db.session.commit() def delete(self): db.session.delete(self) db.session.commit()
class KospiDto(db.Model): __tablename__ = 'kospi_pred' __table_args__ = {'mysql_collate': 'utf8_general_ci'} id: str = db.Column(db.Integer, primary_key=True, index=True) date: str = db.Column(db.DATE) ticker: str = db.Column(db.VARCHAR(30)) pred_price: int = db.Column(db.VARCHAR(30)) covid_id: str = db.Column(db.Integer, db.ForeignKey(KoreaDto.id)) stock_id: str = db.Column(db.Integer, db.ForeignKey(StockDto.id)) news_id: str = db.Column(db.Integer, db.ForeignKey(NewsDto.id)) def __init__(self, id, date, covid_id, stock_id, news_id, ticker, pred_price): self.id = id self.date = date self.covid_id = covid_id self.stock_id = stock_id self.news_id = news_id self.ticker = ticker self.pred_price = pred_price def __repr__(self): return f'id={self.id},date={self.date},covid_id ={self.covid_id },stock_id={self.stock_id},news_id={self.news_id}, ticker={self.ticker},\ pred_price={self.pred_price}' @property def json(self): return { 'id': self.id, 'date': self.date, 'covid_id': self.covid_id, 'stock_id': self.stock_id, 'news_id': self.news_id, 'ticker': self.ticker, 'pred_price': self.pred_price }
class BoardDto(db.Model): __tablename__ = 'boards' __table_args__ = {'mysql_collate': 'utf8_general_ci'} id: int = db.Column(db.Integer, primary_key=True, index=True) email: str = db.Column(db.String(100), db.ForeignKey(MemberDto.email), nullable=False) article_type: str = db.Column(db.String(50), nullable=False) title: str = db.Column(db.String(50), nullable=False) content: str = db.Column(db.String(20000), nullable=False) regdate: datetime = db.Column(db.String(1000), default=datetime.datetime.now()) member = db.relationship('MemberDto', back_populates='boards') comments = db.relationship('CommentDto', back_populates='board', lazy='dynamic') def __init__(self, email, article_type, title, content, regdate): self.email = email self.article_type = article_type self.title = title self.content = content self.regdate = regdate def __repr__(self): return 'Board(id={}, email={}, article_type={}, title={}, content={}, regdate={})'.format( self.id, self.email, self.article_type, self.title, self.content, self.regdate) @property def json(self): return { 'id': self.id, 'email': self.email, 'article_type': self.article_type, 'title': self.title, 'content': self.content, 'regdate': self.regdate } def save(self): db.session.add(self) db.commit() def delete(self): db.session.delete(self) db.commit()
class TradingDto(db.Model): __tablename__ = "tradings" __table_args__ = {'mysql_collate': 'utf8_general_ci'} id: int = db.Column(db.Integer, primary_key=True, index=True) email: str = db.Column(db.String(100), db.ForeignKey(MemberDto.email), nullable=False) kospi_stock_id: int = db.Column(db.Integer, db.ForeignKey(StockDto.id)) nasdaq_stock_id: int = db.Column(db.Integer, db.ForeignKey(YHFinanceDto.id)) stock_qty: int = db.Column(db.Integer, nullable=False) price: float = db.Column(db.FLOAT, nullable=False) trading_date: str = db.Column(db.String(1000), default=datetime.datetime.now()) def __init__(self, id, email, kospi_stock_id, nasdaq_stock_id, stock_qty, price, trading_date): self.id = id self.email = email self.kospi_stock_id = kospi_stock_id self.nasdaq_stock_id = nasdaq_stock_id self.stock_qty = stock_qty self.price = price self.trading_date = trading_date def __repr__(self): return 'Trading(trading_id={}, member_id={}, kospi_stock_id={}, nasdaq_stock_id={}, stock_qty={}, price={}, trading_date={})'.format(self.id, self.member_id, self.kospi_stock_id, self.nasdaq_stock_id, self.stock_qty, self.price, self.trading_date) @property def json(self): return { 'id': self.id, 'member_id': self.member_id, 'kospi_stock_id': self.kospi_stock_id, 'nasdaq_stock_id': self.nasdaq_stock_id, 'stock_qty': self.stock_qty, 'price': self.price, 'trading_date': self.trading_date }
class TradingDto(db.Model): __tablename__ = "tradings" __table_args__ = {'mysql_collate': 'utf8_general_ci'} id: int = db.Column(db.Integer, primary_key=True, index=True) email: str = db.Column(db.String(100), db.ForeignKey(MemberDto.email), nullable=False) stock_type: str = db.Column(db.String(20), nullable=False) stock_ticker: str = db.Column(db.String(50), nullable=False) stock_qty: int = db.Column(db.Integer, nullable=False) price: float = db.Column(db.FLOAT, nullable=False) trading_date: str = db.Column(db.String(50), default=datetime.datetime.now()) member = db.relationship('MemberDto', back_populates='tradings') def __init__(self, email, stock_type, stock_ticker, stock_qty, price, trading_date): self.email = email self.stock_type = stock_type self.stock_ticker = stock_ticker self.stock_qty = stock_qty self.price = price self.trading_date = trading_date def __repr__(self): return 'Trading(trading_id={}, email={}, stock_type={}, stock_ticker={}, stock_qty={}, price={}, trading_date={})'.format( self.id, self.email, self.stock_type, self.stock_ticker, self.stock_qty, self.price, self.trading_date) @property def json(self): return { 'id': self.id, 'email': self.email, 'stock_type': self.stock_type, 'stock_ticker': self.stock_ticker, 'stock_qty': self.stock_qty, 'price': self.price, 'trading_date': self.trading_date }