Skip to content

Commit bff59ab

Browse files
committed
修复保证金计算错误
1 parent 01e880e commit bff59ab

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

trader/strategy/brother2.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -740,17 +740,15 @@ def calculate(self, day, create_main_bar=True):
740740
p_code_set = set(self.__inst_ids)
741741
for code in self.__cur_pos.keys():
742742
p_code_set.add(self.__re_extract_code.match(code).group(1))
743-
sig_dict = dict()
743+
all_margin = 0
744744
for inst in Instrument.objects.all().order_by('exchange', 'product_code'):
745745
if create_main_bar:
746746
logger.debug(f'生成连续合约: {inst.name}')
747747
calc_main_inst(inst, day)
748748
if inst.product_code in p_code_set:
749749
logger.debug(f'计算交易信号: {inst.name}')
750750
sig, margin = self.calc_signal(inst, day)
751-
if sig:
752-
sig_dict[sig] = margin
753-
all_margin = sum(sig_dict.values())
751+
all_margin += margin
754752
if (all_margin + self.__margin) / self.__current > 0.80:
755753
logger.info(f"!!!风险提示!!!开仓保证金共计: {all_margin:.0f}({all_margin/10000:.1f}万) "
756754
f"账户风险度将达到: {100 * (all_margin + self.__margin) / self.__current:.0f}% "

0 commit comments

Comments
 (0)