def cleanOlderData():
    session.query(NseCashDaily).filter(
        NseCashDaily.trade_date < (todaysDate - timedelta(days=365))).delete()
    session.commit()
Exemple #2
0
def cleanupOldFnOData():
    session.query(NseStockOptionDaily).filter(
        NseStockOptionDaily.expiry_date < todaysDate).delete()
    session.commit()
                        high=stock_ohlc_data["High"][ind],
                        low=stock_ohlc_data["Low"][ind],
                        close=stock_ohlc_data["Close"][ind],
                        volume=stock_ohlc_data["Volume"][ind].item(),
                        vwap=stock_ohlc_data["VWAP"][ind],
                        trades=stock_ohlc_data["Trades"][ind].item(),
                        deliverable_volume=stock_ohlc_data[
                            "Deliverable Volume"][ind].item(),
                        percentage_delivery=stock_ohlc_data["%Deliverble"]
                        [ind])
                    # print(nseDaily)
                    session.add(nseDaily)
                    print("END: Inserted into DB......")
                except Exception as ex:
                    print("ERROR: while Create NSEDAILY Object:")
                    print(ex)

        try:
            session.commit()
            session.query(StockList).filter(
                StockList.stock_code == stock.stock_code).update(
                    {StockList.cash_updated: todaysDate},
                    synchronize_session=False)
            session.commit()
        except Exception as ex:
            print("ERROR: while Commiting Last Session Data......")
            print(ex)

#print("To download NSE all Stock Data from:" + str(fromDate) + " to :" + str(toDate))
#print("took %s seconds " % (time.time() - start_time))
Exemple #4
0
def cleanupOldFnOData():
    session.query(NseIndicesOptionDaily.expiry_date < trade_date).delete()
    session.commit()