def btcusdt_binance() -> Instrument: """ Return the Binance BTC/USDT instrument for backtesting. """ return Instrument( symbol=Symbol("BTC/USDT", Venue("BINANCE")), asset_class=AssetClass.CRYPTO, asset_type=AssetType.SPOT, base_currency=BTC, quote_currency=USDT, settlement_currency=USDT, is_inverse=False, price_precision=2, size_precision=6, tick_size=Decimal("0.01"), multiplier=Decimal("1"), leverage=Decimal("1"), lot_size=Quantity("1"), max_quantity=Quantity("9000.0"), min_quantity=Quantity("1e-06"), max_notional=None, min_notional=Money("10.00000000", USDT), max_price=Price("1000000.0"), min_price=Price("0.01"), margin_init=Decimal(), margin_maint=Decimal(), maker_fee=Decimal("0.001"), taker_fee=Decimal("0.001"), financing={}, timestamp=UNIX_EPOCH, )
def ethusd_bitmex(leverage: Decimal=Decimal("1.0")) -> Instrument: """ Return the BitMEX ETH/USD perpetual contract for backtesting. """ return Instrument( symbol=Symbol("ETH/USD", Venue("BITMEX")), asset_class=AssetClass.CRYPTO, asset_type=AssetType.SWAP, base_currency=ETH, quote_currency=USD, settlement_currency=BTC, is_inverse=True, price_precision=2, size_precision=0, tick_size=Decimal("0.05"), multiplier=Decimal("1"), leverage=leverage, lot_size=Quantity(1), max_quantity=Quantity("10000000.0"), min_quantity=Quantity("1.0"), max_notional=None, min_notional=None, max_price=Price("1000000.00"), min_price=Price("0.05"), margin_init=Decimal("0.02"), margin_maint=Decimal("0.007"), maker_fee=Decimal("-0.00025"), taker_fee=Decimal("0.00075"), financing={}, timestamp=UNIX_EPOCH, )
def default_fx_ccy(symbol: Symbol, leverage: Decimal=Decimal("50")) -> Instrument: """ Return a default FX currency pair instrument from the given symbol. Parameters ---------- symbol : Symbol The currency pair symbol. leverage : Decimal, optional The leverage for the instrument. Raises ------ ValueError If the symbol.code length is not in range [6, 7]. """ PyCondition.not_none(symbol, "symbol") PyCondition.in_range_int(len(symbol.code), 6, 7, "len(symbol)") base_currency = symbol.code[:3] quote_currency = symbol.code[-3:] # Check tick precision of quote currency if quote_currency == 'JPY': price_precision = 3 else: price_precision = 5 return Instrument( symbol=symbol, asset_class=AssetClass.FX, asset_type=AssetType.SPOT, base_currency=Currency.from_str(base_currency), quote_currency=Currency.from_str(quote_currency), settlement_currency=Currency.from_str(quote_currency), is_inverse=False, price_precision=price_precision, size_precision=0, tick_size=Decimal(f"{1 / 10 ** price_precision:.{price_precision}f}"), multiplier=Decimal("1"), leverage=leverage, lot_size=Quantity("1000"), max_quantity=Quantity("1e7"), min_quantity=Quantity("1000"), max_price=None, min_price=None, max_notional=Money(50000000.00, USD), min_notional=Money(1000.00, USD), margin_init=Decimal("0.03"), margin_maint=Decimal("0.03"), maker_fee=Decimal("0.00002"), taker_fee=Decimal("0.00002"), financing={}, timestamp=UNIX_EPOCH, )
def xbtusd_bitmex(leverage: Decimal = Decimal("1.0")) -> Instrument: """ Return the BitMEX XBT/USD perpetual contract for backtesting. Parameters ---------- leverage : Decimal The margined leverage for the instrument. Returns ------- Instrument """ instrument_id = InstrumentId( symbol=Symbol("XBT/USD"), venue=Venue("BITMEX"), ) return Instrument( instrument_id=instrument_id, asset_class=AssetClass.CRYPTO, asset_type=AssetType.SWAP, base_currency=BTC, quote_currency=USD, settlement_currency=BTC, is_inverse=True, price_precision=1, size_precision=0, tick_size=Decimal("0.5"), multiplier=Decimal("1"), leverage=leverage, lot_size=Quantity(1), max_quantity=None, min_quantity=None, max_notional=Money("10000000.0", USD), min_notional=Money("1.0", USD), max_price=Price("1000000.0"), min_price=Price("0.5"), margin_init=Decimal("0.01"), margin_maint=Decimal("0.0035"), maker_fee=Decimal("-0.00025"), taker_fee=Decimal("0.00075"), financing={}, timestamp=UNIX_EPOCH, )
def ethusdt_binance() -> Instrument: """ Return the Binance ETH/USDT instrument for backtesting. Returns ------- Instrument """ instrument_id = InstrumentId( symbol=Symbol("ETH/USDT"), venue=Venue("BINANCE"), ) return Instrument( instrument_id=instrument_id, asset_class=AssetClass.CRYPTO, asset_type=AssetType.SPOT, base_currency=ETH, quote_currency=USDT, settlement_currency=USDT, is_inverse=False, price_precision=2, size_precision=5, tick_size=Decimal("0.01"), multiplier=Decimal("1"), leverage=Decimal("1"), lot_size=Quantity("1"), max_quantity=Quantity("9000"), min_quantity=Quantity("1e-05"), max_notional=None, min_notional=Money("10.00000000", USDT), max_price=Price("1000000.0"), min_price=Price("0.01"), margin_init=Decimal("1.00"), margin_maint=Decimal("0.35"), maker_fee=Decimal("0.0001"), taker_fee=Decimal("0.0001"), financing={}, timestamp=UNIX_EPOCH, )
def ethusd_bitmex() -> Instrument: """ Return the BitMEX ETH/USD perpetual contract for backtesting. Returns ------- Instrument """ instrument_id = InstrumentId( symbol=Symbol("ETH/USD"), venue=Venue("BITMEX"), ) return Instrument( instrument_id=instrument_id, asset_class=AssetClass.CRYPTO, asset_type=AssetType.SWAP, base_currency=ETH, quote_currency=USD, settlement_currency=BTC, is_inverse=True, price_precision=2, size_precision=0, tick_size=Decimal("0.05"), multiplier=Decimal("1"), lot_size=Quantity(1), max_quantity=Quantity("10000000.0"), min_quantity=Quantity("1.0"), max_notional=None, min_notional=None, max_price=Price("1000000.00"), min_price=Price("0.05"), margin_init=Decimal("0.02"), margin_maint=Decimal("0.007"), maker_fee=Decimal("-0.00025"), taker_fee=Decimal("0.00075"), timestamp_ns=0, )
def default_fx_ccy(symbol: str, venue: Venue = None) -> Instrument: """ Return a default FX currency pair instrument from the given instrument_id. Parameters ---------- symbol : str The currency pair symbol. venue : Venue The currency pair venue. Returns ------- Instrument Raises ------ ValueError If the instrument_id.instrument_id length is not in range [6, 7]. """ if venue is None: venue = Venue("SIM") PyCondition.valid_string(symbol, "symbol") PyCondition.in_range_int(len(symbol), 6, 7, "len(symbol)") instrument_id = InstrumentId( symbol=Symbol(symbol), venue=venue, ) base_currency = symbol[:3] quote_currency = symbol[-3:] # Check tick precision of quote currency if quote_currency == "JPY": price_precision = 3 else: price_precision = 5 return Instrument( instrument_id=instrument_id, asset_class=AssetClass.FX, asset_type=AssetType.SPOT, base_currency=Currency.from_str(base_currency), quote_currency=Currency.from_str(quote_currency), settlement_currency=Currency.from_str(quote_currency), is_inverse=False, price_precision=price_precision, size_precision=0, tick_size=Decimal( f"{1 / 10 ** price_precision:.{price_precision}f}"), multiplier=Decimal("1"), lot_size=Quantity("1000"), max_quantity=Quantity("1e7"), min_quantity=Quantity("1000"), max_price=None, min_price=None, max_notional=Money(50000000.00, USD), min_notional=Money(1000.00, USD), margin_init=Decimal("0.03"), margin_maint=Decimal("0.03"), maker_fee=Decimal("0.00002"), taker_fee=Decimal("0.00002"), financing={}, timestamp_ns=0, )