Comments (7)
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.
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.
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.
I guess you want line 305 of oandapyV20.py where you find the response. Little hacking and you have access.
from oanda-api-v20.
Thanks!. I'll check it out.
from oanda-api-v20.
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.
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)
- PositionClose HOT 2
- Streaming OHLC data? HOT 3
- `InstrumentsCandles` Returns Candles from a few days ago HOT 1
- Unit not accepting less than 1 HOT 2
- Expiry time on Stop order not correct HOT 1
- Allow floats as unit size instead of integers HOT 3
- Proxy uses HTTP and not HTTPS HOT 1
- daily candles seem to be shifted one day HOT 1
- ContentDecodingError with InstrumentsCandles HOT 3
- API Connection keeps closing HOT 2
- Wrong implementation of units - "rejectReason":"UNITS_INVALID" HOT 1
- Client Access Not working for Instruments call or any data call HOT 1
- question for Feite HOT 1
- question for hootnot 2 HOT 1
- Keep on getting `The provided request was forbidden` error. HOT 4
- question for feit HOT 1
- asyncio support?
- Extend the pricing endpoints
- Add asyncio support
- Wrong bar values?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oanda-api-v20.