bachpx195 / daily_trading_journal

Nhật kí giao dịch
4 stars 4 forks source link

Tổ chức lại database của candlesticks, analytics và reports #102

Open bachpx195 opened 1 week ago

bachpx195 commented 1 week ago

Tổng quan

Hiện tại phần data của candlestick đang chưa đáp ứng được yêu cầu => Cần design lại

bachpx195 commented 6 days ago
Table candlesticks {
  id integer [primary key]
  merchandise_rate_id integer
}

Table merchandise_rates {
  id integer [primary key]
}

Table analytic_hours {
  id integer [primary key]
  merchandise_rate_id integer
  candlestick_id integer
  analytic_day_id integer

  range_type string
  date date
  date_with_binane date
  hour integer
  return_oc float
  return_hl float
  candlestick_type string
  is_same_btc boolean
  continue_by_day integer //default: 1
  continue_by_hour integer //default: 1
}

Table analytic_days {
  id integer [primary key]
  merchandise_rate_id integer
  candlestick_id integer
  analytic_week_id integer
  analytic_month_id integer

  date date
  date_name string
  return_oc float
  return_hl float
  candlestick_type string
  range_type string
  is_inside_day boolean
  is_same_btc boolean
  is_continue_increase boolean
  is_continue_decrease boolean
  is_fake_breakout_increase boolean
  is_fake_breakout_decrease boolean
  continue integer//default: 1
}

Table report_days {
  id integer [primary key]
  merchandise_rate_id integer
  analytic_day_id integer

  highest_hour_return_oc integer
  highest_hour_return_hl integer
  highest_hour_volumn integer
  33_per_hour_range float
  67_per_hour_range float
  reverse_increase_hour integer
  reverse_decrease_hour integer
  continue_increase_hour integer
  continue_decrease_hour integer
}

Table analytic_weeks {
  id integer [primary key]
  merchandise_rate_id integer
  candlestick_id integer
  analytic_month_id integer

  from_date date
  to_date date
  month integer
  year integer
  number_in_month integer //default: 1
  candlestick_type string
  range_type string
  return_oc float
  return_hl float
  is_inside_week boolean
  is_same_btc boolean
  is_continue_increase boolean
  is_continue_decrease boolean
  is_fake_breakout_increase boolean
  is_fake_breakout_decrease boolean
}

Table report_weeks {
  id integer [primary key]
  merchandise_rate_id integer
  analytic_week_id integer

  highest_day_return_oc date
  highest_day_return_oc_name string
  highest_day_return_hl date
  highest_day_return_hl_name string
  highest_day_volumn date
  highest_day_volumn_name string
  33_per_day_range float
  67_per_day_range float
  reverse_increase_day date
  reverse_increase_day_name string
  reverse_decrease_day date
  reverse_decrease_day_name string
  continue_increase_day date
  continue_increase_day_name string
  continue_decrease_day date
  continue_decrease_day_name string
}

Table analytic_months {
  id integer [primary key]
  merchandise_rate_id integer
  candlestick_id integer
  month integer
  year integer
  candlestick_type string
  range_type string
  is_inside_month boolean
  is_same_btc boolean
  is_continue_increase boolean
  is_continue_decrease boolean
  is_fake_breakout_increase boolean
  is_fake_breakout_decrease boolean
}

Table report_months {
  id integer [primary key]
  merchandise_rate_id integer
  analytic_month_id integer

  highest_day_return_oc date
  highest_day_return_hl date
  highest_day_volumn date
  33_per_day_range float
  67_per_day_range float
  reverse_increase_day date
  reverse_decrease_day date
  continue_increase_day date
  continue_decrease_day date
}

Ref: candlesticks.merchandise_rate_id > merchandise_rates.id 

Ref: analytic_hours.merchandise_rate_id > merchandise_rates.id 
Ref: analytic_hours.candlestick_id > candlesticks.id 
Ref: analytic_hours.analytic_day_id > analytic_days.id 

Ref: analytic_days.merchandise_rate_id > merchandise_rates.id 
Ref: analytic_days.candlestick_id > candlesticks.id 
Ref: analytic_days.analytic_month_id > analytic_months.id 
Ref: analytic_days.analytic_week_id > analytic_weeks.id 

Ref: report_days.merchandise_rate_id > merchandise_rates.id 
Ref: report_days.analytic_day_id > analytic_days.id 

Ref: analytic_weeks.merchandise_rate_id > merchandise_rates.id 
Ref: analytic_weeks.candlestick_id > candlesticks.id 
Ref: analytic_weeks.analytic_month_id > analytic_months.id 

Ref: report_weeks.merchandise_rate_id > merchandise_rates.id 
Ref: report_weeks.analytic_week_id > analytic_weeks.id 

Ref: analytic_months.merchandise_rate_id > merchandise_rates.id 
Ref: analytic_months.candlestick_id > candlesticks.id 

Ref: report_months.merchandise_rate_id > merchandise_rates.id 
Ref: report_months.analytic_month_id > analytic_months.id
bachpx195 commented 6 days ago
rails generate model AnalyticMonth candlestick:references merchandise_rate:references month:integer year:integer candlestick_type:string range_type:string return_oc:float return_hl:float is_inside_month:boolean is_same_btc:boolean is_continue_increase:boolean is_continue_decrease:boolean is_fake_breakout_increase:boolean is_fake_breakout_decrease:boolean
bachpx195 commented 6 days ago
rails generate model ReportMonth merchandise_rate:references analytic_month:references highest_day_return_oc:date highest_day_return_hl:date highest_day_volumn:date 33_per_day_range:float 67_per_day_range:float reverse_increase_day:date reverse_decrease_day:date continue_increase_day:date continue_decrease_day:date
bachpx195 commented 6 days ago
rails generate model AnalyticWeek candlestick:references merchandise_rate:references analytic_month:references month:integer year:integer from_date:date to_date:date candlestick_type:string range_type:string return_oc:float return_hl:float is_inside_week:boolean is_same_btc:boolean is_continue_increase:boolean is_continue_decrease:boolean is_fake_breakout_increase:boolean is_fake_breakout_decrease:boolean
bachpx195 commented 6 days ago
rails generate model ReportWeek merchandise_rate:references analytic_week:references highest_day_return_oc:date highest_day_return_hl_name:string highest_day_return_hl:date highest_day_return_hl_name:string highest_day_volumn:date highest_day_volumn_name:string 33_per_day_range:float 67_per_day_range:float reverse_increase_day:date reverse_increase_day_name:string reverse_decrease_day:date reverse_decrease_day_name:string continue_increase_day:date continue_increase_day_name:string continue_decrease_day:date continue_decrease_day_name:string
bachpx195 commented 6 days ago
rails generate model AnalyticDay candlestick:references merchandise_rate:references analytic_month:references analytic_week:references date:date date_name:string candlestick_type:string range_type:string return_oc:float return_hl:float is_inside_day:boolean is_same_btc:boolean is_continue_increase:boolean is_continue_decrease:boolean is_fake_breakout_increase:boolean is_fake_breakout_decrease:boolean continue:integer
bachpx195 commented 6 days ago
rails generate model ReportDay merchandise_rate:references analytic_day:references highest_hour_return_oc:integer highest_hour_return_hl:integer highest_hour_volumn:integer 33_per_hour_range:float 67_per_hour_range:float reverse_increase_hour:integer reverse_decrease_hour:integer continue_increase_hour:integer continue_decrease_hour:integer
bachpx195 commented 6 days ago
rails generate model AnalyticHour candlestick:references merchandise_rate:references analytic_day:references range_type:string date:date date_with_binane:date hour:integer return_oc:float return_hl:float candlestick_type:string is_same_btc:boolean continue_by_day:integer continue_by_hour:integer