import numpy as np
import matplotlib.pyplot as plt
# 参数设置
A = 100
delta_ba = np.array([1, 5, 10]) # 时间差,以秒为单位
k_values = [0.05, 0.1, 0.01] # 不同的k值
# 计算不同k值下的λb,a
def calculate_lambda(A, k, delta):
return A * np.exp(-k * delta)
# 进行计算并打印结果
for k in k_values:
lambda_ba = calculate_lambda(A, k, delta_ba)
print(f"For k = {k}:")
for delta, lam in zip(delta_ba, lambda_ba):
print(f" delta = {delta}s -> λb,a = {lam:.2f}")
# 可视化结果
plt.figure(figsize=(8, 5))
for k in k_values:
lambda_ba = calculate_lambda(A, k, delta_ba)
plt.plot(delta_ba, lambda_ba, marker='o', label=f'k={k}')
plt.xlabel('Time Difference Δb,a (seconds)')
plt.ylabel('Interaction Rate λb,a')
plt.title('Sensitivity of λb,a to k in High-Frequency Trading')
plt.legend()
plt.grid(True)
plt.show()