def from_bar(bar):
    """
    Generate DbBarData object from BarData.
    """
    db_bar = dict(
        index = bar.datetime,
        volume = bar.volume,
        open_int = bar.open_interest,
        open = bar.open_price,
        high = bar.high_price,
        low = bar.low_price,
        close = bar.close_price
    )

    return db_bar