bitcain docs

AI & Machine Learning

AI & Machine Learning

AI predictions, model training, reinforcement learning, and RAG knowledge base.

12 tables in this group.

predictions

AI model predictions for validation and live monitoring

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
user_iduuidYes
model_iduuidYes
strategy_iduuidYes
symboltextNo
timeframetextNo
prediction_typetextNo
predicted_valuefloat8Yes
predicted_labeltextYes
predicted_probabilitiesjsonbYes
confidencefloat8Yes
input_featuresjsonbYes'{}'::jsonb
market_statejsonbYes'{}'::jsonb
current_pricenumericYes
actual_valuefloat8Yes
actual_labeltextYes
is_correctboolYes
error_magnitudefloat8Yes
profit_impactnumericYes
prediction_horizon_minutesint4Yes
prediction_made_attimestamptzNonow()
prediction_expires_attimestamptzYes
outcome_recorded_attimestamptzYes
embeddingvectorYes
metadatajsonbYes'{}'::jsonb
created_attimestamptzNonow()
agent_idtextYes
prompt_versiontextYes

RLS Policies:

  • Service role full access predictions — ALL for {public}
  • Users can insert own predictions — INSERT for {public}
  • Users can view own predictions — SELECT for {public}

Indexes:

  • idx_predictions_agent_id
  • idx_predictions_confidence
  • idx_predictions_created
  • idx_predictions_model
  • idx_predictions_outcome
  • idx_predictions_pending_is_correct
  • idx_predictions_pending_outcome
  • idx_predictions_symbol
  • idx_predictions_type
  • idx_predictions_user
  • idx_predictions_user_id
  • predictions_pkey

model_training_jobs

ML model training runs (LSTM, transformers, RL agents)

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
user_iduuidYes
model_nametextNo
model_typetextNo
model_versiontextYes
statustextNo'queued'::text
hyperparametersjsonbYes'{}'::jsonb
training_data_configjsonbYes'{}'::jsonb
symbols_textYes'{}'::text[]
timeframes_textYes'{}'::text[]
training_data_starttimestamptzYes
training_data_endtimestamptzYes
epochs_totalint4Yes
epochs_completedint4Yes0
batch_sizeint4Yes
learning_ratefloat8Yes
training_metricsjsonbYes'{}'::jsonb
validation_metricsjsonbYes'{}'::jsonb
best_metricsjsonbYes'{}'::jsonb
loss_historyjsonbYes'[]'::jsonb
model_artifact_pathtextYes
model_size_bytesint8Yes
checkpoint_pathsjsonbYes'[]'::jsonb
gpu_hoursfloat8Yes0
estimated_cost_usdnumericYes
tokens_usedint4Yes
created_attimestamptzNonow()
updated_attimestamptzNonow()
started_attimestamptzYes
completed_attimestamptzYes
error_messagetextYes
error_detailsjsonbYes
retry_countint4Yes0
max_retriesint4Yes3

RLS Policies:

  • Service role full access model_training_jobs — ALL for {public}
  • Users can insert own training jobs — INSERT for {public}
  • Users can update own training jobs — UPDATE for {public}
  • Users can view own training jobs — SELECT for {public}

Indexes:

  • idx_model_training_jobs_created
  • idx_model_training_jobs_model_name
  • idx_model_training_jobs_model_type
  • idx_model_training_jobs_status
  • idx_model_training_jobs_user
  • model_training_jobs_pkey

rl_training_episodes

Reinforcement learning episode data (Q-Learning, DT, PPO)

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
agent_idtextNo
algorithmtextNo
episode_numberint4No
statesjsonbNo'[]'::jsonb
actionsjsonbNo'[]'::jsonb
rewardsjsonbNo'[]'::jsonb
total_rewardfloat8No0
episode_lengthint4No0
cumulative_pnlnumericYes
max_drawdownfloat8Yes
sharpe_ratiofloat8Yes
win_ratefloat8Yes
epsilonfloat8Yes
learning_ratefloat8Yes
q_values_summaryjsonbYes
lossfloat8Yes
symboltextNo
timeframetextNo
market_regimetextYes
env_configjsonbYes'{}'::jsonb
started_attimestamptzNonow()
completed_attimestamptzYes
created_attimestamptzNonow()
metadatajsonbYes'{}'::jsonb

RLS Policies:

  • Service role full access rl_training_episodes — ALL for {public}

Indexes:

  • idx_rl_episodes_agent
  • idx_rl_episodes_algorithm
  • idx_rl_episodes_created
  • idx_rl_episodes_number
  • idx_rl_episodes_reward
  • idx_rl_episodes_symbol
  • idx_rl_training_episodes_agent_id
  • rl_training_episodes_pkey

agent_learning_episodes

Agent self-improvement learning episodes

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
agent_idtextNo
agent_typetextNo
episode_typetextNo
contextjsonbNo'{}'::jsonb
action_takentextNo
outcometextNo
rewardfloat8No0
lessons_learned_textYes
pattern_iduuidYes
confidence_beforefloat8Yes
confidence_afterfloat8Yes
strategy_iduuidYes
signal_iduuidYes
order_iduuidYes
prediction_iduuidYes
embeddingvectorYes
episode_starttimestamptzNonow()
episode_endtimestamptzYes
created_attimestamptzNonow()
metadatajsonbYes'{}'::jsonb

RLS Policies:

  • Service role full access agent_learning_episodes — ALL for {public}

Indexes:

  • agent_learning_episodes_pkey
  • idx_agent_learning_agent
  • idx_agent_learning_created
  • idx_agent_learning_episodes_agent_id
  • idx_agent_learning_outcome
  • idx_agent_learning_reward
  • idx_agent_learning_type

collective_memory

Universal shared memory for cross-agent knowledge transfer and collective learning

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
agent_idtextNo
agent_typetextNo
memory_typetextNo
content_jsonjsonbNo
content_embeddingvectorYes
confidencenumericNo0.5
access_countint4No0
decay_factornumericNo1.0
symbolvarchar(20)Yes
tags_textYes'{}'::text[]
expires_attimestamptzYes
created_attimestamptzNonow()
updated_attimestamptzNonow()

RLS Policies:

  • All authenticated users can read collective memory — SELECT for {public}
  • Service role full access to collective memory — ALL for {public}

Indexes:

  • collective_memory_pkey
  • idx_collective_memory_agent
  • idx_collective_memory_agent_id
  • idx_collective_memory_agent_symbol_type
  • idx_collective_memory_confidence
  • idx_collective_memory_created
  • idx_collective_memory_embedding
  • idx_collective_memory_expires
  • idx_collective_memory_memory_type
  • idx_collective_memory_symbol
  • idx_collective_memory_tags
  • idx_collective_memory_type

q_table_snapshots

Persisted Q-value snapshots from RL agents for cross-agent aggregation

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
agent_idtextNo
symbolvarchar(20)No
state_keytextNo
actiontextNo
q_valuenumericNo
update_countint4No0
epsilonnumericYes
episode_numberint4Yes
created_attimestamptzNonow()

RLS Policies:

  • All authenticated users can read Q-table snapshots — SELECT for {public}
  • Service role full access to Q-table snapshots — ALL for {public}

Indexes:

  • idx_q_snapshots_agent
  • idx_q_snapshots_created
  • idx_q_snapshots_state
  • idx_q_snapshots_symbol
  • idx_q_snapshots_symbol_state_action
  • idx_q_table_snapshots_upsert
  • q_table_snapshots_pkey

trading_experiences

RL experiences for Decision Transformer and Q-Learning training

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
agent_idtextNo
statejsonbNo
actiontextNo
rewardfloat8No
next_statejsonbYes
doneboolYesfalse
embeddingvectorYes
confidencefloat8Yes0.5
metadatajsonbYes'{}'::jsonb
created_attimestamptzYesnow()

RLS Policies:

  • Authenticated users can view experience statistics — SELECT for {public}
  • Service role can manage all experiences — ALL for {public}

Indexes:

  • trading_experiences_action_idx
  • trading_experiences_agent_id_idx
  • trading_experiences_agent_reward_idx
  • trading_experiences_created_at_idx
  • trading_experiences_embedding_idx
  • trading_experiences_pkey
  • trading_experiences_reward_idx

trading_documents

RAG knowledge base for trading content with semantic embeddings for similarity search

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
contenttextNo
content_hashvarchar(64)No
doc_typedocument_typeNo
sourcecontent_sourceNo
embeddingvectorNo
metadatajsonbYes'{}'::jsonb
created_attimestamptzNonow()
content_created_attimestamptzNonow()
user_iduuidYes
expires_attimestamptzYes

RLS Policies:

  • trading_documents_delete_policy — DELETE for {authenticated}
  • trading_documents_insert_policy — INSERT for {authenticated}
  • trading_documents_read_policy — SELECT for {authenticated}
  • trading_documents_service_role_policy — ALL for {service_role}
  • trading_documents_update_policy — UPDATE for {authenticated}

Indexes:

  • trading_documents_content_created_at_idx
  • trading_documents_content_hash_key
  • trading_documents_created_at_idx
  • trading_documents_doc_type_idx
  • trading_documents_embedding_hnsw_idx
  • trading_documents_expires_at_idx
  • trading_documents_metadata_gin_idx
  • trading_documents_pkey
  • trading_documents_source_idx
  • trading_documents_user_id_idx

rag_settings

Admin-configurable settings for RAG data collection pipeline. Should contain only one row (singleton pattern).

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
enabled_sourcesjsonbNojsonb_build_object('x_twitter', true, 'reddit', true, 'co...
collection_limitsjsonbNojsonb_build_object('x_twitter', 100, 'reddit', 50, 'coing...
collection_interval_minutesint4No30
auto_expiration_daysint4No30
max_posts_per_runint4No1000
created_attimestamptzNonow()
updated_attimestamptzNonow()
updated_byuuidYes
versionint4No1

RLS Policies:

  • Admins can create RAG settings — INSERT for {authenticated}
  • Admins can delete RAG settings — DELETE for {authenticated}
  • Admins can update RAG settings — UPDATE for {authenticated}
  • Authenticated users can view RAG settings — SELECT for {authenticated}

Indexes:

  • rag_settings_pkey
  • rag_settings_updated_at_idx

ai_batch_jobs

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
user_iduuidYes
job_typetextNo
custom_idtextNo
payload_jsonjsonbNo
priorityint4Yes50
run_aftertimestamptzYes
statustextNo'pending'::text
batch_idtextYes
batch_positionint4Yes
result_jsonjsonbYes
error_messagetextYes
tokens_usedint4Yes
created_attimestamptzNonow()
updated_attimestamptzNonow()
batched_attimestamptzYes
sent_attimestamptzYes
completed_attimestamptzYes
idempotency_keytextYes
expires_attimestamptzYes(now() + '7 days'::interval)

RLS Policies:

  • Service role full access to batch jobs — ALL for {public}
  • Users can cancel own pending batch jobs — UPDATE for {public}
  • Users can insert own batch jobs — INSERT for {public}
  • Users can view own batch jobs — SELECT for {public}

Indexes:

  • ai_batch_jobs_custom_id_key
  • ai_batch_jobs_idempotency_key_key
  • ai_batch_jobs_pkey
  • idx_ai_batch_jobs_batch_id
  • idx_ai_batch_jobs_job_type
  • idx_ai_batch_jobs_pending
  • idx_ai_batch_jobs_status
  • idx_ai_batch_jobs_user_id

ai_batch_executions

ColumnTypeNullableDefault
iduuidNogen_random_uuid()
anthropic_batch_idtextNo
jobs_countint4No
total_tokens_estimatedint4Yes
total_tokens_usedint4Yes
statustextNo'created'::text
succeeded_countint4Yes0
failed_countint4Yes0
estimated_cost_usdnumericYes
actual_cost_usdnumericYes
savings_usdnumericYes
created_attimestamptzNonow()
submitted_attimestamptzYes
completed_attimestamptzYes
error_detailsjsonbYes

RLS Policies:

  • Service role full access to batch executions — ALL for {public}

Indexes:

  • ai_batch_executions_anthropic_batch_id_key
  • ai_batch_executions_pkey
  • idx_ai_batch_executions_status

attribution_analyses

ColumnTypeNullableDefault
iduuidNo
portfolio_iduuidNo
benchmark_iduuidNo
start_datedateNo
end_datedateNo
periodvarchar(20)Yes
total_excess_returnnumericNo
asset_allocation_effectnumericYes
security_selection_effectnumericYes
interaction_effectnumericYes
currency_effectnumericYes
timing_effectnumericYes
t_statisticnumericYes
p_valuenumericYes
confidence_levelnumericYes
created_attimestampNo
attribution_breakdownjsonYes

RLS Policies:

  • attribution_analyses_service_all — ALL for {public}

Indexes:

  • attribution_analyses_pkey
  • idx_attribution_analyses_benchmark_id
  • idx_attribution_analyses_portfolio_id

On this page