Skip to content

Commit ffaa6de

Browse files
committed
Update forex slippage values
1 parent 217b78b commit ffaa6de

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

meta/meta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"subnet_version": "6.8.6"
2+
"subnet_version": "6.8.7"
33
}

vali_objects/utils/price_slippage_model.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import math
22
from collections import defaultdict
3+
from zoneinfo import ZoneInfo
34

45
import holidays
56
import numpy as np
@@ -22,6 +23,7 @@ class PriceSlippageModel:
2223
slippage_estimates: dict = {}
2324
live_price_fetcher: LivePriceFetcher = None
2425
holidays_nyse = None
26+
eastern_tz = None
2527
is_backtesting = False
2628
fetch_slippage_data = False
2729
recalculate_slippage = False
@@ -115,10 +117,14 @@ def calc_slippage_forex(cls, bid:float, ask:float, order:Order) -> float:
115117
slippage percentage = 0.433 * spread/mid_price + 0.335 * sqrt(annualized_volatility**2 / 3 / 250) * sqrt(volume / (0.3 * estimated daily volume))
116118
"""
117119
if order.processed_ms > SLIPPAGE_V2_TIME_MS:
118-
if order.trade_pair.subcategory == ForexSubcategory.G1:
119-
return 0.001 # 10 bps
120+
if cls.eastern_tz is None:
121+
cls.eastern_tz = ZoneInfo("America/New_York")
122+
order_datetime = TimeUtil.millis_to_datetime(order.processed_ms).astimezone(cls.eastern_tz)
123+
hour = order_datetime.hour
124+
if 17 <= hour < 18: # Daily 5-6 pm EST. Higher slippage during market open/closing hours
125+
return 0.001 # 10 bps
120126
else:
121-
return 0.0015 # 15 bps
127+
return 0.0005 # 5 bps
122128

123129
order_date = TimeUtil.millis_to_short_date_str(order.processed_ms)
124130
annualized_volatility = cls.features[order_date]["vol"][order.trade_pair.trade_pair_id]

0 commit comments

Comments
 (0)