Skip to content

Commit

Permalink
Add additional limit parameters for BettingInstrument
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdsellers committed Jan 17, 2025
1 parent f8eafd6 commit a638a7f
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 14 deletions.
1 change: 1 addition & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Released on TBD (UTC).
### Enhancements
- Added `high-precision` mode for 128-bit integer backed value types, see [RFC](https://github.com/nautechsystems/nautilus_trader/issues/2084) and [precision mode](https://nautilustrader.io/docs/nightly/getting_started/installation#precision-mode) docs (#2072), thanks @twitu
- Added `log_commands` config option for `ActorConfig`, `StrategyConfig`, `ExecAlgorithmConfig` for more efficient log filtering
- Added additional limit parameters for `BettingInstrument` constructor

### Breaking Changes
- Renamed `event_logging` config option to `log_events`
Expand Down
1 change: 1 addition & 0 deletions nautilus_trader/adapters/betfair/parsing/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# -------------------------------------------------------------------------------------------------

import hashlib
from functools import lru_cache

Expand Down
50 changes: 36 additions & 14 deletions nautilus_trader/model/instruments/betting.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,17 @@ cdef class BettingInstrument(Instrument):
int8_t size_precision,
uint64_t ts_event,
uint64_t ts_init,
str tick_scheme_name = None,
Price min_price: Price | None = None,
Quantity max_quantity: Quantity | None = None,
Quantity min_quantity: Quantity | None = None,
Money max_notional: Money | None = None,
Money min_notional: Money | None = None,
Price max_price: Price | None = None,
Price min_price: Price | None = None,
margin_init: Decimal | None = None,
margin_maint: Decimal | None = None,
maker_fee: Decimal | None = None,
taker_fee: Decimal | None = None,
str tick_scheme_name = None,
dict info = None,
) -> None:
assert event_open_date.tzinfo or market_start_time.tzinfo is not None
Expand Down Expand Up @@ -116,12 +120,12 @@ cdef class BettingInstrument(Instrument):
size_increment=Quantity(0.01, precision=size_precision),
multiplier=Quantity.from_int_c(1),
lot_size=Quantity.from_int_c(1),
max_quantity=None, # Can be None
min_quantity=None, # Can be None
max_notional=None, # Can be None
min_notional=Money(1, Currency.from_str_c(currency)),
max_price=None, # Can be None
min_price=None, # Can be None
max_quantity=max_quantity,
min_quantity=min_quantity,
max_notional=max_notional,
min_notional=min_notional or Money(1, Currency.from_str_c(currency)),
max_price=max_price,
min_price=min_price,
margin_init=margin_init or Decimal(1),
margin_maint=margin_maint or Decimal(1),
maker_fee=maker_fee or Decimal(0),
Expand All @@ -143,6 +147,30 @@ cdef class BettingInstrument(Instrument):
data["event_open_date"] = pd.Timestamp(data["event_open_date"], tz="UTC")
data["market_start_time"] = pd.Timestamp(data["market_start_time"], tz="UTC")

max_quantity = data.get("max_quantity")
if max_quantity:
data["max_quantity"] = Quantity.from_str(max_quantity)

min_quantity = data.get("min_quantity")
if min_quantity:
data["min_quantity"] = Quantity.from_str(min_quantity)

max_notional = data.get("max_notional")
if max_notional:
data["max_notional"] = Money.from_str(max_notional)

min_notional = data.get("min_notional")
if min_notional:
data["min_notional"] = Money.from_str(min_notional)

max_price = data.get("max_price")
if max_price:
data["max_price"] = Price.from_str(max_price)

min_price = data.get("min_price")
if min_price:
data["min_price"] = Price.from_str(min_price)

margin_init = data.get("margin_init")
if margin_init:
data["margin_init"] = Decimal(margin_init)
Expand All @@ -162,12 +190,6 @@ cdef class BettingInstrument(Instrument):
data.pop("raw_symbol", None)
data.pop("price_increment", None)
data.pop("size_increment", None)
data.pop("max_quantity", None)
data.pop("min_quantity", None)
data.pop("max_notional", None)
data.pop("min_notional", None)
data.pop("max_price", None)
data.pop("min_price", None)
return BettingInstrument(**{k: v for k, v in data.items() if k not in ("id", "type")})

@staticmethod
Expand Down

0 comments on commit a638a7f

Please sign in to comment.