示例#1
0
def test_find_trade_signal_buy(config):
    services = {
        "ig_index":
        MockIG(
            "test/test_data/mock_ig_market_info.json",
            "test/test_data/mock_ig_historic_price.json",
        ),
        "alpha_vantage":
        MockAV("test/test_data/mock_macdext_buy.json"),  # BUY json
    }
    broker = MockBroker(config, services)
    strategy = SimpleMACD(config, broker)
    prices = broker.get_prices("", "", "", "")

    # Create a mock market data from the json file
    market = create_mock_market(broker)

    # Call function to test
    tradeDir, limit, stop = strategy.find_trade_signal(market, prices)

    assert tradeDir is not None
    assert limit is not None
    assert stop is not None

    assert tradeDir == TradeDirection.BUY
def test_find_trade_signal(config):
    services = {
        "ig_index":
        MockIG(
            "test/test_data/mock_ig_market_info.json",
            "test/test_data/mock_ig_historic_price.json",
        ),
        "alpha_vantage":
        MockAV("test/test_data/mock_av_weekly.json"),
    }
    broker = MockBroker(config, services)
    strategy = WeightedAvgPeak(config, broker)
    prices = broker.get_prices("", "", "", "")

    market = create_mock_market(broker)

    tradeDir, limit, stop = strategy.find_trade_signal(market, prices)

    assert tradeDir is not None
    assert limit is None
    assert stop is None

    assert tradeDir == TradeDirection.NONE