def getByTickerAndDay(ticker, day): s = crud.Session() return s.query(models.Historical_Intraday).filter( and_( models.Historical_Intraday.ticker == ticker, models.Historical_Intraday.date == helpers.convertDatetimeToString( day))).all()
def saveOrder(symbol, alpacaOrderId): s = crud.Session() for ticker in tickers: order = models.Order() s.add(order) s.commit() s.close()
def saveBalanceSheet(ticker): s = crud.Session() balance_sheet = models.Balance_Sheet( ticker=ticker, balance_sheet=iex.getBalanceSheet(ticker)) s.add(balance_sheet) s.commit() s.close()
def saveHistoricalDailyByYear(ticker, year): dailyData = iex.getHistoricalDataByYear(ticker, 2018) s = crud.Session() for day, data in dailyData.items(): historical_daily = models.Historical_Daily(date=day, ticker=ticker, data=data) s.add(historical_daily) s.commit() s.close()
def saveIntradayDataDay(ticker, date): intraday_data = iex.getHistoricalIntradayByMinute(ticker, date) date_string = helpers.convertDatetimeToString(date) s = crud.Session() for minute_data in intraday_data: historical_intraday = models.Historical_Intraday( date=date_string, ticker=ticker, intraday_data=minute_data) s.add(historical_intraday) s.commit() s.close()
def saveAllIexTickers(): tickers = iex.get_iex_symbols() s = crud.Session() for ticker in tickers: print('ticker is') print(ticker) iex_ticker = models.IexTicker( ticker=ticker.get('symbol') ) s.add(iex_ticker) s.commit() s.close()
def getByTickerAndYear(ticker, year): s = crud.Session() return s.query(models.Historical_Daily).filter( and_(models.Historical_Daily.ticker == ticker, models.Historical_Daily.date.like("%" + str(year) + "%"))).all()