策略失效时,坚守还是放弃

投资者经常会碰到其使用的策略和当前市场实际有效的策略不吻合的问题,该放弃还是坚守?

今天忽然想到一个可以类比的问题:两人走散时,一个试图寻找,另一个应该呆在原地等还是互相寻找?似乎可以理解为市场本身总在寻找新的有效策略,投资者要不要一起找。问了下deepseek,答说理论上是互相寻找更好,实际用deepseek生成的代码验证后也是如此,在10*10的网格中两种策略重复1000次的结果如下:
A不动的话平均所需: 238.64 步
A移动的话平均所需: 182.22 步

话虽如此,强逻辑策略投资者自然不肯放弃,比如价值投资者,但似乎这就是大奖章能傲视群雄的基本策略:不断放弃旧的并寻找新的弱逻辑策略

PS:代码如下
import numpy as np
import random
import matplotlib.pyplot as plt

class GridWorld:
def __init__(self, size=10):
    self.size = size  # n x n grid
    self.positions = {}  # tracks positions of A and B

def initialize_positions(self):
    # Randomly place A and B in the grid
    self.positions['A'] = (random.randint(0, self.size-1), random.randint(0, self.size-1))
    self.positions['B'] = (random.randint(0, self.size-1), random.randint(0, self.size-1))
    # Ensure A and B start at different positions
    while self.positions['A'] == self.positions['B']:
        self.positions['B'] = (random.randint(0, self.size-1), random.randint(0, self.size-1))

def move_random(self, agent):
    x, y = self.positions[agent]
    possible_moves = []
    # Possible moves: up, down, left, right (no diagonal)
    if x > 0:
        possible_moves.append((x-1, y))  # up
    if x < self.size - 1:
        possible_moves.append((x+1, y))  # down
    if y > 0:
        possible_moves.append((x, y-1))  # left
    if y < self.size - 1:
        possible_moves.append((x, y+1))  # right
    # Randomly choose a move
    if possible_moves:
        self.positions[agent] = random.choice(possible_moves)

def simulate_strategy_stay(self, max_steps=1000):
    """Simulate Strategy S: A stays, B moves randomly."""
    self.initialize_positions()
    a_pos = self.positions['A']
    steps = 0
    while steps < max_steps:
        if self.positions['B'] == a_pos:
            return steps  # A and B meet
        self.move_random('B')
        steps += 1
    return max_steps  # did not meet within max_steps

def simulate_strategy_move(self, max_steps=1000):
    """Simulate Strategy M: A and B both move randomly (synchronously)."""
    self.initialize_positions()
    steps = 0
    while steps < max_steps:
        # Store old positions to check if they cross paths
        old_a_pos = self.positions['A']
        old_b_pos = self.positions['B']

        # Move A and B
        self.move_random('A')
        self.move_random('B')

        # Check if they meet after moving
        if self.positions['A'] == self.positions['B']:
            return steps + 1  # +1 since they move simultaneously

        # Optional: Check if they swapped positions (crossed paths)
        if (self.positions['A'] == old_b_pos) and (self.positions['B'] == old_a_pos):
            return steps + 1  # they crossed paths and met

        steps += 1
    return max_steps  # did not meet within max_steps

def run_simulation(grid_size=10, num_trials=1000, max_steps=1000):
"""Run simulations for both strategies and compare."""
grid = GridWorld(size=grid_size)
stay_times = []
move_times = []

for _ in range(num_trials):
    stay_times.append(grid.simulate_strategy_stay(max_steps))
    move_times.append(grid.simulate_strategy_move(max_steps))

# Compute statistics
avg_stay = np.mean(stay_times)
avg_move = np.mean(move_times)

print(f"Average meeting time (A stays): {avg_stay:.2f} steps")
print(f"Average meeting time (A moves): {avg_move:.2f} steps")

# Plot results
plt.figure(figsize=(10, 6))
plt.hist(stay_times, bins=50, alpha=0.5, label='A stays, B moves')
plt.hist(move_times, bins=50, alpha=0.5, label='A and B both move')
plt.xlabel('Meeting Time (steps)')
plt.ylabel('Frequency')
plt.title('Comparison of Meeting Times for Two Strategies')
plt.legend()
plt.show()

Run the simulation

run_simulation(grid_size=10, num_trials=1000)
发表时间 2025-06-29 12:47     最后修改时间 2025-06-29 13:02     来自上海

赞同来自: 万里无云11 研究一下可转债 genamax 流沙少帅

0

zhouxc

赞同来自:

既然是失效,还坚持个啥呢
2025-07-01 18:20 来自上海 引用
0

yeunglee

赞同来自:

@bigbear2046
现实难道不是一步步走,而是跳跃的?
而且按你的逻辑不是和空间无关,而是变成只和空间有关,每次move到的点就是1/(N*N)的概率...
在这个问题上,你再仔细想想是应该是跳跃,还是不跳跃?另外,如果真的不跳跃,凭什么只有上下左右4个方向?不能是8个方向或者其他?凭什么左上跳到右下,要经过那么漫长的步数?
2025-07-01 17:23 来自香港 引用
0

bigbear2046 - 无非想要明白些道理,遇见些有趣的人或事

赞同来自:

@yeunglee
再仔细想想?其实不是空间问题。你代码默认策略间有距离,且只能按距离最小移动,现实并不是。你的move_random,应该是在N*N的范围内随机找一个坐标(x,y),作为一个move。
现实难道不是一步步走,而是跳跃的?
而且按你的逻辑不是和空间无关,而是变成只和空间有关,每次move到的点就是1/(N*N)的概率...
2025-07-01 16:30修改 来自上海 引用
0

yeunglee

赞同来自:

@bigbear2046
有限空间我试着扩大到20*20直至100*100,上面结论依然有效,实际上有限空间有概率优势,没道理无限空间却失去优势,除非有什么隐性因子和规模反向,无限空间如果随机大概率是找不到
再仔细想想?其实不是空间问题。你代码默认策略间有距离,且只能按距离最小移动,现实并不是。你的move_random,应该是在N*N的范围内随机找一个坐标(x,y),作为一个move。
2025-07-01 14:47 来自香港 引用
0

bigbear2046 - 无非想要明白些道理,遇见些有趣的人或事

赞同来自:

@zengqlleo
这是有限空间,无限空间就不是这样了。原地不动找到的概率大
有限空间我试着扩大到20*20直至100*100,上面结论依然有效,实际上有限空间有概率优势,没道理无限空间却失去优势,除非有什么隐性因子和规模反向,无限空间如果随机大概率是找不到
2025-06-30 18:18 来自上海 引用
1

zengqlleo

赞同来自: qianfa

这是有限空间,无限空间就不是这样了。原地不动找到的概率大
2025-06-30 15:30 来自北京 引用
0

bigbear2046 - 无非想要明白些道理,遇见些有趣的人或事

赞同来自:

@春秋战国
迷路时反思为啥会迷路有什么问题?像无头苍蝇一样乱动?
数学结论似乎是…
2025-06-30 08:53 来自移动 引用
0

春秋战国

赞同来自:

@bigbear2046
所以迷路时先反思为啥迷路,而不是先行动起来:)
迷路时反思为啥会迷路有什么问题?像无头苍蝇一样乱动?
2025-06-30 08:50 来自福建 引用
0

bigbear2046 - 无非想要明白些道理,遇见些有趣的人或事

赞同来自:

@pondfish
预期与现实不一致的时候,先分析为啥不一致,而不是做决定。
所以迷路时先反思为啥迷路,而不是先行动起来:)
2025-06-30 07:08 来自上海 引用
2

pondfish

赞同来自: 红糖饼 wangchengf

预期与现实不一致的时候,先分析为啥不一致,而不是做决定。
2025-06-29 23:58 来自广西 引用

要回复问题请先登录注册

发起人

bigbear2046
bigbear2046

无非想要明白些道理,遇见些有趣的人或事

问题状态

  • 最新活动: 2025-07-01 18:20
  • 浏览: 3408
  • 关注: 33