Comments (9)
Hi zihoa,
please check out the updated store. This may fix your issues.
from btoandav20.
Hi zihoa,
are you using the btoandav20 store?
check this example for setup:
https://github.com/ftomassetti/backtrader-oandav20/blob/master/examples/oandav20test/oandav20test.py
from btoandav20.
Hi zihoa,
are you using the btoandav20 store?
check this example for setup:
https://github.com/ftomassetti/backtrader-oandav20/blob/master/examples/oandav20test/oandav20test.py
Hi Happydasch,
Thanks for your reply.
Yes I directly run the example code of btoandav20,
as the command below:
(base) eMacBook-Pro:backtrader-oandav20-master e$ python oandav20test.py --token 'e25677e.........84f63' --account '10........01' --data0 'EUR_USD'
The output is:
--------------------------------------------------
Strategy Created
--------------------------------------------------
-- Contract Details:
{'name': 'EUR_USD', 'type': 'CURRENCY', 'displayName': 'EUR/USD', 'pipLocation': -4, 'displayPrecision': 5, 'tradeUnitsPrecision': 0, 'minimumTradeSize': '1.0', 'maximumTrailingStopDistance': '1.0', 'minimumTrailingStopDistance': '0.0005', 'maximumPositionSize': '0.0', 'maximumOrderUnits': '100000000.0', 'marginRate': '0.01'}
Datetime, Open, High, Low, Close, Volume, OpenInterest, SMA
***** DATA NOTIF: DELAYED
The example code have no respond then. I then keep the process continue to wait the exception cached, the error info seems shown that the program is waiting for response from oanda.
Traceback (most recent call last):
File "/Users/zihoa/anaconda3/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/Users/zihoa/anaconda3/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/Users/zihoa/PycharmProjects/Hheng/btoandav20/stores/oandav20store.py", line 465, in _t_account
print(e, response.get('errorMessage'))
File "/Users/zihoa/anaconda3/lib/python3.7/site-packages/v20/response.py", line 35, in get
raise ResponseNoField(self, field)
v20.errors.ResponseNoField: 200 response for GET https://api-fxpractice.oanda.com:443/v3/accounts/101.................001/summary does not have field 'errorMessage' (contains 'account', 'lastTransactionID')
***** STORE NOTIF: v20 REST request to https://api-fxpractice.oanda.com:443/v3/accounts/101-...............001/summary has timed out (read)
Is there any possible explanations for this issue?
Many thanks,
zihoa
from btoandav20.
Hi,
I cannot see a issue here. the output is account info, which seems to be working. Is there a problem accessing data or what exactly does not work for you?
Cheers
from btoandav20.
I have tried to access oanda with a practice account just now and it seems that the service is not available at the moment. Maybe that is your issue. Check for oanda server status and try again maybe later.
***** STORE NOTIF: GET https://api-fxpractice.oanda.com:443/v3/accounts/1xxx-001/summary expected status 200, got 503 (Service Unavailable)
from btoandav20.
Hi,
I cannot see a issue here. the output is account info, which seems to be working. Is there a problem accessing data or what exactly does not work for you?
Cheers
Hi,
My problems is when I launch the program by command,
(base) eMacBook-Pro:HengSheng zihoa $ python3 oandaTest.py --token "asdasdasdasdasd" --account "100000000001" --data0 "EUR_USD" --timeframe Seconds`
The output I get is:
--------------------------------------------------
Strategy Created
--------------------------------------------------
-- Contract Details:
{'name': 'EUR_USD', 'type': 'CURRENCY', 'displayName': 'EUR/USD', 'pipLocation': -4, 'displayPrecision': 5, 'tradeUnitsPrecision': 0, 'minimumTradeSize': '1.0', 'maximumTrailingStopDistance': '1.0', 'minimumTrailingStopDistance': '0.0005', 'maximumPositionSize': '0.0', 'maximumOrderUnits': '100000000.0', 'marginRate': '0.01'}
Datetime, Open, High, Low, Close, Volume, OpenInterest, SMA
***** DATA NOTIF: DELAYED
And the program do not response then.
But as espected it should return the 5 seconds price stream...
I found the problem yesterday and I tried in another computer but also have same problem.
Yes, I also suspect the problem comes from OANDA server. I will explore then and keep update here.
Thanks happydasch.
from btoandav20.
It is most likely the oanda server. I have just tried accessing the api with my live account, which is working. I did just output the data in the strategy, no order execution.
I'll close this issue, but reopen it or create a new one if your issue remains.
from btoandav20.
Hi Happydasch,
I check the program this morning and the problem still exist. To verify the problem comes from OANDA Server or not I use the curl command to ask the price stream and it works:
curl \
-H "Authorization: Bearer <TOKEN>" \
"https://stream-fxpractice.oanda.com/v3/accounts/<ACCOUNTID>/pricing/stream?instruments=EUR_USD%2CUSD_CAD"
The command return:
{"type":"PRICE","time":"2019-05-28T13:06:32.682119462Z","bids":[{"price":"1.11914","liquidity":10000000}],"asks":[{"price":"1.11925","liquidity":10000000}],"closeoutBid":"1.11899","closeoutAsk":"1.11940","status":"tradeable","tradeable":true,"instrument":"EUR_USD"}
{"type":"PRICE","time":"2019-05-28T13:06:36.867978259Z","bids":[{"price":"1.34639","liquidity":10000000}],"asks":[{"price":"1.34656","liquidity":10000000}],"closeoutBid":"1.34639","closeoutAsk":"1.34656","status":"tradeable","tradeable":true,"instrument":"USD_CAD"}
{"type":"PRICE","time":"2019-05-28T13:06:38.001645632Z","bids":[{"price":"1.34641","liquidity":10000000}],"asks":[{"price":"1.34658","liquidity":10000000}],"closeoutBid":"1.34641","closeoutAsk":"1.34658","status":"tradeable","tradeable":true,"instrument":"USD_CAD"}
However, I call the example test program, there is no response. I then use a simple program to run the oandav20 package, which just request the price stream from oanda and print the price. The code shown following:
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import argparse
import datetime
import backtrader as bt
import btoandav20
StoreCls = btoandav20.stores.OandaV20Store
DataCls = btoandav20.feeds.OandaV20Data
#BrokerCls = btoandav20.brokers.OandaV20Broker
# available timeframes for oanda
TIMEFRAMES = [bt.TimeFrame.Names[bt.TimeFrame.Seconds],
bt.TimeFrame.Names[bt.TimeFrame.Minutes],
bt.TimeFrame.Names[bt.TimeFrame.Days],
bt.TimeFrame.Names[bt.TimeFrame.Weeks],
bt.TimeFrame.Names[bt.TimeFrame.Months]]
api_key = "e2 63"
account_number = "10 001"
class TestStrategy(bt.Strategy):
def __init__(self):
# To keep track of pending orders
self.orders = []
# others
self.datastatus = 0
def logdata(self):
txt = []
txt.append('{}'.format(len(self)))
txt.append('{}'.format(
self.data.datetime.datetime(0).isoformat())
)
txt.append('{:.4f}'.format(self.data.open[0]))
txt.append('{:.4f}'.format(self.data.high[0]))
txt.append('{:.4f}'.format(self.data.low[0]))
txt.append('{:.4f}'.format(self.data.close[0]))
txt.append('{:.4f}'.format(self.data.volume[0]))
print(','.join(txt))
def notify_data(self, data, status, *args, **kwargs):
print('*' * 5, 'DATA NOTIF:', data._getstatusname(status), *args)
if status == data.LIVE:
self.datastatus = 1
def notify_trade(self, trade):
date = self.data.datetime.datetime()
if trade.isclosed:
print('-' * 32, ' NOTIFY TRADE ', '-' * 32)
print('{}, Close Price: {}, Profit, Gross {}, Net {}'.format(
date,
trade.price,
round(trade.pnl, 2),
round(trade.pnlcomm, 2)))
print('-' * 80)
def next(self):
print('-' * 32, ' NOTIFY PRICE ', '-' * 32)
print('{},'.format(self.data.close[0]))
print('-' * 80)
def start(self):
if self.data0.contractdetails is not None:
print('-- Contract Details:')
print(self.data0.contractdetails)
print('Started')
acc_cash = cerebro.broker.getcash()
acc_val = cerebro.broker.getvalue()
print('Account Cash = {}'.format(acc_cash))
print('Account Value = {}'.format(acc_val))
if __name__ == '__main__':
cerebro = bt.Cerebro()
oandastore = StoreCls(token=api_key, account=account_number, practice=True)
cerebro.broker = oandastore.getbroker()#BrokerCls()
data = oandastore.getdata(dataname="EUR_USD", timeframe=bt.TimeFrame.Seconds,
compression=5, reconnect = True,reconntimeout = 10)
cerebro.adddata(data)
cerebro.addsizer(bt.sizers.SizerFix, stake=500)
cerebro.addstrategy(TestStrategy)
cerebro.run()
After function 'start' return the account information, there are no response data return.
I am not sure where the problem come from yet, maybe it's related to my network? I checked the code in store, I think the thread is waiting for the response from OANDA, but using single V20 package the server return my request data. Totally confused...
Best,
zihoa
from btoandav20.
Hi zihoa,
please check out the updated store. This may fix your issues.
Hi Happydasch,
Thank you very much for solving the problem, and thanks for contributing the oandav20 project.
Best regards,
zihao
from btoandav20.
Related Issues (20)
- OANDA v20 repetitive disconnection HOT 6
- Issue in oandav20store.py line 879 for Python3 HOT 3
- Simple backtest example HOT 9
- Timing out and not reconnecting HOT 9
- Timezone, Live Data and Connection Timeouts HOT 1
- Order replacement for bracket orders
- Is this msg_type check necessary? HOT 11
- Live Feed constantly dropping out HOT 1
- StopLimit returns rejected HOT 2
- Not consistence parameter stoploss & pips name in getsizing function HOT 1
- Datafeeds delay candle when set node candles=True HOT 3
- The sizers don't work as my expection HOT 1
- Why no loop when call response =??? HOT 2
- 401 (Unauthorized) on btoandav20 works ok on oandapyV20 HOT 1
- Need your help or explain because backtrader stops after receiving new data at new minute HOT 4
- the status of expired order is still "Accepted" in living trading HOT 1
- Commission HOT 1
- Is this expected `broker.getcash()` behavior? HOT 2
- Makes Orders during the backfill candles
- avail variable is no longer part of OandaSizer
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 btoandav20.