Skip to content

Commit

Permalink
Update trading fee
Browse files Browse the repository at this point in the history
  • Loading branch information
pan-xiong committed Sep 23, 2023
1 parent af11160 commit da1d070
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/adding_positions_history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def trading_fee
fee = $redis.get("aph_#{id}_trading_fee")
if fee.nil?
if snapshot_position.present?
fee = FundingFeeHistory.where('user_id is null and origin_symbol = ? and event_date <= ?', origin_symbol, event_date - 1.day).sum(&:amount) * (amount / snapshot_position.amount)
fee = FundingFeeHistory.where('user_id is null and origin_symbol = ? and event_date <= ? and trade_type = ?', origin_symbol, event_date - 1.day, trade_type).sum(&:amount) * (amount / snapshot_position.amount)
else
fee = 0
end
Expand Down
4 changes: 2 additions & 2 deletions app/models/user_position.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ def ranking
end

def funding_fee
FundingFeeHistory.where(user_id: user_id, origin_symbol: origin_symbol).sum(&:amount).round(4)
FundingFeeHistory.where(user_id: user_id, origin_symbol: origin_symbol, trade_type: trade_type).sum(&:amount).round(4)
end

def last_funding_fee
FundingFeeHistory.where(user_id: user_id, origin_symbol: origin_symbol).where('event_date < ?', Date.yesterday).sum(&:amount).round(4)
FundingFeeHistory.where(user_id: user_id, origin_symbol: origin_symbol, trade_type: trade_type).where('event_date < ?', Date.yesterday).sum(&:amount).round(4)
end

def notes
Expand Down

0 comments on commit da1d070

Please sign in to comment.