Tweak py to get rid of false positive type hint warns
This commit is contained in:
1 parent
b94cdb561e
commit
fe74aed048
1 file changed
+9
-14
@@ -306,23 +306,18 @@ def get_security(
|
||||
if not spec:
|
||||
spec = get_contract_spec()
|
||||
sec.set_contract_spec(spec)
|
||||
is_spot = expiration is None and option_kind is None and strike is None
|
||||
is_future = expiration is not None and option_kind is None and strike is None
|
||||
is_option = (
|
||||
expiration is not None and option_kind is not None and strike is not None
|
||||
)
|
||||
if is_spot:
|
||||
sec.set_spot(pycore.PySpot())
|
||||
elif is_future:
|
||||
if expiration and strike and option_kind:
|
||||
opt = pycore.PyOption()
|
||||
opt.set_expiration(expiration)
|
||||
opt.set_is_call(option_kind[0].lower() == "c")
|
||||
opt.set_strike(strike)
|
||||
sec.set_option(opt)
|
||||
elif expiration and not strike and not option_kind:
|
||||
fut = pycore.PyFuture()
|
||||
fut.set_expiration(expiration)
|
||||
sec.set_future(fut)
|
||||
elif is_option:
|
||||
opt = pycore.PyOption()
|
||||
opt.set_expiration(expiration)
|
||||
opt.set_is_call(option_kind.lower().startswith("c"))
|
||||
opt.set_strike(strike)
|
||||
sec.set_option(opt)
|
||||
elif not expiration and not strike and not option_kind:
|
||||
sec.set_spot(pycore.PySpot())
|
||||
else:
|
||||
raise ValueError("Invalid parameters (unable to deduce security type)")
|
||||
return sec
|
||||
Reference in new issue
Block a user