feat: saxo history
This commit is contained in:
@@ -26,7 +26,14 @@ _OPTION_ASSET_TYPES = "StockOption,StockIndexOption,FuturesOption,FxVanillaOptio
|
||||
# Applied around a Black-Scholes theoretical price when Saxo returns no live Bid/Ask (FX
|
||||
# options in particular go quiet outside FX market hours — closed over the weekend) but
|
||||
# still supplies MidVolatility/Greeks from its own model, so IV/spot/strike are usable.
|
||||
#
|
||||
# Calibrated against a real Saxo EURUSD chain: the quoted spread there sits at a near-
|
||||
# constant ~9-10 pips (~0.0009-0.0010) in ABSOLUTE terms across every strike/expiry —
|
||||
# 40%+ of the premium for a cheap OTM contract, ~8% for an expensive one. A pure
|
||||
# percentage-of-premium spread badly underprices the OTM end, so the wider of the two
|
||||
# (percentage floor vs. a spot-scaled absolute floor) is used.
|
||||
_SYNTHETIC_SPREAD_PCT = 0.05
|
||||
_SYNTHETIC_SPREAD_FLOOR_PCT_OF_SPOT = 0.0008
|
||||
_SYNTHETIC_RATE = 0.02
|
||||
|
||||
|
||||
@@ -44,7 +51,8 @@ def _synthesize_quote(
|
||||
theo = float(black_scholes(spot, strike, T, _SYNTHETIC_RATE, iv_pct / 100.0, option_type)["price"])
|
||||
if theo <= 0:
|
||||
return None, None, None
|
||||
half_spread = theo * _SYNTHETIC_SPREAD_PCT / 2
|
||||
full_spread = max(theo * _SYNTHETIC_SPREAD_PCT, spot * _SYNTHETIC_SPREAD_FLOOR_PCT_OF_SPOT)
|
||||
half_spread = full_spread / 2
|
||||
bid = round(max(0.0, theo - half_spread), 6)
|
||||
ask = round(theo + half_spread, 6)
|
||||
return bid, ask, round((bid + ask) / 2, 6)
|
||||
|
||||
Reference in New Issue
Block a user