@@ -79,14 +79,16 @@ impl EquityOption{
7979 }
8080}
8181impl EquityOption {
82- //pub fn new(x:T)->Self{
83- //
84- //}
82+
8583 pub fn from_json ( data : & Contract ) -> Box < EquityOption > {
8684 let payoff_type = data. payoff_type . as_ref ( ) . unwrap ( ) . parse :: < PayoffType > ( ) ;
8785 let market_data = data. market_data . as_ref ( ) . unwrap ( ) ;
88- let option_type = & market_data. option_type ;
86+ // let option_type = &market_data.option_type;
8987 let side: OptionType ;
88+ let option_type = match & market_data. option_type {
89+ Some ( x) => x. clone ( ) ,
90+ None => "" . to_string ( ) ,
91+ } ;
9092 match option_type. trim ( ) {
9193 "C" | "c" | "Call" | "call" => side = OptionType :: Call ,
9294 "P" | "p" | "Put" | "put" => side = OptionType :: Put ,
@@ -130,7 +132,7 @@ impl EquityOption {
130132 transection : Transection :: Buy ,
131133 underlying_price : underlying_quote,
132134 current_price : option_price,
133- strike_price : market_data. strike_price ,
135+ strike_price : market_data. strike_price . unwrap_or ( 0.0 ) ,
134136 volatility : volatility,
135137 maturity_date : future_date,
136138 risk_free_rate : risk_free_rate. unwrap_or ( 0.0 ) ,
0 commit comments