<commit_before>- cache do
  ruby:
      chart_data = {}
      @snapshots.each do |snapshot|
        snapshot.exchange_runs.each do |ex_run|
          chart_data[ex_run.exchange] ||= [ ex_run.exchange.name, [], [] ]

          depth_runs = ex_run.depth_runs.includes(:best_offer).all
          if depth_runs.size == 2
            o=depth_runs.first # tofix: bid/ask detection
            op = o.best_offer ? o.best_offer.price : nil
            chart_data[ex_run.exchange][1] << [o.created_at.to_i*1000, op]
            o=depth_runs.last # tofix: bid/ask detection
            op = o.best_offer ? o.best_offer.price : nil
            chart_data[ex_run.exchange][2] << [o.created_at.to_i*1000, op]
          end
        end
      end
      @chart_data = chart_data.map{|k,v| v}

      @strategy_data = @snapshots.map{|s| [s.created_at.to_i*1000,
                                          s.strategy.potential.amount.to_f] if s.strategy}
      @strategy_ids = @snapshots.map{|s| s.strategy.id if s.strategy}
      @strategy_percentages = @snapshots.map{|s| [s.created_at.to_i*1000,
                                                  s.strategy.profit_percentage.to_f] if s.strategy}

  h2 Bitcoin/USD Arbitrage Strategy Report

  section#strategy
    - if @strategy
      h4
        | Strategy
        '  #{link_to "##{@strategy.id}", @strategy}
        time datetime="#{@strategy.created_at.iso8601}" data-format="yyyy-MMM-dd hh:mmtt"
        '
        span.local_timezone

      section#opportunity style="margin-bottom: 1em"
        div style="width: 45em"
          - trade_stage = @strategy.stage.children.select{|s| s.name=="Trades"}.first
          ' For the #{Exchange.actives.count} exchanges being monitored, the total value of offers
          ' that have immediate buyers is
          span style="font-size: 110%; font-weight:bold; color:#{trade_stage.potential < 0 ? "#e00" : "black"}"
            ' #{trade_stage.balance_in}.
          - if trade_stage.balance_in > 0.01
            ' Selling immediately,
            ' including market fees, earns
            span style="font-size: 110%; font-weight:bold; color:#{trade_stage.potential < 0 ? "#e00" : "black"}"
              '  #{trade_stage.balance_out}

            ' for a profit of
            span style="font-size: 110%; font-weight:bold; color:#{trade_stage.potential < 0 ? "#e00" : "black"}"
              ' #{trade_stage.potential} (#{"%0.3f"%trade_stage.profit_percentage}%).
            - trade_stage_moves = @strategy.stage.children.select{|s| s.name=="Moves"}.first
            ' Estimated transfer fees of
            span style="font-size: 110%; font-weight:bold"
              ' #{trade_stage_moves.balance_in - trade_stage.balance_in}
            ' adjust total profit to
            span style="font-size: 110%; font-weight:bold; color:#{@strategy.potential < 0 ? "#e00" : "black"}"
              ' #{@strategy.potential} (#{"%0.3f"%@strategy.profit_percentage}%)
          - else
            ' The different
            ' exchanges are close enough that no opportunity is currently available.
      section#trade_summary
        div style="float:left"
          i
            | ---- transfer USD ---->&nbsp;
        table style="float:left"
          - @strategy.exchange_balances.select{|eb| eb.balances.select{|b|b.usd? && b>0}.any?}.each do |eb|
            tr
              td
                a href="#{exchange_path(eb.exchange)}" style="color: black" #{eb.exchange.name}
              - eb.balances.each do |b|
                td
                  - if b > 0
                    | buy #{b}
        div style="float:left"
          i
            | &nbsp;---- transfer BTC ---->&nbsp;
        table style="float:left"
          - @strategy.exchange_balances.select{|eb| eb.balances.select{|b|b.btc? && b>0}.any?}.each do |eb|
            tr
              td
                a href="#{exchange_path(eb.exchange)}" style="color: black" #{eb.exchange.name}<commit_msg>drop transfer fee estimate<commit_after>- cache do
  ruby:
      chart_data = {}
      @snapshots.each do |snapshot|
        snapshot.exchange_runs.each do |ex_run|
          chart_data[ex_run.exchange] ||= [ ex_run.exchange.name, [], [] ]

          depth_runs = ex_run.depth_runs.includes(:best_offer).all
          if depth_runs.size == 2
            o=depth_runs.first # tofix: bid/ask detection
            op = o.best_offer ? o.best_offer.price : nil
            chart_data[ex_run.exchange][1] << [o.created_at.to_i*1000, op]
            o=depth_runs.last # tofix: bid/ask detection
            op = o.best_offer ? o.best_offer.price : nil
            chart_data[ex_run.exchange][2] << [o.created_at.to_i*1000, op]
          end
        end
      end
      @chart_data = chart_data.map{|k,v| v}

      @strategy_data = @snapshots.map{|s| [s.created_at.to_i*1000,
                                          s.strategy.potential.amount.to_f] if s.strategy}
      @strategy_ids = @snapshots.map{|s| s.strategy.id if s.strategy}
      @strategy_percentages = @snapshots.map{|s| [s.created_at.to_i*1000,
                                                  s.strategy.profit_percentage.to_f] if s.strategy}

  h2 Bitcoin/USD Arbitrage Strategy Report

  section#strategy
    - if @strategy
      h4
        | Strategy
        '  #{link_to "##{@strategy.id}", @strategy}
        time datetime="#{@strategy.created_at.iso8601}" data-format="yyyy-MMM-dd hh:mmtt"
        '
        span.local_timezone

      section#opportunity style="margin-bottom: 1em"
        div style="width: 45em"
          - trade_stage = @strategy.stage.children.select{|s| s.name=="Trades"}.first
          ' For the #{Exchange.actives.count} exchanges being monitored, the total value of offers
          ' that have immediate buyers is
          span style="font-size: 110%; font-weight:bold; color:#{trade_stage.potential < 0 ? "#e00" : "black"}"
            ' #{trade_stage.balance_in}.
          - if trade_stage.balance_in > 0.01
            ' Selling immediately,
            ' including market fees, earns
            span style="font-size: 110%; font-weight:bold; color:#{trade_stage.potential < 0 ? "#e00" : "black"}"
              '  #{trade_stage.balance_out}

            ' for a profit of
            span style="font-size: 110%; font-weight:bold; color:#{trade_stage.potential < 0 ? "#e00" : "black"}"
              ' #{trade_stage.potential} (#{"%0.3f"%trade_stage.profit_percentage}%).
            - trade_stage_moves = @strategy.stage.children.select{|s| s.name=="Moves"}.first
            /!
              ' Estimated transfer fees of
              span style="font-size: 110%; font-weight:bold"
                ' #{trade_stage_moves.balance_in - trade_stage.balance_in}
              ' adjust total profit to
              span style="font-size: 110%; font-weight:bold; color:#{@strategy.potential < 0 ? "#e00" : "black"}"
                ' #{@strategy.potential} (#{"%0.3f"%@strategy.profit_percentage}%)
          - else
            ' The different
            ' exchanges are close enough that no opportunity is currently available.
      section#trade_summary
        div style="float:left"
          i
            | ---- transfer USD ---->&nbsp;
        table style="float:left"
          - @strategy.exchange_balances.select{|eb| eb.balances.select{|b|b.usd? && b>0}.any?}.each do |eb|
            tr
              td
                a href="#{exchange_path(eb.exchange)}" style="color: black" #{eb.exchange.name}
              - eb.balances.each do |b|
                td
                  - if b > 0
                    | buy #{b}
        div style="float:left"
          i
            | &nbsp;---- transfer BTC ---->&nbsp;
        table style="float:left"
          - @strategy.exchange_balances.select{|eb| eb.balances.select{|b|b.btc? && b>0}.any?}.each do |eb|
            tr
              td
                a href="#{exchange_path(eb.exchange)}" style="color: black" #{eb.exchange.name}
{'fraction_non_alphanumeric': 0.13702770780856424, 'fraction_numerical': 0.0163727959697733, 'mean_word_length': 1.9741573033707864, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2621081', 'n_tokens_mistral': 2674, 'n_tokens_neox': 2440, 'n_words': 478}