diff --git a/binance_db/candle.py b/binance_db/candle.py index 7dac931..ad0945a 100644 --- a/binance_db/candle.py +++ b/binance_db/candle.py @@ -2,7 +2,7 @@ import binance_db.util.constants.ws as ws import binance_db.util.constants.rest as rest from sqlalchemy.ext.declarative import declarative_base -from sqlalchemy import Column, String, Integer, Float, DateTime +from sqlalchemy import Column, String, Integer, Float, DateTime, Index Base = declarative_base() @@ -22,6 +22,11 @@ class Candle(Base): tbbav = Column(Float) tbqav = Column(Float) + __table_args__ = ( + Index('open_time_asc', open_time.asc(), postgresql_using='btree'), + Index('open_time_desc', open_time.desc(), postgresql_using='btree'), + ) + def __init__(self, pair, kline): self.pair = pair self.open_time = self.to_date(kline[rest.OPEN_TIME])