Administrator
2023-09-25 b696ad64d69705c03d43406f1d1d2010b16923bb
trade/l2_trade_factor.py
@@ -6,6 +6,7 @@
from code_attribute import big_money_num_manager, limit_up_time_manager, global_data_loader, gpcode_manager
import constant
from trade import trade_manager
from utils import global_util, tool
@@ -114,6 +115,11 @@
        self.now_time = now_time
        self.buy_rank = self.get_buy_rank()
    # 是否是初次下单
    @classmethod
    def is_first_place_order(cls, code):
        return trade_manager.CodesTradeStateManager().get_trade_state_cache(code) == trade_manager.TRADE_STATE_NOT_TRADE
    # 设置分数
    def set_score(self, score):
        score_ranks = [constant.BUY_SCORE_RANK_3, constant.BUY_SCORE_RANK_2, constant.BUY_SCORE_RANK_1,
@@ -146,6 +152,9 @@
        volume_rate_index = self.volume_rate_index
        if self.volume_rate_index >= len(ts):
            volume_rate_index = -1
        # 首次下单必须同1s
        if self.is_first_place_order(self.code):
            return 1
        return ts[volume_rate_index]
    # 获取需要的大单个数
@@ -161,6 +170,9 @@
        volume_rate_index = self.volume_rate_index
        if self.volume_rate_index >= len(counts):
            volume_rate_index = -1
        # 第一次下单必须为2个
        if self.is_first_place_order(self.code):
            return 2
        return counts[volume_rate_index]
    # 获取安全笔数影响比例
@@ -200,6 +212,8 @@
    # 获取m值
    def get_m_val(self):
        base_m = self.get_base_m_val(self.code)
        if self.is_first_place_order(self.code):
            base_m = int(base_m * 1.5)
        rate = self.get_m_val_rate(self.volume_rate_index)
        m = round(base_m * (1 + rate))
        return m, ""