Git Product home page Git Product logo

Comments (7)

silgon avatar silgon commented on June 2, 2024

Damn. I found it in the end. First I did something silly:

 client.client.headers["Accept-Datetime-Format"]="Unix"

And then I found out I could do it directly with the configuration.

client = oandapyV20.API(access_token=token_id,
                        environment=environement,
                        headers={"Accept-Datetime-Format":"Unix"})

Thanks for the great work!

from oanda-api-v20.

hootnot avatar hootnot commented on June 2, 2024

Hi, that indeed is the way to set headers. See the requests package also if you want details.
Earlier this year this issue: oanda/v20-python#22 on the v20 wrapper of OANDA. They have the issue still open, don't know if it is fixed. So, if you run into issues you might want to check.

Personally I always use regular datetime.

from oanda-api-v20.

silgon avatar silgon commented on June 2, 2024

I tested some hours ago and it seemed to be working, with either unix or RFC3339 time format. In another matter, since you use the requests package, you have the elapsed time of the request. Is there a way to get it from your package?
In requests package is like a=requests.get(myurl);print(a.elapsed)

from oanda-api-v20.

hootnot avatar hootnot commented on June 2, 2024

I guess you want line 305 of oandapyV20.py where you find the response. Little hacking and you have access.

from oanda-api-v20.

silgon avatar silgon commented on June 2, 2024

Thanks!. I'll check it out.

from oanda-api-v20.

hootnot avatar hootnot commented on June 2, 2024

Using jupyter notebook (or ipython directly) you can do:

import os
os.chdir('<there-where-you-cloned-the-repo>/oandapyV20-examples')
import json
from oandapyV20 import API
import oandapyV20.endpoints.accounts as accounts
from oandapyV20.exceptions import V20Error
# touch src/__init__.py
from src.exampleauth import exampleAuth
import requests
accountID, token = exampleAuth()

api = API(access_token=token)
params = {"instruments": "EUR_USD"}
r = accounts.AccountInstruments(accountID=accountID, params=params)
# make a first request before the test to get an established session
api.request(r)

%timeit rv = api.request(r)
print(json.dumps(rv, indent=2))

and you get:

10 loops, best of 3: 134 ms per loop

... don't know what your exact goal is. Network is key in the number you get here.

from oanda-api-v20.

silgon avatar silgon commented on June 2, 2024

I just want to be able to check latency if I use different computers or virtual machines, not that I'm going to decide something based on that, I just want to be able to do it (for fun, you know). Thanks for the workaround, it's true that I don't need to complicate myself, I could just use a time it and average the response.

from oanda-api-v20.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.