[Mod]change is_convert_required function
This commit is contained in:
parent
be3850fe3c
commit
1aa2faf4cb
@ -1,6 +1,5 @@
|
|||||||
""""""
|
""""""
|
||||||
from copy import copy
|
from copy import copy
|
||||||
from functools import lru_cache
|
|
||||||
|
|
||||||
from vnpy.trader.engine import MainEngine
|
from vnpy.trader.engine import MainEngine
|
||||||
from vnpy.trader.object import (
|
from vnpy.trader.object import (
|
||||||
@ -76,7 +75,6 @@ class OffsetConverter:
|
|||||||
else:
|
else:
|
||||||
return [req]
|
return [req]
|
||||||
|
|
||||||
@lru_cache()
|
|
||||||
def is_convert_required(self, vt_symbol: str):
|
def is_convert_required(self, vt_symbol: str):
|
||||||
"""
|
"""
|
||||||
Check if the contract needs offset convert.
|
Check if the contract needs offset convert.
|
||||||
@ -84,7 +82,7 @@ class OffsetConverter:
|
|||||||
contract = self.main_engine.get_contract(vt_symbol)
|
contract = self.main_engine.get_contract(vt_symbol)
|
||||||
|
|
||||||
# Only contracts with long-short position mode requires convert
|
# Only contracts with long-short position mode requires convert
|
||||||
if not contract.net_position:
|
if not contract or not contract.net_position:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user