Comments (2)
A close websocket function was added in this PR #63.
Please see this example on how to use:
import os
import sys
sys.path.append('../../../')
from bfxapi import Client
bfx = Client(
logLevel='DEBUG',
)
@bfx.ws.on('order_book_snapshot')
async def log_snapshot(data):
print ("Snapshot: {}".format(data))
# stop the websocket once a snapshot is received
await bfx.ws.stop()
async def start():
await bfx.ws.subscribe('book', 'tBTCUSD')
bfx.ws.on('connected', start)
bfx.ws.run()
from bitfinex-api-py.
Hi, this function works on specific event like 'order_book_snapshot', but how to close connection from the main thread on demand?
await bfx.ws.stop()
`---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
in
----> 1 await bfx.ws.stop()
~/anaconda3/envs/arb/lib/python3.8/site-packages/bfxapi/websockets/generic_websocket.py in stop(self)
164 self.attempt_retry = False
165 for key, socket in self.sockets.items():
--> 166 await socket.ws.close()
167 self._emit('done')
168
~/anaconda3/envs/arb/lib/python3.8/site-packages/websockets/protocol.py in close(self, code, reason)
530 """
531 try:
--> 532 yield from asyncio.wait_for(
533 self.write_close_frame(serialize_close(code, reason)),
534 self.close_timeout,
~/anaconda3/envs/arb/lib/python3.8/asyncio/tasks.py in wait_for(fut, timeout, loop)
474 # wait until the future completes or the timeout
475 try:
--> 476 await waiter
477 except exceptions.CancelledError:
478 fut.remove_done_callback(cb)
RuntimeError: Task <Task pending name='Task-5' coro=<InteractiveShell.run_cell_async() running at /home/dima/anaconda3/envs/arb/lib/python3.8/site-packages/IPython/core/interactiveshell.py:3155> cb=[IPythonKernel._cancel_on_sigint..cancel_unless_done(<Future pendi...ernel.py:230]>)() at /home/dima/anaconda3/envs/arb/lib/python3.8/site-packages/ipykernel/ipkernel.py:230, IOLoop.add_future..() at /home/dima/anaconda3/envs/arb/lib/python3.8/site-packages/tornado/ioloop.py:688]> got Future attached to a different loop`
from bitfinex-api-py.
Related Issues (20)
- Error running subscribe_trades_candles.py example. HOT 4
- misleading documentation HOT 1
- 'Fatal error on SSL protocol' when use uvloop
- API is missing candle data HOT 4
- Rest API missing Liquidations implementation HOT 2
- Python 3.10 Support HOT 2
- bitfinex-api-py/bfxapi/rest/ public stats data HOT 2
- Unable to create order on paper account: [ERROR] Notification ERROR: action: disabled HOT 1
- Not working with python3.10 asyncio HOT 2
- Unknown data event: '[0.79816, 0, 1]' [54, [0.79816, 0, 1]] HOT 1
- How to get more data in public orderbook? HOT 1
- New pyee version
- Candle data from wss is delayed behind rest HOT 1
- bfx.rest.auth.cancel_order_multi HOT 1
- Failing "import bfxapi" HOT 2
- How come I can't call this endpoint: get_derivatives_status_history
- Starting from version 3.0.0b3, the meta parameter is no longer present in the submit_order function. HOT 1
- Christina vongphit
- How to setup logging? HOT 1
- "TypeError: constraints must be a tuple" when importing bfxapi in Python 3.12.2 HOT 2
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 bitfinex-api-py.