Yea, I'm also annoyed with the need to type code twice. Actually it's the types 
typed twice, the keys typed **4 times** , 1) in object definition 2) in `init` 
args 3 and 4) in object initialisation as `key: key`
    
    
    type HedgedStock* = object
      id*:           string
      evol*:         float
      safe_mv*:      float
      min_tenor*:    float
      min_hedge_mv*: float
      stocks*:       seq[UStock]
      puts*:         seq[UOption]
    
    proc init*(
      _:            type[HedgedStock],
      id:           string,
      evol:         float,
      safe_mv:      float,
      min_tenor:    float              = 120.0,
      min_hedge_mv: float              = 0.02,
      stocks:       openarray[UStock],
      puts:         openarray[UOption]
    ): HedgedStock =
      assert evol > 1.0
      HedgedStock(
        id: id, evol: evol, safe_mv: safe_mv,
        min_tenor: min_tenor, min_hedge_mv: min_hedge_mv,
        stocks: stocks.to_seq, puts: puts.to_seq
      )
    
    
    Run

Reply via email to