bitcain docs

Market Data

Market Data

Real-time and historical market data, price feeds, technical indicators, and alerts.

15 tables in this group.

market_data

ColumnTypeNullableDefault
idint8Nonextval('market_data_id_seq'::regclass)
symboltextNo
timestamptimestamptzNo
datajsonbYes
created_attimestamptzYesnow()

RLS Policies:

  • market_data_read_policy — SELECT for {authenticated}
  • market_data_service_policy — ALL for {service_role}

Indexes:

  • market_data_pkey

market_data_ticks

ColumnTypeNullableDefault
timetimestamptzNo
exchangevarchar(50)No
symbolvarchar(20)No
pricenumericNo
bidnumericYes
asknumericYes
bid_sizenumericYes
ask_sizenumericYes
volumenumericYes
sequence_numberint8Yes

RLS Policies:

  • rls_market_data_ticks_insert — INSERT for {service_role}
  • rls_market_data_ticks_select — SELECT for {authenticated}

Indexes:

  • market_data_ticks_pkey

market_data_ohlcv

ColumnTypeNullableDefault
timetimestamptzNo
exchangevarchar(50)No
symbolvarchar(20)No
intervalvarchar(10)No
opennumericNo
highnumericNo
lownumericNo
closenumericNo
volumenumericNo
quote_volumenumericYes
trade_countint4Yes
vwapnumericYes

RLS Policies:

  • rls_market_data_ohlcv_insert — INSERT for {service_role}
  • rls_market_data_ohlcv_select — SELECT for {authenticated}

Indexes:

  • market_data_ohlcv_pkey

market_data_orderbook

ColumnTypeNullableDefault
timetimestamptzNo
exchangevarchar(50)No
symbolvarchar(20)No
bidsjsonbNo'[]'::jsonb
asksjsonbNo'[]'::jsonb
snapshot_idint8Yes
sequence_numberint8Yes
best_bidnumericYes
best_asknumericYes
spreadnumericYes
spread_percentnumericYes

RLS Policies:

  • rls_market_data_orderbook_insert — INSERT for {service_role}
  • rls_market_data_orderbook_select — SELECT for {authenticated}

Indexes:

  • market_data_orderbook_pkey

market_data_trades

ColumnTypeNullableDefault
timetimestamptzNo
exchangevarchar(50)No
symbolvarchar(20)No
trade_idvarchar(100)No
pricenumericNo
amountnumericNo
sidevarchar(10)No
makerboolYes
sequence_numberint8Yes

RLS Policies:

  • rls_market_data_trades_insert — INSERT for {service_role}
  • rls_market_data_trades_select — SELECT for {authenticated}

Indexes:

  • market_data_trades_pkey

candlestick_data

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
symbolvarchar(20)No
exchangevarchar(50)No
intervalvarchar(10)No
open_timetimestampNo
close_timetimestampNo
open_pricenumericNo
high_pricenumericNo
low_pricenumericNo
close_pricenumericNo
volumenumericNo
quote_volumenumericYes
number_of_tradesint4Yes
taker_buy_volumenumericYes
taker_buy_quote_volumenumericYes
sma_20numericYes
ema_20numericYes
rsi_14numericYes
macdnumericYes
macd_signalnumericYes
macd_histogramnumericYes
created_attimestampYesnow()

RLS Policies:

  • candlestick_data_public_select — SELECT for {public}
  • candlestick_data_service_delete — DELETE for {public}
  • candlestick_data_service_insert — INSERT for {public}
  • candlestick_data_service_update — UPDATE for {public}

Indexes:

  • candlestick_data_pkey
  • candlestick_data_unique_candle
  • idx_symbol_exchange_interval_time
  • ix_candlestick_data_open_time
  • ix_candlestick_data_symbol

price_data

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
asset_symbolvarchar(20)No
exchangevarchar(50)No
trading_pairvarchar(20)No
price_usdnumericNo
bid_price_usdnumericYes
ask_price_usdnumericYes
spread_percentnumericYes
volume_24h_usdnumericYes
volume_24h_basenumericYes
orderbook_depth_usdnumericYes
price_change_24h_percentnumericYes
price_change_7d_percentnumericYes
high_24h_usdnumericYes
low_24h_usdnumericYes
data_quality_scorenumericYes
is_staleboolYes
last_trade_timetimestampYes
timestamptimestampNo
created_attimestampYesnow()
price_metadatajsonYes

RLS Policies:

  • price_data_public_select — SELECT for {public}
  • price_data_service_delete — DELETE for {public}
  • price_data_service_insert — INSERT for {public}
  • price_data_service_update — UPDATE for {public}

Indexes:

  • ix_price_data_asset_symbol
  • ix_price_data_timestamp
  • price_data_pkey

price_alerts

ColumnTypeNullableDefault
iduuidNo
user_iduuidNo
symbolvarchar(20)No
conditionvarchar(20)No
target_pricenumericNo
current_pricenumericYes
is_activevarchar(10)Yes
triggered_attimestampYes
notification_methodsjsonYes
expires_attimestampYes
created_attimestampYes
updated_attimestampYes
messagevarchar(500)Yes
market_metadatajsonYes

RLS Policies:

  • price_alerts_delete_own — DELETE for {public}
  • price_alerts_insert_own — INSERT for {public}
  • price_alerts_select_own — SELECT for {public}
  • price_alerts_update_own — UPDATE for {public}

Indexes:

  • ix_price_alerts_symbol
  • ix_price_alerts_user_id
  • price_alerts_pkey

ColumnTypeNullableDefault
iduuidNo
symbolvarchar(20)No
timeframevarchar(10)No
trend_directionvarchar(20)No
trend_strengthnumericYes
trend_confidencenumericYes
support_levelnumericYes
resistance_levelnumericYes
current_pricenumericNo
rsinumericYes
macdnumericYes
macd_signalnumericYes
bollinger_uppernumericYes
bollinger_lowernumericYes
volume_smanumericYes
sma_20numericYes
sma_50numericYes
sma_200numericYes
ema_12numericYes
ema_26numericYes
volatility_24hnumericYes
volatility_7dnumericYes
volatility_30dnumericYes
analysis_datetimestampNo
data_start_datetimestampNo
data_end_datetimestampNo
sample_sizeint4Yes
created_attimestampNo
updated_attimestampYes

RLS Policies:

  • market_trends_public_select — SELECT for {public}
  • market_trends_service_delete — DELETE for {public}
  • market_trends_service_insert — INSERT for {public}
  • market_trends_service_update — UPDATE for {public}

Indexes:

  • ix_market_trends_symbol
  • market_trends_pkey

technical_indicators

ColumnTypeNullableDefault
iduuidNo
symbolvarchar(20)No
timeframevarchar(10)No
timestamptimestampNo
open_pricenumericNo
high_pricenumericNo
low_pricenumericNo
close_pricenumericNo
volumenumericYes
rsi_14numericYes
stochastic_knumericYes
stochastic_dnumericYes
williams_rnumericYes
momentum_10numericYes
sma_20numericYes
sma_50numericYes
sma_200numericYes
ema_12numericYes
ema_26numericYes
ema_50numericYes
macd_linenumericYes
macd_signalnumericYes
macd_histogramnumericYes
bb_uppernumericYes
bb_middlenumericYes
bb_lowernumericYes
bb_widthnumericYes
bb_positionnumericYes
volume_sma_20numericYes
volume_rationumericYes
obvnumericYes
atr_14numericYes
volatilitynumericYes
pivot_pointnumericYes
support_1numericYes
support_2numericYes
resistance_1numericYes
resistance_2numericYes
created_attimestampNo

RLS Policies:

  • technical_indicators_public_select — SELECT for {public}
  • technical_indicators_service_delete — DELETE for {public}
  • technical_indicators_service_insert — INSERT for {public}
  • technical_indicators_service_update — UPDATE for {public}

Indexes:

  • ix_technical_indicators_symbol
  • ix_technical_indicators_timestamp
  • technical_indicators_pkey

market_correlations

ColumnTypeNullableDefault
iduuidNo
symbol_1varchar(20)No
symbol_2varchar(20)No
timeframevarchar(10)No
pearson_correlationnumericNo
spearman_correlationnumericYes
kendall_correlationnumericYes
rolling_correlation_30dnumericYes
rolling_correlation_90dnumericYes
p_valuenumericYes
confidence_interval_lowernumericYes
confidence_interval_uppernumericYes
sample_sizeint4No
start_datedateNo
end_datedateNo
analysis_datedateNo
correlation_strengthvarchar(20)Yes
correlation_directionvarchar(20)Yes
created_attimestampNo
updated_attimestampYes

RLS Policies:

  • market_correlations_public_select — SELECT for {public}
  • market_correlations_service_delete — DELETE for {public}
  • market_correlations_service_insert — INSERT for {public}
  • market_correlations_service_update — UPDATE for {public}

Indexes:

  • ix_market_correlations_symbol_1
  • ix_market_correlations_symbol_2
  • market_correlations_pkey

market_sentiment_scores

ColumnTypeNullableDefault
sentiment_iduuidNo
symbolvarchar(20)No
timestamptimestampNo
sentiment_scorenumericNo
confidence_levelnumericNo
sourcesjsonNo
analysis_metadatajsonNo
created_attimestampNo
updated_attimestampYes
asset_symbolvarchar(20)No
sources_aggregatedjsonNo
market_fear_greed_indexint4No
social_volume_change_24hnumericNo
news_sentiment_change_24hnumericNo
whale_activity_scorenumericNo
expires_attimestampYes

RLS Policies:

  • market_sentiment_scores_public_select — SELECT for {public}
  • market_sentiment_scores_service_delete — DELETE for {public}
  • market_sentiment_scores_service_insert — INSERT for {public}
  • market_sentiment_scores_service_update — UPDATE for {public}

Indexes:

  • ix_market_sentiment_scores_asset_symbol
  • ix_market_sentiment_scores_symbol
  • ix_market_sentiment_scores_timestamp
  • market_sentiment_scores_pkey

alerts

ColumnTypeNullableDefault
iduuidNo
alert_idvarchar(100)No
user_iduuidNo
namevarchar(200)No
descriptiontextYes
asset_symbolvarchar(20)No
alert_typevarchar(30)No
trigger_conditionjsonbNo
severityvarchar(20)Yes
statusvarchar(20)Yes
frequencyvarchar(20)Yes
notification_channelsjsonbYes
trigger_countint4Yes
last_triggered_attimestamptzYes
next_check_attimestamptzYes
expires_attimestamptzYes
auto_disable_after_triggerboolYes
max_triggersint4Yes
alert_metadatajsonbYes
created_attimestamptzNo
updated_attimestamptzYes

RLS Policies:

  • alerts_delete_own — DELETE for {public}
  • alerts_insert_own — INSERT for {public}
  • alerts_select_own — SELECT for {public}
  • alerts_update_own — UPDATE for {public}

Indexes:

  • alerts_pkey
  • idx_alerts_active_queries
  • idx_alerts_alert_id
  • idx_alerts_asset_symbol
  • idx_alerts_auto_disable
  • idx_alerts_created_at
  • idx_alerts_expired_cleanup
  • idx_alerts_last_triggered
  • idx_alerts_next_check
  • idx_alerts_notification_channels
  • idx_alerts_symbol_type
  • idx_alerts_trigger_condition
  • idx_alerts_user_severity
  • idx_alerts_user_status
  • idx_alerts_user_type
  • ix_alerts_alert_id
  • ix_alerts_asset_symbol
  • ix_alerts_user_id

alert_history

ColumnTypeNullableDefault
iduuidNo
history_idvarchar(100)No
alert_iduuidNo
user_iduuidNo
event_typevarchar(30)No
trigger_valuenumericYes
threshold_valuenumericYes
asset_pricenumericYes
sentiment_scorenumericYes
volume_24hnumericYes
market_contextjsonbYes
messagetextYes
history_metadatajsonbYes
created_attimestampNo

RLS Policies:

  • alert_history_delete_own — DELETE for {public}
  • alert_history_insert_own — INSERT for {public}
  • alert_history_select_own — SELECT for {public}
  • alert_history_update_own — UPDATE for {public}

Indexes:

  • alert_history_pkey
  • idx_alert_history_alert_event
  • idx_alert_history_alert_id
  • idx_alert_history_event_type
  • idx_alert_history_market_context
  • idx_alert_history_metadata
  • idx_alert_history_recent_triggers
  • idx_alert_history_trigger_analytics
  • idx_alert_history_user_id
  • ix_alert_history_alert_id
  • ix_alert_history_history_id
  • ix_alert_history_user_id

alert_notifications

ColumnTypeNullableDefault
iduuidNo
notification_idvarchar(100)No
alert_iduuidNo
user_iduuidNo
channelvarchar(20)No
recipientvarchar(255)No
subjectvarchar(500)Yes
messagetextNo
statusvarchar(20)Yes
sent_attimestampYes
delivered_attimestampYes
error_messagetextYes
retry_countint4Yes
trigger_valuenumericYes
market_contextjsonbYes
created_attimestampNo
updated_attimestampYes

RLS Policies:

  • alert_notifications_delete_own — DELETE for {public}
  • alert_notifications_insert_own — INSERT for {public}
  • alert_notifications_select_own — SELECT for {public}
  • alert_notifications_update_own — UPDATE for {public}

Indexes:

  • alert_notifications_pkey
  • idx_alert_notifications_alert_id
  • idx_alert_notifications_channel_recent
  • idx_alert_notifications_delivery_time
  • idx_alert_notifications_market_context
  • idx_alert_notifications_retry
  • idx_alert_notifications_status
  • idx_alert_notifications_user_id
  • ix_alert_notifications_alert_id
  • ix_alert_notifications_notification_id
  • ix_alert_notifications_user_id

On this page