Update template.py
This commit is contained in:
parent
2363583fc3
commit
f8b249500d
@ -1,5 +1,6 @@
|
|||||||
""""""
|
""""""
|
||||||
from abc import ABC
|
from abc import ABC
|
||||||
|
from copy import copy
|
||||||
from typing import Any, Callable
|
from typing import Any, Callable
|
||||||
|
|
||||||
from vnpy.trader.constant import Interval, Direction, Offset
|
from vnpy.trader.constant import Interval, Direction, Offset
|
||||||
@ -32,12 +33,12 @@ class CtaTemplate(ABC):
|
|||||||
self.trading = False
|
self.trading = False
|
||||||
self.pos = 0
|
self.pos = 0
|
||||||
|
|
||||||
if "inited" not in self.variables:
|
# Copy a new variables list here to avoid duplicate insert when multiple
|
||||||
self.variables.insert(0, "inited")
|
# strategy instances are created with the same strategy class.
|
||||||
if "trading" not in self.variables:
|
self.variables = copy(self.variables)
|
||||||
self.variables.insert(1, "trading")
|
self.variables.insert(0, "inited")
|
||||||
if "pos" not in self.variables:
|
self.variables.insert(1, "trading")
|
||||||
self.variables.insert(2, "pos")
|
self.variables.insert(2, "pos")
|
||||||
|
|
||||||
self.update_setting(setting)
|
self.update_setting(setting)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user