Skip to content

ctx.pricing.candles returning illegal character error #12

Description

@yohanesyuen

I was trying to testout PricingContext.candles, however, I noticed that it did not include the account id in the url. Require assistance.

Below is my stack trace.

	at com.oanda.v20.Context.execute(Context.java:198)
	at com.oanda.v20.pricing.PricingContext.candles(PricingContext.java:229)
	at com.oanda.v20.pricing.PricingContext.candles(PricingContext.java:206)
	at Summary.main(Summary.java:29)
Caused by: java.net.URISyntaxException: Illegal character in path at index 45: https://api-fxpractice.oanda.com/v3/accounts/{accountID}/instruments/EUR_USD/candles
	at java.net.URI$Parser.fail(URI.java:2848)
	at java.net.URI$Parser.checkChars(URI.java:3021)
	at java.net.URI$Parser.parseHierarchical(URI.java:3105)
	at java.net.URI$Parser.parse(URI.java:3053)
	at java.net.URI.<init>(URI.java:588)
	at org.apache.http.client.utils.URIBuilder.<init>(URIBuilder.java:80)
	at com.oanda.v20.Context.execute(Context.java:196)
	... 3 more

Code attached below also.

import com.oanda.v20.Context;
import com.oanda.v20.ContextBuilder;
import com.oanda.v20.account.AccountID;
import com.oanda.v20.account.AccountSummary;
import com.oanda.v20.pricing.PricingCandlesResponse;
import com.oanda.v20.primitives.AcceptDatetimeFormat;
import com.oanda.v20.primitives.InstrumentName;

public class Summary {

	@SuppressWarnings("deprecation")
	public static void main(String[] args) {
		final String uri = Config.getBaseUri();
		final String Token = Config.getToken();
		ContextBuilder ctxBuilder = new ContextBuilder(uri);
		ctxBuilder.setToken(Token);
		ctxBuilder.setApplication("");
		Context ctx = ctxBuilder.build();
		AccountID accID = new AccountID(Config.getAccountNumber());

		try {
			PricingCandlesResponse candles= ctx.pricing.candles(new InstrumentName("EUR_USD"));
			System.out.println(candles);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions