同步回测与tqsdk
This commit is contained in:
@@ -330,6 +330,8 @@ class SimpleLimitBuyStrategyShort(Strategy):
|
||||
# 只有当有持仓时才考虑平仓
|
||||
if current_pos_volume < 0: # 假设只做多,所以持仓量 > 0
|
||||
avg_entry_price = self.get_average_position_price(self.symbol)
|
||||
self.log(f'avg_entry_price {avg_entry_price}, bar.open {bar.open}')
|
||||
|
||||
if avg_entry_price is not None:
|
||||
pnl_per_unit = (
|
||||
avg_entry_price - bar.open
|
||||
|
||||
Reference in New Issue
Block a user