Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need example of how to lookup prices #1

Open
quux00 opened this issue Aug 18, 2017 · 1 comment
Open

Need example of how to lookup prices #1

quux00 opened this issue Aug 18, 2017 · 1 comment

Comments

@quux00
Copy link

quux00 commented Aug 18, 2017

I am currently unable to figure out how to lookup prices via the Java API. I am able to do it via curl with

curl \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <KEY>" \
  "https://api-fxpractice.oanda.com/v3/accounts/<ACCOUNT>/pricing?instruments=EUR_USD%2CUSD_CAD"

I am also able to get your Java code examples to work (e.g., I can create an order via the Java API). But you don't have any example of how to look up prices for one or more instruments. My attempt was:

  private void lookupPrices() throws RequestException, ExecuteException {
    // ctx.pricing.get();
    List<InstrumentName> instruments = new ArrayList<>();
    instruments.add(tradeableInstrument);
    PricingGetRequest priceRequest = new PricingGetRequest(accountId, instruments);
    PricingGetResponse pricingGetResponse = ctx.pricing.get(priceRequest);
  }

or

  private void lookupPrices() throws RequestException, ExecuteException {
    // ctx.pricing.get();
    List<String> instruments = new ArrayList<>();
    instruments.add("USD_CAD");
    PricingGetRequest priceRequest = new PricingGetRequest(accountId, instruments);
    PricingGetResponse pricingGetResponse = ctx.pricing.get(priceRequest);
  }

but both attempts fail with:

class com.oanda.v20.RequestException
Exception in thread "main" com.oanda.v20.v20sample.TestFailureException: 400 : null : null
	at com.oanda.v20.v20sample.TestTradesAndOrders.main(TestTradesAndOrders.java:75)
Caused by: 400 : null : null
	at com.oanda.v20.Context.execute(Context.java:191)
	at com.oanda.v20.pricing.PricingContext.get(PricingContext.java:72)
	at com.oanda.v20.v20sample.TestTradesAndOrders.lookupPrices(TestTradesAndOrders.java:92)
	at com.oanda.v20.v20sample.TestTradesAndOrders.runMPTest(TestTradesAndOrders.java:83)
	at com.oanda.v20.v20sample.TestTradesAndOrders.main(TestTradesAndOrders.java:72)

I also tried using versions 3.0.17 and 3.0.18 of the oanda/v20-java library. Same result with both.

Help and examples requested. Thank you.

@fxnh
Copy link

fxnh commented Sep 13, 2017

I just tried with 3.0.19 and seems to work now but I still would appreciate a example. Not sure about PriceBucket, ClientPrice, Steraming,....

No it only worked for 2 days now I get - with same code - also 400 error back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants