Comments (8)
The attribute error stems from the fact that I haven't updated the sample (thanks for reporting that :D) ; it should be tickers, not ticker. See if you can connect using that! :)
Keep the issues coming! They're much appreciated!
from btfxwss.
Thx for your fast answer!
I changed it to tickers
but seems like it is a connection problem with the WS, the logs remains the same:
INFO:btfxwss.connection:Connection Error - cafile, capath and cadata cannot be all omitted
INFO:btfxwss.connection:Connection closed
INFO:btfxwss.connection:Attempting to connect again in 10 seconds.
And seems like the self.queue_processor.tickers
is empty because the pair BTCUSD wasn't found:
print(wss.queue_processor.tickers)
wss.tickers('BTCUSD')
results in:
defaultdict(<class 'queue.Queue'>, {})
Traceback (most recent call last):
File "/home/kepler/Workspace/FinexMonitor/main.py", line 33, in <module>
wss.tickers('BTCUSD')
File "/usr/lib/python3.6/site-packages/btfxwss/client.py", line 48, in tickers
raise KeyError(pair)
KeyError: 'BTCUSD'
from btfxwss.
I have pushed a hotfix for this (1.0.3) - could you verify this works for you?
By the way, I confused my own examples in the previous comments.
tickers
doesn't subscribe anymore. You need to call subscribe_to_ticker('BTCUSD)
.
To elaborate on the above error:
The key error occurs because there's no data yet. It may be either because you haven't subscribed, or because the connection wasn't esablished (due to the issue you referenced with the websocket module).
from btfxwss.
Also, could you verify that this doesn't happen with the dev
branch version ?
from btfxwss.
Thanks for your patch, I'm testing with this sample:
import logging
import sys
import time
from btfxwss import BtfxWss
apikey = '....'
apisecret = '....'
logging.basicConfig(level=logging.DEBUG, filename='test.log')
log = logging.getLogger(__name__)
fh = logging.FileHandler('test.log')
fh.setLevel(logging.DEBUG)
sh = logging.StreamHandler(sys.stdout)
sh.setLevel(logging.DEBUG)
log.addHandler(sh)
log.addHandler(fh)
wss = BtfxWss()
wss.start()
time.sleep(3) # give the client some prep time to set itself up.
# Subscribe to some channels
wss.subscribe_to_ticker('BTCUSD')
# Do something else
t = time.time()
while time.time() - t < 10:
pass
ticker_q = wss.tickers('BTCUSD') # returns a Queue object for the pair.
while not ticker_q.empty():
print(ticker_q.get())
On your master version, 1.0.3
it returns:
Traceback (most recent call last):
File "/home/kepler/Workspace/FinexMonitor/main.py", line 32, in <module>
wss.subscribe_to_ticker('BTCUSD')
File "/usr/lib/python3.6/site-packages/btfxwss/client.py", line 132, in subscribe_to_ticker
self._subscribe('ticker', identifier, symbol=pair, **kwargs)
File "/usr/lib/python3.6/site-packages/btfxwss/client.py", line 111, in _subscribe
self.conn.send(**q)
File "/usr/lib/python3.6/site-packages/btfxwss/connection.py", line 235, in send
self.conn.send(payload)
File "/usr/lib/python3.6/site-packages/websocket/_app.py", line 120, in send
"Connection is already closed.")
websocket._exceptions.WebSocketConnectionClosedException: Connection is already closed.
INFO:btfxwss.connection:Connection Error - [Errno 2] No such file or directory
INFO:btfxwss.connection:Connection closed
INFO:btfxwss.connection:Attempting to connect again in 10 seconds.
DEBUG:btfxwss.client:_subscribe: {'event': 'subscribe', 'channel': 'ticker', 'symbol': 'BTCUSD'}
On Dev version:
Traceback (most recent call last):
File "/home/kepler/Workspace/FinexMonitor/main.py", line 40, in <module>
ticker_q = wss.tickers('BTCUSD') # returns a Queue object for the pair.
File "/usr/lib/python3.6/site-packages/btfxwss/client.py", line 151, in tickers
raise KeyError(pair)
KeyError: 'BTCUSD'
INFO:btfxwss.connection:Connection Error - [Errno 2] No such file or directory
INFO:btfxwss.connection:Connection closed
INFO:btfxwss.connection:Attempting to connect again in 10 seconds.
ERROR:btfxwss.client:Cannot call subscribe_to_ticker() on unestablished connection!
INFO:btfxwss.connection:Connection Error - cafile, capath and cadata cannot be all omitted
INFO:btfxwss.connection:Connection closed
INFO:btfxwss.connection:Attempting to connect again in 10 seconds.
from btfxwss.
see if it works now (dev
) - I'm now getting the default path for the certificates via the ssl module, that should take care of it. Otherwise I have to look at this in depth tomorrow.
from btfxwss.
Tested on dev! It seems to be working!, at least it is returning data.
$ python3 main.py
([[3252.1, 1.78920249, 3255.6, 3.35648544, 425.2, 0.1502, 3255.6, 47986.71579181, 3339.5, 2820.5]], 1501961446.8678486)
([[3255.6, 1.738, 3257.6, 3.33813918, 424.8, 0.1501, 3255.2, 48063.90211299, 3339.5, 2820.5]], 1501961446.9137855)
Thank you for your effort/time, I will now see how could I add/cancel margin funding operations with your API.
from btfxwss.
Excellent, glad to hear it's fixed!
from btfxwss.
Related Issues (20)
- Timeout settings? HOT 1
- Websocket configuration is not restored during reconnect HOT 1
- pip install not newest version HOT 1
- after running for hours the timeout become much HOT 1
- Connection Issue HOT 2
- A proper handling of a Bitfinex-initiated connection closing
- how to reconnect properly HOT 3
- ORDER RELATED API HOT 1
- SUBSCRIPTION TO DATA HOT 1
- authenticated channels HOT 4
- New websocket-client release breaking code HOT 1
- client_tests don't work HOT 8
- problems with reconection HOT 3
- Pypi version 1.2.2 breaks `raise_exception` HOT 3
- websockets reconnecting constantly? HOT 2
- the auth_nonce problem
- fail to run client.py ,help HOT 2
- not responding sometimes
- Upcoming Bitfinex API Update June 2019
- Account channel not updated
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 btfxwss.