edition = "2023";

package statistic;

import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";
import "types/amount/amount.proto";

option go_package = "github.com/michaelahli/sabot/proto/api/statistic";

enum TradeType {
  UnknownTradeType = 0;
  Long = 1;
  Short = 2;
}

enum TimeRange {
  UnknownTimeRange = 0;
  Day = 1;
  Week = 2;
  Month = 3;
}

message Statistic {
  // Capital is initial capital used for simulation.
  amount.Amount Capital = 1 [ json_name = "capital" ];
  // NetProfit is profit earned in simulation using the strategy.
  amount.Amount NetProfit = 2 [ json_name = "net_profit" ];
  // PercentProfitable is the percentage of profit divided by capital.
  string PercentProfitable = 3 [ json_name = "percent_profitable" ];
  // TotalClosedTrades is total trade being made using the strategy.
  google.protobuf.Int64Value TotalClosedTrades = 4
      [ json_name = "total_closed_trades" ];
  // TotalWinningTrades is total winning trade being made using the strategy.
  google.protobuf.Int64Value TotalWinningTrades = 5
      [ json_name = "total_winning_trades" ];
  // MaximumDrawdown is maximum losing amount being made using the strategy.
  amount.Amount MaximumDrawdown = 6 [ json_name = "maximum_drawdown" ];
  // WinRate is total winning trades divided by total closed trades.
  string WinRate = 7 [ json_name = "win_rate" ];
  // Details are list sets of trade has been made by algoritms.
  repeated Trades Details = 8 [ json_name = "details" ];
}

message Trades {
  // Label describe series name.
  string Label = 1 [ json_name = "label" ];
  // Trades are list sets of trade has been made by an algoritm.
  repeated Trade Trades = 2 [ json_name = "trades" ];
}

message Trade {
  // Capital is capital used for open position.
  amount.Amount Capital = 1 [ json_name = "capital" ];
  // OpenPosition is open position price to entry.
  amount.Amount OpenPosition = 2 [ json_name = "open_position" ];
  // ClosePosition is open position price to exit.
  amount.Amount ClosePosition = 3 [ json_name = "close_position" ];
  // TradeType represents type of trade can be either Long or Short.
  TradeType TradeType = 4 [ json_name = "type" ];
  // PnL represents percentage of close position divided by open position.
  string PnL = 5 [ json_name = "pnl" ];
}

