Ejemplo n.º 1
0
# ------------------------
# price types include BID, ASK, MID, LAST
# Current aggregations TICK, SECOND, MINUTE, HOUR, DAY, VOLUME, VALUE
# These can be combined in any way, for example;
tick_bars = BarSpecification(100, BarAggregation.TICK, PriceType.LAST)
time_bars = BarSpecification(1, BarAggregation.MINUTE, PriceType.LAST)
volu_bars = BarSpecification(100, BarAggregation.VOLUME, PriceType.MID)
valu_bars = BarSpecification(1_000_000, BarAggregation.VALUE, PriceType.MID)

# Instantiate your strategies to pass into the trading node. You could add
# custom options into the configuration file or even use another configuration
# file.
strategy = VolatilityMarketMaker(
    symbol=Symbol("ETH/USDT", Venue("BINANCE")),
    bar_spec=time_bars,
    trade_size=Decimal("0.05"),
    atr_period=20,
    atr_multiple=1.0,
    order_id_tag="001",
)

# Instantiate the node passing a list of strategies and configuration
node = TradingNode(strategies=[strategy], config=config)

# Stop and dispose of the node with SIGINT/CTRL+C
if __name__ == "__main__":
    try:
        node.start()
    finally:
        node.dispose()
Ejemplo n.º 2
0
    },
}

# Instantiate your strategies to pass into the trading node. You could add
# custom options into the configuration file or even use another configuration
# file.

instrument_id = InstrumentId(
    symbol=Symbol("BTC/USD"),
    venue=Venue("BITMEX"),
)

strategy = VolatilityMarketMaker(
    instrument_id=instrument_id,
    bar_spec=BarSpecification(1, BarAggregation.MINUTE, PriceType.LAST),
    trade_size=Decimal("100"),
    atr_period=20,
    atr_multiple=1.0,
    order_id_tag="001",
)

# Instantiate the node passing a list of strategies and configuration
node = TradingNode(strategies=[strategy], config=config)

# Stop and dispose of the node with SIGINT/CTRL+C
if __name__ == "__main__":
    try:
        node.start()
    finally:
        node.dispose()
Ejemplo n.º 3
0
    data.add_bars(
        symbol=GBPUSD.symbol,
        aggregation=BarAggregation.MINUTE,
        price_type=PriceType.BID,
        data=TestDataProvider.gbpusd_1min_bid(),  # Stub data from the test kit
    )
    data.add_bars(
        symbol=GBPUSD.symbol,
        aggregation=BarAggregation.MINUTE,
        price_type=PriceType.ASK,
        data=TestDataProvider.gbpusd_1min_ask(),  # Stub data from the test kit
    )

    # Instantiate your strategy
    strategy = VolatilityMarketMaker(
        symbol=GBPUSD.symbol,
        bar_spec=BarSpecification(5, BarAggregation.MINUTE, PriceType.BID),
        trade_size=Decimal(500_000),
        atr_multiple=3.0,
    )

    # Build the backtest engine
    engine = BacktestEngine(
        data=data,
        strategies=[strategy],  # List of 'any' number of strategies
        use_tick_cache=True,
        # exec_db_type="redis",
        # bypass_logging=True
    )

    # Create a fill model (optional)
    fill_model = FillModel(
Ejemplo n.º 4
0
            "api_key":
            "BINANCE_API_KEY",  # value is the environment variable key
            "api_secret":
            "BINANCE_API_SECRET",  # value is the environment variable key
            "sandbox_mode": False,  # If clients use the testnet
        },
    },
}

# Instantiate your strategies to pass into the trading node. You could add
# custom options into the configuration file or even use another configuration
# file.
strategy = VolatilityMarketMaker(
    symbol=Symbol("ETH/USDT", Venue("BINANCE")),
    bar_spec=BarSpecification(1, BarAggregation.MINUTE, PriceType.LAST),
    trade_size=Decimal("0.05"),
    atr_period=20,
    atr_multiple=1.0,
    order_id_tag="001",
)

# Instantiate the node passing a list of strategies and configuration
node = TradingNode(strategies=[strategy], config=config)

# Stop and dispose of the node with SIGINT/CTRL+C
if __name__ == "__main__":
    try:
        node.start()
    finally:
        node.dispose()
    data.add_bars(
        instrument_id=GBPUSD.id,
        aggregation=BarAggregation.MINUTE,
        price_type=PriceType.BID,
        data=TestDataProvider.gbpusd_1min_bid(),  # Stub data from the test kit
    )
    data.add_bars(
        instrument_id=GBPUSD.id,
        aggregation=BarAggregation.MINUTE,
        price_type=PriceType.ASK,
        data=TestDataProvider.gbpusd_1min_ask(),  # Stub data from the test kit
    )

    # Instantiate your strategy
    strategy = VolatilityMarketMaker(
        instrument_id=GBPUSD.id,
        bar_spec=BarSpecification(5, BarAggregation.MINUTE, PriceType.BID),
        trade_size=Decimal(500_000),
        atr_period=20,
        atr_multiple=3.0,
        order_id_tag="001",
    )

    # Build the backtest engine
    engine = BacktestEngine(
        data=data,
        strategies=[strategy],  # List of 'any' number of strategies
        use_data_cache=True,
        # exec_db_type="redis",
        # bypass_logging=True
    )
            "api_key":
            "BITMEX_API_KEY_SANDBOX",  # value is the environment variable key
            "api_secret":
            "BITMEX_API_SECRET_SANDBOX",  # value is the environment variable key
            "sandbox_mode": True,  # If clients use the testnet
        },
    },
}

# Instantiate your strategies to pass into the trading node. You could add
# custom options into the configuration file or even use another configuration
# file.
strategy = VolatilityMarketMaker(
    symbol=Symbol("BTC/USD", Venue("BITMEX")),
    bar_spec=BarSpecification(1, BarAggregation.MINUTE, PriceType.LAST),
    trade_size=Decimal("10"),
    atr_period=20,
    atr_multiple=1.5,
    order_id_tag="091",
)

# Instantiate the node passing a list of strategies and configuration
node = TradingNode(strategies=[strategy], config=config)

# Stop and dispose of the node with SIGINT/CTRL+C
if __name__ == "__main__":
    try:
        node.start()
    finally:
        node.dispose()