How to use the technical.history.__init__.OHLCV function in technical

To help you get started, we’ve selected a few technical examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github freqtrade / technical / technical / history / __init__.py View on Github external
def init():
    """
        setups our persistence for this module
    :return:
    """

    engine = create_engine(os.environ.get("TECHNICAL_HISTORY_DB", 'sqlite://'))
    session = scoped_session(sessionmaker(bind=engine, autoflush=True, autocommit=True))
    OHLCV.session = session
    OHLCV.query = session.query_property()
    _DECL_BASE.metadata.create_all(engine)
github freqtrade / technical / technical / history / __init__.py View on Github external
close=row[4],
                high=row[2],
                low=row[3],
                volume=row[5],
                timestamp=row[0]
            )
            OHLCV.session.merge(o)

    # return all data to user
    result = []

    # filter by exchange, currency and other pairs
    for row in OHLCV.session.query(OHLCV).filter(
            OHLCV.exchange == ccxt_api.name,
            OHLCV.pair == "{}/{}".format(asset.upper(), stake.upper()),
            OHLCV.interval == interval,
            OHLCV.timestamp >= from_date * 1000,
            OHLCV.timestamp <= till_date * 1000,
    ).all():
        result.append([row.timestamp, row.open, row.high, row.low, row.close, row.volume])

    return result
github freqtrade / technical / technical / history / __init__.py View on Github external
open=row[1],
                close=row[4],
                high=row[2],
                low=row[3],
                volume=row[5],
                timestamp=row[0]
            )
            OHLCV.session.merge(o)

    # return all data to user
    result = []

    # filter by exchange, currency and other pairs
    for row in OHLCV.session.query(OHLCV).filter(
            OHLCV.exchange == ccxt_api.name,
            OHLCV.pair == "{}/{}".format(asset.upper(), stake.upper()),
            OHLCV.interval == interval,
            OHLCV.timestamp >= from_date * 1000,
            OHLCV.timestamp <= till_date * 1000,
    ).all():
        result.append([row.timestamp, row.open, row.high, row.low, row.close, row.volume])

    return result
github freqtrade / technical / technical / history / __init__.py View on Github external
latest_time = OHLCV.session.query(func.max(OHLCV.timestamp)).filter(
        OHLCV.exchange == ccxt_api.name,
        OHLCV.pair == "{}/{}".format(asset.upper(), stake.upper()),
        OHLCV.interval == interval
    ).one()[0]

    if force:
        print("forcing database refresh and downloading all data!")
        latest_time = None

    # add additional data on top
    if latest_time is None:

        # store data for all
        for row in historical_data(stake, asset, interval, from_date, ccxt_api):
            o = OHLCV(
                id="{}-{}-{}/{}:{}".format(ccxt_api.name, interval, asset.upper(), stake.upper(), row[0]),
                exchange=ccxt_api.name,
                pair="{}/{}".format(asset.upper(), stake.upper()),
                interval=interval,
                open=row[1],
                close=row[4],
                high=row[2],
                low=row[3],
                volume=row[5],
                timestamp=row[0]
            )
            OHLCV.session.merge(o)

    else:
        # calculate the difference in days and download and merge the data files
github freqtrade / technical / technical / history / __init__.py View on Github external
pair="{}/{}".format(asset.upper(), stake.upper()),
                interval=interval,
                open=row[1],
                close=row[4],
                high=row[2],
                low=row[3],
                volume=row[5],
                timestamp=row[0]
            )
            OHLCV.session.merge(o)

    else:
        # calculate the difference in days and download and merge the data files

        for row in historical_data(stake, asset, interval, latest_time, ccxt_api):
            o = OHLCV(
                id="{}-{}-{}/{}:{}".format(ccxt_api.name, interval, asset.upper(), stake.upper(), row[0]),
                exchange=ccxt_api.name,
                pair="{}/{}".format(asset.upper(), stake.upper()),
                interval=interval,
                open=row[1],
                close=row[4],
                high=row[2],
                low=row[3],
                volume=row[5],
                timestamp=row[0]
            )
            OHLCV.session.merge(o)

    # return all data to user
    result = []
github freqtrade / technical / technical / history / __init__.py View on Github external
high=row[2],
                low=row[3],
                volume=row[5],
                timestamp=row[0]
            )
            OHLCV.session.merge(o)

    # return all data to user
    result = []

    # filter by exchange, currency and other pairs
    for row in OHLCV.session.query(OHLCV).filter(
            OHLCV.exchange == ccxt_api.name,
            OHLCV.pair == "{}/{}".format(asset.upper(), stake.upper()),
            OHLCV.interval == interval,
            OHLCV.timestamp >= from_date * 1000,
            OHLCV.timestamp <= till_date * 1000,
    ).all():
        result.append([row.timestamp, row.open, row.high, row.low, row.close, row.volume])

    return result
github freqtrade / technical / technical / history / __init__.py View on Github external
interval=interval,
                open=row[1],
                close=row[4],
                high=row[2],
                low=row[3],
                volume=row[5],
                timestamp=row[0]
            )
            OHLCV.session.merge(o)

    # return all data to user
    result = []

    # filter by exchange, currency and other pairs
    for row in OHLCV.session.query(OHLCV).filter(
            OHLCV.exchange == ccxt_api.name,
            OHLCV.pair == "{}/{}".format(asset.upper(), stake.upper()),
            OHLCV.interval == interval,
            OHLCV.timestamp >= from_date * 1000,
            OHLCV.timestamp <= till_date * 1000,
    ).all():
        result.append([row.timestamp, row.open, row.high, row.low, row.close, row.volume])

    return result