Cannot subscribe WebSocket for inverse contract in ByBit unified v3 API - websocket

I'm trying to use ByBit derivatives v3 API to subscribe public market data from WebSocket.
I first query instruments of inverse contract BTCUSD through /derivatives/v3/public/instruments-info, and I got this:
{
"symbol": "BTCUSD",
"contractType": "InversePerpetual",
"status": "Trading",
"baseCoin": "BTC",
"quoteCoin": "USD",
"launchTime": "0",
"deliveryTime": "0",
"deliveryFeeRate": "",
"priceScale": "2",
"leverageFilter": {
"minLeverage": "1",
"maxLeverage": "100",
"leverageStep": "0.01"
},
"priceFilter": {
"minPrice": "0.50",
"maxPrice": "999999.00",
"tickSize": "0.50"
},
"lotSizeFilter": {
"maxTradingQty": "1000000",
"minTradingQty": "1",
"qtyStep": "1"
}
}
Then I follow the WebSocket Data Document, using endpoint wss://stream.bybit.com/contract/usdt/public/v3 to subscribe topic orderbook.25.BTCUSD, and I got:
{"success":false,"ret_msg":"error:handler not found,topic:orderbook.25.BTCUSD","conn_id":"027f109e-a7fb-4af0-8b69-78bbb293e34b","req_id":"","op":"subscribe"}
Topic orderbook.25.BTCUSDT works. I know there is usdt in the websocket endpoints, but in the document there is no other choice. I tried usd/public/v3 unified/public/v3, none of them works.

Subscribe to wss://stream.bybit.com/realtime and send this message :
{"op":"subscribe","args":["trade.BTCUSD"]}
see https://bybit-exchange.github.io/docs/futuresV2/inverse/#t-websocket for the documentation

Related

Microsoft graph API - unable to use $filter operation in "toRecipients" array

Hello guys hope ur doing good,
I want to filter out the graph api response based on the "toRecipient" which is a array, hence I used lambda expression, but it gives error.
"error": {
"code": "ErrorInvalidUrlQueryFilter",
"message": "The query filter contains one or more invalid nodes.",
"innerError": {
"date": "2021-09-22T06:04:17",
"request-id": "c6077cd4-dbec-4671-9c11-10e547917d29",
"client-request-id": "66dfbc92-2482-11f3-86f9-22652a4e4e00"
}
}
My actual response is
"toRecipients": [
{
"emailAddress": {
"name": "abc",
"address": "abc#abc.com"
}
}
],
I had used this operation to filter out
https://graph.microsoft.com/v1.0/me/mailFolders/sentItems/messages?&$top=1000&$search="abc#abc.com"
Graph API calls underlaying Office 365 API.
According to the documentation, property ToRecipients is not filterable.

Cannot send messages in other channels except General msbot for teams (nodejs)

I have created a bot for teams and added it to a channel (testChannel1) as a tab (using a configuration page). I have received a ConversationUpdate event to my server. When I try to send message using the context object that I have received in ConversationUpdate event the message was sent in General channel instead of testChannel1. I have added my bot to testChannel1 but I dont know why the message is sent in General. I am also not able to get the channels list using that context object it is throwing error Error: This method is only valid within the scope of a MS Teams Team..
contextActivityObject :- {
"membersAdded": [
{
"id": "28:[guid]"
}
],
"type": "conversationUpdate",
"timestamp": "2020-04-24T12:00:06.7125247Z",
"id": "f:[guid]",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/in/",
"from": {
"id": "29:[id]",
"aadObjectId": "[guid]"
},
"conversation": {
"isGroup": true,
"conversationType": "channel",
"tenantId": "[guid]",
"id": "19:aba[id]#thread.tacv2"
},
"recipient": {
"id": "28:[guid]",
"name": "teststandups"
},
"channelData": {
"team": {
"aadGroupId": "[guid]",
"name": "nikhilp",
"id": "19:aba[id]#thread.tacv2"
},
"eventType": "teamMemberAdded",
"tenant": {
"id": "[guid]"
}
}
}
The scope I have provided for my bot is Team
I would be thankful for any help
So you've asked a couple of questions, I'll try answer as best as possible. Basically, that Conversation ID (19:aba[id]#thread.tacv2) is unique per channel, so if you're using the "General" channel one, it will for sure go into General.
To find out how to get the channel Ids, have a look at Get the list of channels in a team. That will show you -how- to get the info, but you need to get a trigger in order to be able to make that call. To do that, the best way is to hook into one of the triggers, like receiving a message from a user, or being added to the team. Included in these set of events, are channels being added and deleted. See more here.

When sending multiple messages using await context.PostAsync(reply), they are sometimes received out of order

When we send messages using the below code using the Directline channel, the messages are sometimes received with their order swapped.
await context.PostAsync(msg1);
await context.PostAsync(msg2);
Expected:
mgs1
msg2
But in some cases, they're coming through as
msg2
msg1
Is there any way to handle and prevent this?
I'm going to write this answer assuming you're using the Directline or REST API for receiving messages. I can update if that's not the case.
This entire answer is based off of the Receive activities from the bot docs as well as doing some testing of the Directline API to confirm.
If you're connected via WebSocket, you should always be receiving the messages in order, provided there isn't some kind of size difference in the messages (like one has an attachment) that requires additional processing.
If you're not, messages are retrieved via a polling interval, meaning that your client likely sends a GET request every 5 or 10 seconds (varies by client) to retrieve all messages that have not already been retrieved.
Upon doing so, the client will receive something like this:
{
"activities": [
{
"type": "message",
"channelId": "directline",
"conversation": {
"id": "abc123"
},
"id": "abc123|0000",
"from": {
"id": "user1"
},
"text": "hello"
},
{
"type": "message",
"channelId": "directline",
"conversation": {
"id": "abc123"
},
"id": "abc123|0001",
"from": {
"id": "bot1"
},
"text": "Nice to see you, user1!"
}
],
"watermark": "0001a-95"
}
My guess is that your client is just running a foreach on the array of activities, which could be displaying them out of order. If you have the client order them by either timestamp or id, it should work.

Bot framework direct line using POST with JSON data

I now use bot framework with Azure functions.
it now works when the user sends his message its writes it to queue storage then picked up by Azure function and sends it back to the bot with direct line build in Azure function connector.
I want to change the functionality to LogicAppp and return the answer to the user with direct-line with http rest.
I have a key and have a json input that the function got like this:
{
"relatesTo": {
"user": {
"id": "default-user",
"name": "User"
},
"bot": {
"id": "b5023440-b1ce-11e8-9ad8-f5b615a4c6c3",
"name": "Bot"
},
"conversation": {
"id": "33cd0410-bf46-11e8-a228-a5c7cd21a798|livechat"
},
"channelId": "emulator",
"serviceUrl": "https://0a87dff1.ngrok.io"
},
"text": "example",
"isTrustedServiceUrl": true
}
I try to answer the chat using
https://directline.botframework.com/v3/directline/conversations/{conversationId}/activitie
I can't make it work, the conversation id looks different, it's like a guid instead of an id.
how can help me with the right POST syntax from the json provided?

Error when attempting to create VSTS API Service Hook Subscription

Everyone,
I have been around and around about creating Visual Studio Team Services - Service Hook Subscriptions automagically via API. I can get the TFS publisher to work, but not the RM publisher. I am trying to create a hook subscription for Release Deployment Completed. Any examples I can find simply don't work even when swapped with my data. TFS provider works perfecty. Sample with response...
POST https://project.visualstudio.com/_apis/hooks/subscriptions?api-version=4.1-preview
Body:
{
"publisherId": "rm",
"eventType": "ms.vss-release.deployment-completed-event",
"consumerId": "slack",
"consumerActionId": "postMessageToChannel",
"publisherInputs": {
"releaseEnvironmentId" : "777",
"releaseDefinitionId" : "1",
"releaseEnvironmentStatus" : "4",
"projectId" : "6ce954b1-ce1f-45d1-b94d-e6bf2464ba2c"
},
"consumerInputs": {
"url": "https://hooks.slack.com/services/myservice/crazyGuidxxxxxxxxxxxxxxxx"
}
}
Response:
{
"$id": "1",
"innerException": null,
"message": "There is no registered handler for the service hooks event type ms.vss-release.deployment-completed-event.",
"typeName": "System.InvalidOperationException, mscorlib",
"typeKey": "InvalidOperationException",
"errorCode": 0,
"eventId": 0
}
It's because you missed vsrm in your url for a release. Use the following api and you'll get a successful response:
POST https://project.vsrm.visualstudio.com/_apis/hooks/subscriptions?api-version=4.1-preview

Resources