Quantcast
Channel: TimescaleDB and PostgreSQL - Timescale Community Forum
Viewing all articles
Browse latest Browse all 291

Creating Localized OHLC Candles with Custom Calendars in TimescaleDB

$
0
0

I’m working on a project that requires creating OHLC (Open, High, Low, Close) candles for various assets, including some that are specific to the Iranian market. While TimescaleDB’s MATERIALIZED VIEWS and continuous aggregation features are great for creating standard candles, I’m facing some challenges with localization. I’d appreciate any guidance on how to approach this problem.

Current Setup

I’m using MATERIALIZED VIEWS and continuous aggregation to create OHLC candles for different time frames.

Localization Challenges

  1. Timezone: For assets like USRIRR (US Dollar against Iranian Rial) that trade only in local markets, I need to consider the Tehran timezone for candle views.
  2. Week Start: In Iran, weeks start on Saturday, and the weekend is Friday. This affects how weekly (1w) candles should be calculated.
  3. Persian Calendar: Monthly and yearly candles need to align with the Persian calendar (Jalali Calendar), which differs significantly from the Gregorian calendar used by default in TimescaleDB.

Questions

  1. Is there a way to add locale information or custom calendars for Postgres / TimescaleDB when creating views?
  2. How can I create time-based aggregations (daily, weekly, monthly, yearly) that respect a custom calendar system?
  3. Are there any extensions or workarounds that could help implement these localization requirements?
  4. If direct support isn’t available, what would be the best approach to implement this custom logic? Should I consider pre-processing the data or post-processing the results?

Any insights, suggestions, or examples would be greatly appreciated. Thank you in advance for your help!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 291

Trending Articles