Comments (7)
I added output for Hashs:
public async Task<object> watch(object url2, object messageHash2, object message = null, object subscribeHash2 = null, object subscription = null)
{
var url = url2.ToString();
var messageHash = messageHash2.ToString();
var subscribeHash = subscribeHash2?.ToString();
var client = this.client(url);
var futures = (client.futures as ConcurrentDictionary<string, Future>);
var subscriptions = (client.subscriptions as ConcurrentDictionary<string, object>);
Console.WriteLine($"watch, messageHash2: '{messageHash2}', subscribeHash2: '{subscribeHash2}', futures.ContainsKey: '{futures.ContainsKey(messageHash)}', subscriptions.ContainsKey: '{subscriptions.ContainsKey(subscribeHash)}'");
var future = (client.futures as ConcurrentDictionary<string, Future>).GetOrAdd (messageHash, (key) => client.future(messageHash));
if (subscribeHash == null) {
return await future;
}
var connected = client.connect(0);
if ((client.subscriptions as ConcurrentDictionary<string, object>).TryAdd(subscribeHash, subscription ?? true))
{
Console.WriteLine($"watch, messageHash2: '{messageHash2}', subscribeHash2: '{subscribeHash2}', this subscription added");
await connected;
if (message != null)
{
try
{
await client.send(message);
}
catch (Exception ex)
{
client.subscriptions.Remove(subscribeHash);
future.reject(ex);
// future.SetException(ex); check this out
}
}
}
Console.WriteLine($"watch, messageHash2: '{messageHash2}', subscribeHash2: '{subscribeHash2}', futures keys: '{string.Join(",", futures.Keys)}'");
Console.WriteLine($"watch, messageHash2: '{messageHash2}', subscribeHash2: '{subscribeHash2}', subscriptions keys: '{string.Join(",", subscriptions.Keys)}'");
return await future;
}
And updated log:
1180 loaded
waiting
watch, messageHash2: 'authenticated', subscribeHash2: 'authenticated', futures.ContainsKey: 'True', subscriptions.ContainsKey: 'False'
watch, messageHash2: 'authenticated', subscribeHash2: 'authenticated', futures.ContainsKey: 'True', subscriptions.ContainsKey: 'False'
watch, messageHash2: 'authenticated', subscribeHash2: 'authenticated', futures.ContainsKey: 'True', subscriptions.ContainsKey: 'False'
watch, messageHash2: 'authenticated', subscribeHash2: 'authenticated', futures.ContainsKey: 'True', subscriptions.ContainsKey: 'False'
watch, messageHash2: 'authenticated', subscribeHash2: 'authenticated', futures.ContainsKey: 'True', subscriptions.ContainsKey: 'False'
Sending order
watch, messageHash2: 'authenticated', subscribeHash2: 'authenticated', this subscription added
watch, messageHash2: 'authenticated', subscribeHash2: 'authenticated', futures keys: 'authenticated'
watch, messageHash2: 'authenticated', subscribeHash2: 'authenticated', futures keys: 'authenticated'
watch, messageHash2: 'authenticated', subscribeHash2: 'authenticated', futures keys: 'authenticated'
watch, messageHash2: 'authenticated', subscribeHash2: 'authenticated', futures keys: 'authenticated'
watch, messageHash2: 'authenticated', subscribeHash2: 'authenticated', subscriptions keys: 'authenticated'
watch, messageHash2: 'authenticated', subscribeHash2: 'authenticated', subscriptions keys: 'authenticated'
watch, messageHash2: 'authenticated', subscribeHash2: 'authenticated', subscriptions keys: 'authenticated'
watch, messageHash2: 'authenticated', subscribeHash2: 'authenticated', subscriptions keys: 'authenticated'
fetch Request:
bitget POST https://api.bitget.com/api/v2/margin/crossed/place-order
RequestHeaders:
ACCESS-KEY, xxx
ACCESS-SIGN, xxx
ACCESS-TIMESTAMP, 1717848153262
ACCESS-PASSPHRASE, xxx
X-CHANNEL-API-CODE, p4sve
Content-Type, application/json
RequestBody:
"{\"symbol\":\"XRPUSDT\",\"orderType\":\"limit\",\"price\":\"0.48\",\"force\":\"GTC\",\"side\":\"buy\",\"loanType\":\"normal\",\"baseSize\":\"11\"}"
handleRestResponse:
bitget POST https://api.bitget.com/api/v2/margin/crossed/place-order 200 OK
ResponseHeaders:
ResponseBody:
{"code":"00000","msg":"success","requestTime":1717848153715,"data":{"orderId":"1183306410625732609","clientOid":"310031d5f2f343228e0bdeaab0901fd0"}}
WebSocket connected to wss://ws.bitget.com/v2/ws/private
Sending message: {"op":"login","args":[{"apiKey":"xxx","passphrase":"xxx","timestamp":"1717848150","sign":"xxx"}]}
watch, messageHash2: 'authenticated', subscribeHash2: 'authenticated', futures keys: 'authenticated'
watch, messageHash2: 'authenticated', subscribeHash2: 'authenticated', subscriptions keys: 'authenticated'
On message: {"event":"login","code":0}
watch, messageHash2: 'order:XRP/USDT', subscribeHash2: 'order:trades:XRP/USDT:SPOT', futures.ContainsKey: 'False', subscriptions.ContainsKey: 'False'
watch, messageHash2: 'order:BTC/USDT', subscribeHash2: 'order:trades:MARGIN', futures.ContainsKey: 'False', subscriptions.ContainsKey: 'False'
watch, messageHash2: 'order:XRP/USDT', subscribeHash2: 'order:trades:MARGIN', futures.ContainsKey: 'False', subscriptions.ContainsKey: 'False'
watch, messageHash2: 'order:XRP/USDT', subscribeHash2: 'order:trades:XRP/USDT:SPOT', this subscription added
watch, messageHash2: 'order:BTC/USDT', subscribeHash2: 'order:trades:MARGIN', this subscription added
watch, messageHash2: 'order:XRP/USDT', subscribeHash2: 'order:trades:MARGIN', futures keys: 'order:XRP/USDT,order:BTC/USDT,authenticated'
Sending message: {"op":"subscribe","args":[{"instType":"MARGIN","channel":"orders-isolated","instId":"BTCUSDT"}]}
watch, messageHash2: 'order:XRP/USDT', subscribeHash2: 'order:trades:MARGIN', subscriptions keys: 'order:trades:MARGIN,order:trades:XRP/USDT:SPOT,authenticated'
Sending message: {"op":"subscribe","args":[{"instType":"SPOT","channel":"orders","instId":"XRPUSDT"}]}
watch, messageHash2: 'order:BTC/USDT', subscribeHash2: 'order:trades:MARGIN', futures.ContainsKey: 'False', subscriptions.ContainsKey: 'False'
watch, messageHash2: 'order:XRP/USDT', subscribeHash2: 'order:trades:MARGIN', futures.ContainsKey: 'False', subscriptions.ContainsKey: 'False'
watch, messageHash2: 'order:BTC/USDT', subscribeHash2: 'order:trades:MARGIN', futures keys: 'order:XRP/USDT,order:BTC/USDT,authenticated'
watch, messageHash2: 'order:XRP/USDT', subscribeHash2: 'order:trades:MARGIN', futures keys: 'order:XRP/USDT,order:BTC/USDT,authenticated'
watch, messageHash2: 'order:BTC/USDT', subscribeHash2: 'order:trades:MARGIN', subscriptions keys: 'order:trades:MARGIN,order:trades:XRP/USDT:SPOT,authenticated'
watch, messageHash2: 'order:XRP/USDT', subscribeHash2: 'order:trades:MARGIN', subscriptions keys: 'order:trades:MARGIN,order:trades:XRP/USDT:SPOT,authenticated'
watch, messageHash2: 'order:BTC/USDT', subscribeHash2: 'order:trades:MARGIN', futures keys: 'order:XRP/USDT,order:BTC/USDT,authenticated'
watch, messageHash2: 'order:XRP/USDT', subscribeHash2: 'order:trades:XRP/USDT:SPOT', futures keys: 'order:XRP/USDT,order:BTC/USDT,authenticated'
watch, messageHash2: 'order:BTC/USDT', subscribeHash2: 'order:trades:MARGIN', subscriptions keys: 'order:trades:MARGIN,order:trades:XRP/USDT:SPOT,authenticated'
watch, messageHash2: 'order:XRP/USDT', subscribeHash2: 'order:trades:XRP/USDT:SPOT', subscriptions keys: 'order:trades:MARGIN,order:trades:XRP/USDT:SPOT,authenticated'
On message: {"event":"subscribe","arg":{"instType":"MARGIN","channel":"orders-isolated","instId":"BTCUSDT"}}
On message: {"event":"subscribe","arg":{"instType":"SPOT","channel":"orders","instId":"XRPUSDT"}}
Orders: 0
What we have there, subscriptions keys:
'order:trades:MARGIN,order:trades:XRP/USDT:SPOT,authenticated'
But we have 6 total subscriptions, I extended names for clarify:
authenticated,
XRP/USDT:SPOT,
XRP/USDT:MARGIN:CROSS,
XRP/USDT:MARGIN:ISOLATED,
BTC/USDT:MARGIN:CROSS,
BTC/USDT:MARGIN:ISOLATED
from ccxt.
Here is my attempt to fix all these problems... At least you can use is as base.
Please look at the file.
bitget.zip
log:
1180 loaded
waiting
WebSocket connected to wss://ws.bitget.com/v2/ws/private
Sending message: {"op":"login","args":[{"apiKey":"xxx","passphrase":"xxx","timestamp":"1717854088","sign":"xxx"}]}
On message: {"event":"login","code":0}
Sending message: {"op":"subscribe","args":[{"instType":"USDT-FUTURES","channel":"orders","instId":"default"}]}
Sending message: {"op":"subscribe","args":[{"instType":"MARGIN","channel":"orders-crossed","instId":"XRPUSDT"}]}
Sending message: {"op":"subscribe","args":[{"instType":"MARGIN","channel":"orders-isolated","instId":"XRPUSDT"}]}
Sending message: {"op":"subscribe","args":[{"instType":"MARGIN","channel":"orders-crossed","instId":"BTCUSDT"}]}
Sending message: {"op":"subscribe","args":[{"instType":"SPOT","channel":"orders","instId":"XRPUSDT"}]}
Sending message: {"op":"subscribe","args":[{"instType":"MARGIN","channel":"orders-isolated","instId":"BTCUSDT"}]}
On message: {"event":"subscribe","arg":{"instType":"USDT-FUTURES","channel":"orders","instId":"default"}}
On message: {"event":"subscribe","arg":{"instType":"MARGIN","channel":"orders-crossed","instId":"XRPUSDT"}}
On message: {"event":"subscribe","arg":{"instType":"SPOT","channel":"orders","instId":"XRPUSDT"}}
On message: {"event":"subscribe","arg":{"instType":"MARGIN","channel":"orders-isolated","instId":"XRPUSDT"}}
On message: {"event":"subscribe","arg":{"instType":"MARGIN","channel":"orders-crossed","instId":"BTCUSDT"}}
On message: {"event":"subscribe","arg":{"instType":"MARGIN","channel":"orders-isolated","instId":"BTCUSDT"}}
Sending order
fetch Request:
bitget POST https://api.bitget.com/api/v2/margin/crossed/place-order
RequestHeaders:
ACCESS-KEY, xxx
ACCESS-SIGN, xxx
ACCESS-TIMESTAMP, 1717854090560
ACCESS-PASSPHRASE, xxx
X-CHANNEL-API-CODE, p4sve
Content-Type, application/json
RequestBody:
"{\"symbol\":\"XRPUSDT\",\"orderType\":\"limit\",\"price\":\"0.48\",\"force\":\"GTC\",\"side\":\"buy\",\"loanType\":\"normal\",\"baseSize\":\"11\"}"
handleRestResponse:
bitget POST https://api.bitget.com/api/v2/margin/crossed/place-order 200 OK
ResponseHeaders:
ResponseBody:
{"code":"00000","msg":"success","requestTime":1717854090846,"data":{"orderId":"1183331312745451521","clientOid":"4b7525e1ceb64c24b730c98e12e43c21"}}
On message: {"action":"snapshot","arg":{"instType":"MARGIN","channel":"orders-crossed","instId":"XRPUSDT"},"data":[{"enterPointSource":"api","feeDetail":[],"force":"gtc","orderType":"limit","price":"0.480000000","quoteSize":"5.280000000","side":"buy","status":"live","baseSize":"11.000000000","cTime":"1717854090868","clientOid":"4b7525e1ceb64c24b730c98e12e43c21","fillPrice":"0.000000000","baseVolume":"0.000000000","fillTotalAmount":"0.000000000","loanType":"normal","orderId":"1183331312745451521"}],"ts":1717854090886}
Cross Order XRP/USDT[4b7525e1ceb64c24b730c98e12e43c21]
Orders: 1
4b7525e1ceb64c24b730c98e12e43c21, count: 1, result: ok
from ccxt.
@skuvv can you tell, whether the update we made in bitget to handle incoming margin orders too, also fixed this issue?
from ccxt.
also I see you had these commented (and then manually directing incoming topics into handleOrder, if the topic name started with orders
phrase):
//{ "orders-algo", this.handleOrder },
//{ "orders-crossed", this.handleOrder },
//{ "orders-isolated", this.handleOrder },
do you remember, was there any case when the incoming string could have been different than these 3 prefixes?
from ccxt.
@skuvv can you tell, whether the update we made in bitget to handle incoming margin orders too, also fixed this issue?
sorry, didn't remember exactly which subscriptions were with problem.
also I see you had these commented (and then manually directing incoming topics into handleOrder, if the topic name started with
orders
phrase)://{ "orders-algo", this.handleOrder }, //{ "orders-crossed", this.handleOrder }, //{ "orders-isolated", this.handleOrder },
do you remember, was there any case when the incoming string could have been different than these 3 prefixes?
No, I haven't faced with other prefix, but I haven't cover all the cases.
from ccxt.
so, can you please clarify, did those updates also fixed this problem? if so, we can close this issue.
from ccxt.
@ttodua no, this was not helped, still have missed subscriptions, only 3 of all here:
Sending message: {"op":"subscribe","args":[{"instType":"MARGIN","channel":"orders-crossed","instId":"XRPUSDT"}]}
Sending message: {"op":"subscribe","args":[{"instType":"USDT-FUTURES","channel":"orders","instId":"default"}]}
Sending message: {"op":"subscribe","args":[{"instType":"SPOT","channel":"orders","instId":"XRPUSDT"}]}
On message: {"event":"subscribe","arg":{"instType":"MARGIN","channel":"orders-crossed","instId":"XRPUSDT"}}
On message: {"event":"subscribe","arg":{"instType":"USDT-FUTURES","channel":"orders","instId":"default"}}
On message: {"event":"subscribe","arg":{"instType":"SPOT","channel":"orders","instId":"XRPUSDT"}}
ps tested on v4.3.53
from ccxt.
Related Issues (20)
- crypto.com access denied HOT 5
- hyperliquid unable to use/debug "set_margin_mode" and "set_leverage" HOT 9
- GateIO Futures - Time/bid/ask is not saved in watch_tickers (also bid, ask). HOT 2
- New Exchange: Biconomy CEX - https://www.biconomy.com/en
- New Exchange: KoinBX CEX - https://koinbx.com/ HOT 1
- bitget .markets doesn't include margin markets HOT 1
- Error: self is not defined in Deno HOT 4
- Bitmart bid or ask getting stuck
- okx watchPositions extra parameters not working HOT 1
- hyperliquid create_order params are being ignored HOT 2
- binance fetch_open_interest_history params['paginate'] is overriden to False HOT 1
- kucoinfutures fetch_my_trades only returns 50 trades regardless of limit or pagination attempts HOT 1
- Bitmart - uid should be renamed to memo HOT 3
- How to place a spot marker order using base currency amount for Gate? HOT 3
- how log all ccxt calls? HOT 1
- ccxt.pro watch_ohlcv for multiple symbols from binance futures HOT 2
- CurrencyCom OHLCV fetch returning empty values HOT 1
- Biance USA, error on startup HOT 5
- Coinbase watch_order_book not returning the correct one if there are multiple streams running HOT 5
- Memory Leaks in PHP HOT 10
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 ccxt.