GithubHelp home page GithubHelp logo

jkorf / bybit.net Goto Github PK

View Code? Open in Web Editor NEW
88.0 9.0 59.0 5.37 MB

A C# .netstandard client library for the Bybit REST and Websocket V5 API focusing on clear usage and models

Home Page: https://jkorf.github.io/Bybit.Net/

C# 100.00%
bybit bybit-api bybit-apis bybit-bot bybit-rest bybit-sdk bybit-websocket cryptocurrency cryptocurrency-exchanges cryptoexchange-net

bybit.net's People

Contributors

afcrio avatar andrewtatham avatar battlefieldduck avatar bradtus avatar code-hatchery avatar ericgarnier avatar hui-shen avatar jkorf avatar kulikov-dev avatar luukholleman avatar mattjan7588 avatar mircofx avatar netstep avatar oxfordgrid avatar tosa27 avatar wclark17 avatar wtiben avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bybit.net's Issues

Future Api Klines Error

Dim clientBybit = New BybitClient 'API Bybit Exchange
clientBybit.SetApiCredentials(New ApiCredentials(API_Bybit1, Secret_Bybit1))
Dim m1d_BybitFuture As WebCallResult(Of IEnumerable(Of BybitKline))
Dim Fromtime as Date="1/1/2020"
m1d_BybitFuture = Await clientBybit.UsdPerpetualApi.ExchangeData.GetKlinesAsync("ETHUSDT", KlineIntervalBybit.OneHour , fromtime, 24 )

I was expecting i got:
m1d_BybitFuture.Data(0).OpenTime="1/1/2020"
m1d_BybitFuture.Data(m1d_BybitFuture.Data.Count - 1).OpenTime="1/1/2020 11:00:00 PM"

But I got this wrong answer:
m1d_BybitFuture.Data(0).OpenTime="10/21/2020 9:00:00 AM"
m1d_BybitFuture.Data(m1d_BybitFuture.Data.Count - 1).OpenTime="10/22/2020 8:00:00 AM"

Spot is ok, true answer but UsdPerpetualApi and InversePerpetualApi get wrong answer
Please help me to fix this. Thank you

UsdPerpetualStreams.SubscribeToTickersUpdatesAsync doesnt seem to work

UsdPerpetualStreams.SubscribeToTickersUpdatesAsync seems to never issue an await call. And the the result is only a piece of singular symbol data and not the entire symbol list I would expect

        var result = await bybit_SockClient.UsdPerpetualStreams.SubscribeToTickersUpdatesAsync(async data =>
        {
            // This is never triggered. If you do ToTicker with Symbol it does???
            foreach (var info in data.Data)    //  data.Data is only showing the result for a single symbol not a list so you cant do foreach
            {


            }
        }).ConfigureAwait(false);

Thanks Rob

Redundant OrderType.LimitMaker

This enum type doesn't exist in Usdt Perps API and OrderTypeConverter. It might be worth splitting this enum into 2 different

trade list endpoint wrong

The endpoint for the list of user trades in UsdPerpetual is set to "/private/linear/execution/list" but should be "/private/linear/trade/execution/list" in BybitClientUsdPerpetualApiTrading.
I was about to send this as a pull request - changing the URL I now get a proper successful response from the call - but the list of trades is always empty.
The request looks fine right before it's submitted: GET to "https://api-testnet.bybit.com/private/linear/trade/execution/list?api_key=xxxxx&recvWindow=5000&symbol=BTCUSDT&timestamp=1643810171081&sign=xxxxx"
X-checking in postman I get the proper list. Will check further later today but thought you might have an idea.

client endpoint mixup

some (not all) calls under the UsdPerpetual client seem to redirect to the corresponding InversePerpetual client routines which is fine as they have the same signature but it silently uses the InversePerpetual client options as well. In my case I had only the UsdPerpetual client options configured (for testnet) and was surprised that the calls targeted the live URLs as these are the default for the InversePerpetual client... then obviously complaining about a bad API key as testnet and live are using separate keys.

Deserialize JsonSerializationException

When I try to run the "SetLeverageAsync" I receive an Json Serialization Exception:

Command line: var resultado = ClienteRest.InverseFuturesApi.Account.SetLeverageAsync("BTCUSDU22", 5, 5).Result;

Result error message: "Deserialize JsonSerializationException: Error converting value {null} to type 'System.Int32'. Path 'result', line 1, position 70."

ERRO=[22] Deserialize JsonSerializationException: Error converting value {null} to type 'System.Int32'. Path 'result', line 1, position 70. data: {
"ret_code": 0,
"ret_msg": "OK",
"ext_code": "",
"ext_info": "",
"result": null,
"time_now": "1650487234.099507",
"rate_limit_status": 74,
"rate_limit_reset_ms": 1650487234098,
"rate_limit": 75
}

I'm using the latest versions:
ByBit.Net 1.0.0
CryptoExchange.Net 5.1.7

Param validation for 'symbol' failed on the 'linear_symbol' tag

Hi,
I am using Bybit.Net version 0.0.1-beta5.

I cannot send a limit buy order or market order for BITUSD (not BITUSDT) in futures.
Error header: Param validation for 'symbol' failed on the 'linear_symbol' tag (Error Code: 10001)
Below I am attaching the C# code block and the outgoing statement in the HTTP request.
Can you tell me what am I missing?

Code:
var limitOrderResult = await client.UsdPerpetualApi.Trading.PlaceOrderAsync( symbol: "BITUSD", side: Bybit.Net.Enums.OrderSide.Buy, type: Bybit.Net.Enums.OrderType.Limit, quantity: 20, timeInForce: Bybit.Net.Enums.TimeInForce.GoodTillCanceled, reduceOnly: false, closeOnTrigger: false, price: 1.4M).ConfigureAwait(false);

Request Body:
api_key=XXXXXXXXXXX&close_on_trigger=False&order_type=Limit&price=1.4&qty=20&recvWindow=5000&reduce_only=False&side=Buy&symbol=BITUSD&time_in_force=GoodTillCancel&timestamp=1643129586158&sign=XXXXXXXXXXXXXX

Request URL:
https://api.bybit.com/private/linear/order/create

InvariantCulture is missing at SetTradingStopAsync

Hi,

if I execute BybitClientInversePerpetualApiTrading.SetTradingStopAsync on my local machine (wich is not english culture) the call gives an error.
I think this is because CultureInfo.InvariantCulture is missing at the ToString calls for the decimal values .
So setting the price to eg 42.000 results in 42,000 which gives a 'sign!' error from bybit.

Websocket Tickerdata price differs from the actual price

Hello, Im using websocket ticker data api to sace the best ask and bid prices and it sometimes significantly differs from what i see on tradingview.com's Chart+. Here's a photo
The code is very simple Tickerdata ipdate event is triggered and it saves the whole object into a public variable
subscribe =>
UpdateResults = await SocketClient.UsdPerpetualStreams.SubscribeToTickerUpdatesAsync(Symbol.Name, SocketHandler_TickerDataUpdate);
Event=>
private void SocketHandler_TickerDataUpdate(DataEvent<BybitTickerUpdate> obj) foreach (var stringPropertyNamesAndValues in obj.Data.GetType() .GetProperties().Where(x => x.GetType() != null) .Select(pi => new { pi.Name, Value = pi.GetGetMethod().Invoke(obj.Data, null) })) { if (stringPropertyNamesAndValues.Value != null) { PropertyInfo propertyInfo = TickerData.GetType().GetProperty(stringPropertyNamesAndValues.Name); if (propertyInfo.GetGetMethod().Invoke(obj.Data, null) != null) propertyInfo.SetValue(TickerData, stringPropertyNamesAndValues.Value, null); } }
and writing to the db file.
BTW i use lock to prevent Threads from Interfering

403 error

hello with this new update i encounter this error while trying to fetch the currencies endpoints

<title>Access Denied</title>

Access Denied

You don't have permission to access "/v2/public/symbols" on this server.
0.ece83217.1658441122.750f9789

Spot Api Klines Error 2

Hello,
I'm running the GetKlinesAsync() method using the Bybit Spot API. However, as far as I can see, the 'CloseTime' field among the incoming data is always null.
Thank you.

var klineResult = await client.SpotApi.ExchangeData.GetKlinesAsync("1SOLUSDT", Bybit.Net.Enums.KlineInterval.OneMonth, ct: stoppingToken);
if (klineResult.Success && klineResult.Data.Any())
{

}

SubscribeToStopOrderUpdatesAsync fails when PartialStopLoss or PartialTakeProfit are used

When I use partial mode position in UsdPerpetualStreams, this subscribe method will be called with those Stop order types and this error is received:

2022/07/06 07:40:08:714 | Warning | Cannot map enum value. EnumType: Bybit.Net.Enums.StopOrderType, Value: PartialStopLoss, Known values: TakeProfit, StopLoss, TrailingStop, Stop. If you think PartialStopLoss should added please open an issue on the Github repo
2022/07/06 07:40:08:716 | Error | Bybit | Deserialize JsonSerializationException: Error setting value to 'StopOrderType' on 'Bybit.Net.Objects.Models.Socket.BybitUsdPerpetualStopOrderUpdate'. data: [

I think both types should be added to StopOrderType enumerator and properly conversion to class StopOrderTypeConverter.

Socket Data Null Fields

Hi,
While reading data from the socket, a lot of data comes as 'null'.
Also, many socket functions for both Spot and Futures don't seem to work properly.
Thanks.
Ekran Alıntısı

Missing "ReduceOnly" Property from BybitConditionalOrder

Dim BybitOpenOrders_Conditional = Await clientBybit.UsdPerpetualApi.Trading.GetOpenConditionalOrdersRealTimeAsync(Symbol, receiveWindow:=receiveWindow)

Dim BybitOpenOrders_Conditional = Await clientBybit.InversePerpetualApi.Trading.GetOpenConditionalOrdersRealTimeAsync(Symbol_CoinFuture, receiveWindow:=receiveWindow)

Error is missing ReduceOnly Property in BybitConditionalOrder

GetOpenOrdersRealTimeAsync is ok but missing ReduceOnly in GetOpenConditionalOrdersRealTimeAsync

Socket - Subscribe To All Ticker

Hello,
I want to listen to the price change of all symbols from the socket instantly. However, I couldn't find a method for this.
Do you have to listen separately for each symbol? (SubscribeToTickerUpdatesAsync())
Thanks.

Exception at reading data from websocket subscription

I tried to subscribe to UsdPerpetualStreams.SubscribeToOrderUpdatesAsync and UsdPerpetualStreams.SubscribeToPositionUpdatesAsync via websockets. There is no response bit an exception is logged.
To test this simply subscribe and place an order. This is on testnet but I don't think there is a big difference.

Exception thrown: 'Newtonsoft.Json.JsonReaderException' in Newtonsoft.Json.dll
Exception thrown: 'Newtonsoft.Json.JsonReaderException' in Newtonsoft.Json.dll
Exception thrown: 'Newtonsoft.Json.JsonReaderException' in Newtonsoft.Json.dll
Exception thrown: 'Newtonsoft.Json.JsonReaderException' in Newtonsoft.Json.dll
Exception thrown: 'Newtonsoft.Json.JsonReaderException' in Newtonsoft.Json.dll
2022.01.25 11:32:34:718 | Error | Bybit | Deserialize JsonReaderException: Unexpected character encountered while parsing number: T. Path '', line 1, position 10. Path: , LineNumber: 1, LinePosition: 10, data: [
{
"order_id": "19bffe79-de68-4c53-9515-4f91b0c70112",
"order_link_id": "",
"symbol": "BTCUSDT",
"side": "Buy",
"order_type": "Market",
"price": 38262,
"qty": 0.01,
"leaves_qty": 0,
"last_exec_price": 36442,
"cum_exec_qty": 0.01,
"cum_exec_value": 364.411,
"cum_exec_fee": 0.0273315,
"time_in_force": "ImmediateOrCancel",
"create_type": "CreateByUser",
"cancel_type": "UNKNOWN",
"order_status": "Filled",
"take_profit": 0,
"stop_loss": 0,
"trailing_stop": 0,
"create_time": "2022-01-25T10:32:34.519268798Z",
"update_time": "2022-01-25T10:32:34.519369Z",
"reduce_only": false,
"close_on_trigger": false,
"position_idx": "1"
}
]
2022.01.25 11:32:34:725 | Warning | Bybit | Failed to deserialize BybitOrderUpdate object: : Deserialize JsonReaderException: Unexpected character encountered while parsing number: T. Path '', line 1, position 10. Path: , LineNumber: 1, LinePosition: 10, data: [
{
"order_id": "19bffe79-de68-4c53-9515-4f91b0c70112",
"order_link_id": "",
"symbol": "BTCUSDT",
"side": "Buy",
"order_type": "Market",
"price": 38262,
"qty": 0.01,
"leaves_qty": 0,
"last_exec_price": 36442,
"cum_exec_qty": 0.01,
"cum_exec_value": 364.411,
"cum_exec_fee": 0.0273315,
"time_in_force": "ImmediateOrCancel",
"create_type": "CreateByUser",
"cancel_type": "UNKNOWN",
"order_status": "Filled",
"take_profit": 0,
"stop_loss": 0,
"trailing_stop": 0,
"create_time": "2022-01-25T10:32:34.519268798Z",
"update_time": "2022-01-25T10:32:34.519369Z",
"reduce_only": false,
"close_on_trigger": false,
"position_idx": "1"
}
] [
{
"order_id": "19bffe79-de68-4c53-9515-4f91b0c70112",
"order_link_id": "",
"symbol": "BTCUSDT",
"side": "Buy",
"order_type": "Market",
"price": 38262,
"qty": 0.01,
"leaves_qty": 0,
"last_exec_price": 36442,
"cum_exec_qty": 0.01,
"cum_exec_value": 364.411,
"cum_exec_fee": 0.0273315,
"time_in_force": "ImmediateOrCancel",
"create_type": "CreateByUser",
"cancel_type": "UNKNOWN",
"order_status": "Filled",
"take_profit": 0,
"stop_loss": 0,
"trailing_stop": 0,
"create_time": "2022-01-25T10:32:34.519268798Z",
"update_time": "2022-01-25T10:32:34.519369Z",
"reduce_only": false,
"close_on_trigger": false,
"position_idx": "1"
}
]
Exception thrown: 'System.ArgumentOutOfRangeException' in System.Private.CoreLib.dll
'ConsoleApp1.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.1\System.Diagnostics.StackTrace.dll'.
'ConsoleApp1.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.1\System.Reflection.Metadata.dll'.
'ConsoleApp1.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.1\System.Collections.Immutable.dll'.
2022.01.25 11:32:34:932 | Error | Bybit | Socket 1 Exception during message processing
Exception: ArgumentOutOfRangeException - Length cannot be less than zero. (Parameter 'length')
at System.String.Substring(Int32 startIndex, Int32 length)
at Bybit.Net.Clients.BybitSocketClient.MessageMatchesHandler(SocketConnection socketConnection, JToken message, Object request)
at CryptoExchange.Net.Sockets.SocketConnection.HandleData(MessageEvent messageEvent)

Data: {
"topic": "order",
"action": "",
"data": [
{
"order_id": "19bffe79-de68-4c53-9515-4f91b0c70112",
"order_link_id": "",
"symbol": "BTCUSDT",
"side": "Buy",
"order_type": "Market",
"price": 38262,
"qty": 0.01,
"leaves_qty": 0,
"last_exec_price": 36442,
"cum_exec_qty": 0.01,
"cum_exec_value": 364.411,
"cum_exec_fee": 0.0273315,
"time_in_force": "ImmediateOrCancel",
"create_type": "CreateByUser",
"cancel_type": "UNKNOWN",
"order_status": "Filled",
"take_profit": 0,
"stop_loss": 0,
"trailing_stop": 0,
"create_time": "2022-01-25T10:32:34.519268798Z",
"update_time": "2022-01-25T10:32:34.519369Z",
"reduce_only": false,
"close_on_trigger": false,
"position_idx": "1"
}
]
}
Exception thrown: 'System.ArgumentOutOfRangeException' in System.Private.CoreLib.dll
2022.01.25 11:32:34:960 | Error | Bybit | Socket 1 Exception during message processing
Exception: ArgumentOutOfRangeException - Length cannot be less than zero. (Parameter 'length')
at System.String.Substring(Int32 startIndex, Int32 length)
at Bybit.Net.Clients.BybitSocketClient.MessageMatchesHandler(SocketConnection socketConnection, JToken message, Object request)
at CryptoExchange.Net.Sockets.SocketConnection.HandleData(MessageEvent messageEvent)

Data: {
"topic": "position",
"action": "update",
"data": [
{
"user_id": "443745",
"symbol": "BTCUSDT",
"size": 0.01,
"side": "Buy",
"position_value": 364.411,
"entry_price": 36441.098,
"liq_price": 32979.5,
"bust_price": 32797,
"leverage": 10,
"order_margin": 0,
"position_margin": 36.68708,
"occ_closing_fee": 0.2459775,
"take_profit": 0,
"tp_trigger_by": "UNKNOWN",
"stop_loss": 0,
"sl_trigger_by": "UNKNOWN",
"trailing_stop": 0,
"realised_pnl": -3.9626534,
"auto_add_margin": "0",
"cum_realised_pnl": -4.0535393,
"position_status": "Normal",
"position_id": "0",
"position_seq": "10383",
"adl_rank_indicator": "2",
"free_qty": 0.01,
"tp_sl_mode": "Full",
"risk_id": "1",
"isolated": true,
"mode": "BothSide",
"position_idx": "1"
},
{
"user_id": "443745",
"symbol": "BTCUSDT",
"size": 0,
"side": "Sell",
"position_value": 0,
"entry_price": 0,
"liq_price": 0,
"bust_price": 0,
"leverage": 10,
"order_margin": 0,
"position_margin": 0,
"occ_closing_fee": 0,
"take_profit": 0,
"tp_trigger_by": "UNKNOWN",
"stop_loss": 0,
"sl_trigger_by": "UNKNOWN",
"trailing_stop": 0,
"realised_pnl": -0.9992362,
"auto_add_margin": "0",
"cum_realised_pnl": -0.9992362,
"position_status": "Normal",
"position_id": "0",
"position_seq": "10380",
"adl_rank_indicator": "0",
"free_qty": 0,
"tp_sl_mode": "Full",
"risk_id": "1",
"isolated": true,
"mode": "BothSide",
"position_idx": "2"
}
]
}

no authentication is provided for private endpoints

set all the available api authentications in BybitSocketClientOptions still getting this error while trying to subscribe to user data such as bybitSocketClient.UsdPerpetualStreams.SubscribeToUserTradeUpdatesAsync

        var bybitSocketClient = new BybitSocketClient(new BybitSocketClientOptions()
        {

            AutoReconnect = true,
            UsdPerpetualStreamsOptions = new BybitSocketApiClientOptions()
            {
                ApiCredentials = new ApiCredentials(textBox1.Text.Replace(" ", ""), textBox2.Text.Replace(" ", "")),
            },
            InversePerpetualStreamsOptions = new BybitSocketApiClientOptions()
            {
                ApiCredentials = new ApiCredentials(textBox1.Text.Replace(" ", ""), textBox2.Text.Replace(" ", "")),
            },
            SpotStreamsOptions = new BybitSocketApiClientOptions()
            {
                ApiCredentials = new ApiCredentials(textBox1.Text.Replace(" ", ""), textBox2.Text.Replace(" ", "")),
            },
            InverseFuturesStreamsOptions=new BybitSocketApiClientOptions()
            {
                ApiCredentials = new ApiCredentials(textBox1.Text.Replace(" ", ""), textBox2.Text.Replace(" ", "")),
            },
            SocketResponseTimeout = TimeSpan.FromSeconds(1),
            SocketSubscriptionsCombineTarget = 2,
            OutputOriginalData = true,
            LogLevel = Microsoft.Extensions.Logging.LogLevel.Trace,
            ApiCredentials = new ApiCredentials(textBox1.Text.Replace(" ", ""), textBox2.Text.Replace(" ", "")),
        });

and
var t = await bybitSocketClient.UsdPerpetualStreams.SubscribeToTradeUpdatesAsync(Crypto.Name, TradesHandler);
returns "Authentication failed: No credentials provided for private endpoint"

Missing "Status" Property from BybitConditionalOrderUsd

Dim ItemOrder As WebCallResult(Of BybitConditionalOrderUsd) = Await clientFutureBybit.UsdPerpetualApi.Trading.GetOpenConditionalOrderRealTimeAsync(Symbol, , ClientOrderId, receiveWindow:=receiveWindow)
Msgbox(ItemOrder.Data.Status)

or:

Dim ItemOrders= Await clientFutureBybit.UsdPerpetualApi.Trading.GetConditionalOrdersAsync(Symbol, receiveWindow:=receiveWindow)
Msgbox(ItemOrders.Data.Data(0).Status)

Error is missing Status Property

GetOpenOrderRealTimeAsync is ok but missing status in GetOpenConditionalOrderRealTimeAsync and GetConditionalOrdersAsync

UsdPerpetualApi, InverseFuturesApi and InversePerpetualApi invalid request !

Hello,
When I make any request to places other than the Spot API (Example: Bringing balance information), I get an error with the code 10002.

Bybit.Net Version: v1.0.6
Error Code: 10002
Error Message: invalid request, please check your timestamp and recv_window param. req_timestamp: 1657479201370 server_timestamp: 1657479200284 recv_window: 5000

Sample Code:

var res = await client.InverseFuturesApi.Account.GetBalancesAsync();

Spot Api Klines Error 1

Hello,
When I want to get data on a monthly basis using the Bybit Spot API, the data comes on a minute basis.
Sample code is below.
Thank you.

var klineResult = await client.SpotApi.ExchangeData.GetKlinesAsync("1SOLUSDT", Bybit.Net.Enums.KlineInterval.OneMonth, ct: stoppingToken);
if (klineResult.Success && klineResult.Data.Any())
{

}

SubscribeToBalanceUpdatesAsync -> BybitBalanceUpdate missing "Asset" property

The class "BybitBalanceUpdate" in "namespace Bybit.Net.Objects.Models.Socket" is missing the "Asset" property, showing only the "WalletBalance" and "AvailableBalance". Version ByBit.Net 1.0.0 and CryptoExchange.Net 5.1.7

The log result from the handler:

{
"Timestamp": "2022-04-21T21:10:05.3008907Z",
"Topic": null,
"OriginalData": "{"topic":"wallet","data":[{"user_id":2052755,"coin":"BTC","available_balance":"0.00000000","wallet_balance":"0.00000000"}]}",
"Data": [
{
"wallet_balance": 0.00000000,
"available_balance": 0.00000000
}
]
}

User Socket Expire?

Hi,
I created a socket connection for listening in my user account. (SubscribeToAccountUpdatesAsync())
But will this link stay open forever?
No timeout?
Is there a method that I can trigger in certain periods so that there is no timeout?
Thanks.

There is no ClosePositionAsync

Hi is there any way closing an open position be implemented in this package?Like clicking on the Market or Limit button next to the open position in the website

Set Leverage for Float Type

Hi,

I think, we need change parameter type from Integer to Float for Set Leverage, because on Bybit the leverage can be set as decimal.

thanks Team.

order fix price failed for CannotAffordOrderCost.

I am getting an error while submitting a purchase order.?

Error Code: 30031
Error Message: order[576661 fad5247a-9335-47cd-bc0f-993bc740600c] fix price failed for CannotAffordOrderCost.

var result = await client.InversePerpetualApi.Trading.PlaceOrderAsync(
                    symbol: "BITUSD",
                    side: OrderSide.Buy,
                    type: OrderType.Market,
                    quantity: 1,
                    timeInForce: TimeInForce.GoodTillCanceled,
                    price: null,
                    clientOrderId: null,
                    ct: ct).ConfigureAwait(false);

BybitOrderBookEntry.Quantity is a Decimal in Bybit.Net, and an Int in the Bybit API. What does this mean?

Quick question about the definition of BybitOrderBookEntry.Quantity...

The response for the orderbooks asks/bids Quantity value is of type decimal (with decimal values), but from the Bybit documentation, it looks like this value would be an Int, with much larger integer values (ie., integer number of contracts in USD).

Can someone help me understand what the definition of BybitOrderBookEntry.Quantity is within Bybit.Net is?

Missing position endpoint properties

Hey there, somehow PositionMode-property (position_idx in the json response) ... is missing in GetPositionsAsync() ... it is delivered with SubscribeToPositionUpdatesAsync() i would like to check if my symbosl are in the correct mode when setting up he bot. Could you add that? It should inherit from the base classes (by looking at your code) but i have no clue why its not visible

Deserialize JsonSerializationException: Error setting value to 'OrderType' on 'Bybit.Net.Objects.Models.BybitUserTrade'

Hi I was just testing the GetUserTradesAsync api when i encountered this error
no special settings or call just the example from the docs:

            var userTradesResult = await bybitClient.UsdPerpetualApi.Trading.GetUserTradesAsync(Crypto.Name);
            if (userTradesResult.Success)
            {
                foreach (var t in userTradesResult.Data.Data)
                {
                    if (t.QuantityRemaining!=0.000000m)
                    {
//do sth
                    }
                }
            }

2022/05/11 12:56:40:124 | Error | Bybit | [9] Deserialize JsonSerializationException: Error setting value to 'OrderType' on 'Bybit.Net.Objects.Models.BybitUserTrade'. data: {
"ret_code": 0,
"ret_msg": "OK",
"ext_code": "",
"ext_info": "",
"result": {
"current_page": 1,
"data": [
{
"order_id": "f32133d7-66d8-4ad7-99d2-5267e2dc5d4f",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "f32133d7-66d8-4ad7-99d2-5267e2dc5d4f",
"price": 0.00733,
"order_price": 0.00733,
"order_qty": 940,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00718,
"exec_type": "BustTrade",
"exec_qty": 940,
"exec_fee": 0.00404952,
"exec_value": 6.7492,
"leaves_qty": 0,
"closed_size": 940,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652253746,
"trade_time_ms": 1652253746981
},
{
"order_id": "085a39f1-d948-455e-b033-415196f6aa38",
"order_link_id": "",
"side": "Buy",
"symbol": "SLPUSDT",
"exec_id": "9df92d3f-8c7c-56f0-9238-c679a13c3b75",
"price": 0.00778,
"order_price": 0.00778,
"order_qty": 940,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00755,
"exec_type": "Trade",
"exec_qty": 940,
"exec_fee": 0.0042582,
"exec_value": 7.097,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652253494,
"trade_time_ms": 1652253494616
},
{
"order_id": "e911c04f-a768-421c-ac09-841746c23a8b",
"order_link_id": "",
"side": "Buy",
"symbol": "SLPUSDT",
"exec_id": "379284fa-4322-566a-a407-317818468bdc",
"price": 0.00767,
"order_price": 0.00767,
"order_qty": 480,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00732,
"exec_type": "Trade",
"exec_qty": 480,
"exec_fee": 0.00210816,
"exec_value": 3.5136,
"leaves_qty": 0,
"closed_size": 480,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652253198,
"trade_time_ms": 1652253198309
},
{
"order_id": "f4d4675d-f3f5-4eed-a5de-115fa084e273",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "7c0cd568-241f-55fe-a8ae-010d52391848",
"price": 0.00719,
"order_price": 0.00719,
"order_qty": 480,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00736,
"exec_type": "Trade",
"exec_qty": 480,
"exec_fee": 0.00211968,
"exec_value": 3.5328,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652253163,
"trade_time_ms": 1652253163020
},
{
"order_id": "7fbfa24c-f2ab-4717-be97-16e5ee586ecf",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "5b5f1c7b-467d-51b7-87c3-d035e02d26b8",
"price": 0.00729,
"order_price": 0.00729,
"order_qty": 460,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00767,
"exec_type": "Trade",
"exec_qty": 460,
"exec_fee": 0.00211692,
"exec_value": 3.5282,
"leaves_qty": 0,
"closed_size": 460,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652252703,
"trade_time_ms": 1652252703074
},
{
"order_id": "1652252400-SLPUSDT-24638417-Buy",
"order_link_id": "",
"side": "Buy",
"symbol": "SLPUSDT",
"exec_id": "5a01cfa0-fe92-4edf-9f1b-3adcbfa5fe9f",
"price": 0,
"order_price": 0,
"order_qty": 0,
"order_type": "",
"fee_rate": 1.25E-05,
"exec_price": 0.00758,
"exec_type": "Funding",
"exec_qty": 460,
"exec_fee": 4.359E-05,
"exec_value": 3.4868,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "LiquidityIndNA",
"trade_time": 1652252400,
"trade_time_ms": 1652252400000
},
{
"order_id": "85902a57-f353-4c08-a4df-76cc6e10befe",
"order_link_id": "",
"side": "Buy",
"symbol": "SLPUSDT",
"exec_id": "028136a5-de65-5349-8609-065827a2ae82",
"price": 0.00798,
"order_price": 0.00798,
"order_qty": 460,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.0076,
"exec_type": "Trade",
"exec_qty": 460,
"exec_fee": 0.0020976,
"exec_value": 3.496,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652252279,
"trade_time_ms": 1652252279729
},
{
"order_id": "1a43798e-8759-4bb4-b998-9ad2a8ee1ce0",
"order_link_id": "",
"side": "Buy",
"symbol": "SLPUSDT",
"exec_id": "56531fd0-5c4a-5b8f-a50d-f39e54293963",
"price": 0.00841,
"order_price": 0.00841,
"order_qty": 440,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00802,
"exec_type": "Trade",
"exec_qty": 440,
"exec_fee": 0.00211728,
"exec_value": 3.5288,
"leaves_qty": 0,
"closed_size": 440,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652250429,
"trade_time_ms": 1652250429905
},
{
"order_id": "216f2226-0b1a-4dbf-b94c-0d5e88ea574f",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "ff53a28a-c1dd-5ad9-b6df-4caf9d893152",
"price": 0.00799,
"order_price": 0.00799,
"order_qty": 440,
"order_type": "Limit",
"fee_rate": 0.0006,
"exec_price": 0.00799,
"exec_type": "Trade",
"exec_qty": 190,
"exec_fee": 0.00091086,
"exec_value": 1.5181,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652250278,
"trade_time_ms": 1652250278138
},
{
"order_id": "216f2226-0b1a-4dbf-b94c-0d5e88ea574f",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "980101d9-c770-5b38-8f5e-183cad70f73d",
"price": 0.00799,
"order_price": 0.00799,
"order_qty": 440,
"order_type": "Limit",
"fee_rate": 0.0006,
"exec_price": 0.00799,
"exec_type": "Trade",
"exec_qty": 250,
"exec_fee": 0.0011985,
"exec_value": 1.9975,
"leaves_qty": 190,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652250278,
"trade_time_ms": 1652250278138
},
{
"order_id": "f20efb77-1079-45be-bb2e-5f4dae3d8191",
"order_link_id": "",
"side": "Buy",
"symbol": "SLPUSDT",
"exec_id": "ef8ca6f2-e507-58c0-9eee-a08d6c905e98",
"price": 0.0089,
"order_price": 0.0089,
"order_qty": 240,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 240,
"exec_fee": 0.00122256,
"exec_value": 2.0376,
"leaves_qty": 0,
"closed_size": 240,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247766,
"trade_time_ms": 1652247766520
},
{
"order_id": "d776e172-71c4-4c7e-a2ab-7c7b7ffd1121",
"order_link_id": "",
"side": "Buy",
"symbol": "SLPUSDT",
"exec_id": "c64a11b2-cc62-5d25-8153-0038890cff33",
"price": 0.00891,
"order_price": 0.00891,
"order_qty": 1730,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.0085,
"exec_type": "Trade",
"exec_qty": 1730,
"exec_fee": 0.008823,
"exec_value": 14.705,
"leaves_qty": 0,
"closed_size": 1730,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247758,
"trade_time_ms": 1652247758539
},
{
"order_id": "c50902df-476f-4ebc-9802-e251853ceacc",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "16faf138-af70-52a2-a806-eba958a3f443",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 240,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 240,
"exec_fee": 0.00122256,
"exec_value": 2.0376,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247756,
"trade_time_ms": 1652247756708
},
{
"order_id": "d7098f48-ce27-4fbe-bc56-7fce3d60af1a",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "4c0b4bb3-c879-5d7c-89a2-d7b2b5c96c00",
"price": 0.00808,
"order_price": 0.00808,
"order_qty": 300,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.0085,
"exec_type": "Trade",
"exec_qty": 300,
"exec_fee": 0.00153,
"exec_value": 2.55,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247750,
"trade_time_ms": 1652247750434
},
{
"order_id": "3e179f1d-e656-4ca6-b828-86b8428d6a15",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "535730f2-692c-5ba3-873d-6a79c4c9a6d0",
"price": 0.00808,
"order_price": 0.00808,
"order_qty": 300,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00851,
"exec_type": "Trade",
"exec_qty": 300,
"exec_fee": 0.0015318,
"exec_value": 2.553,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247744,
"trade_time_ms": 1652247744081
},
{
"order_id": "ee754562-2a31-4f88-bb4e-e3c5a4eae21c",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "f6bd2db8-3b20-592b-b409-8c9dd8b6f35f",
"price": 0.00807,
"order_price": 0.00807,
"order_qty": 340,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 340,
"exec_fee": 0.00173196,
"exec_value": 2.8866,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247737,
"trade_time_ms": 1652247737242
},
{
"order_id": "93a9bcac-fd02-46ce-8893-67a7102be334",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "12d970fa-eccf-510b-b34a-067c99645cfa",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 370,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 50,
"exec_fee": 0.0002547,
"exec_value": 0.4245,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247730,
"trade_time_ms": 1652247730899
},
{
"order_id": "93a9bcac-fd02-46ce-8893-67a7102be334",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "9eea7de8-79fa-546b-abb2-f4a6bdba12ff",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 370,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.0085,
"exec_type": "Trade",
"exec_qty": 320,
"exec_fee": 0.001632,
"exec_value": 2.72,
"leaves_qty": 50,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247730,
"trade_time_ms": 1652247730899
},
{
"order_id": "ead6aec6-b697-44d6-8cb2-c24ec00d629e",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "7755ed3f-f240-5115-ab55-c970ea51daa5",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 410,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 410,
"exec_fee": 0.00208854,
"exec_value": 3.4809,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247724,
"trade_time_ms": 1652247724425
},
{
"order_id": "f9a93f97-14ad-4f6c-9039-06692558642f",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "58961ed3-edc7-5d71-9564-4cf4a954377e",
"price": 0.00808,
"order_price": 0.00808,
"order_qty": 10,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 10,
"exec_fee": 5.094E-05,
"exec_value": 0.0849,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247718,
"trade_time_ms": 1652247718172
},
{
"order_id": "bdd777d2-20e1-46cb-8059-2d8a60e2c239",
"order_link_id": "",
"side": "Buy",
"symbol": "SLPUSDT",
"exec_id": "608c5bb3-ecf1-56aa-8d8e-613f593cd642",
"price": 0.00892,
"order_price": 0.00892,
"order_qty": 4080,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00851,
"exec_type": "Trade",
"exec_qty": 4080,
"exec_fee": 0.02083248,
"exec_value": 34.7208,
"leaves_qty": 0,
"closed_size": 4080,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247716,
"trade_time_ms": 1652247716716
},
{
"order_id": "00d749f9-82b1-4e18-ae55-968a0715ab56",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "6e6d2e31-9d24-5feb-b9c6-0d976625b71b",
"price": 0.00807,
"order_price": 0.00807,
"order_qty": 10,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.0085,
"exec_type": "Trade",
"exec_qty": 10,
"exec_fee": 5.1E-05,
"exec_value": 0.085,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247711,
"trade_time_ms": 1652247711815
},
{
"order_id": "ada2fd10-db3b-4809-8e47-43de5f39370e",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "b43c7626-0bc5-5432-bea2-3496f95c2388",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 10,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 10,
"exec_fee": 5.094E-05,
"exec_value": 0.0849,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247705,
"trade_time_ms": 1652247705546
},
{
"order_id": "8023c368-956f-41ee-9ef8-299d42815783",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "a11c1c4f-a1c3-5dc0-9419-0428f6c6853c",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 10,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 10,
"exec_fee": 5.094E-05,
"exec_value": 0.0849,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247699,
"trade_time_ms": 1652247699197
},
{
"order_id": "280f7faf-041a-4e47-a932-66968ac62e30",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "75c98ec3-4970-5e4e-b80e-472c96bc7657",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 10,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 10,
"exec_fee": 5.094E-05,
"exec_value": 0.0849,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247692,
"trade_time_ms": 1652247692967
},
{
"order_id": "382a6d66-9bd4-492b-89d3-79d5a008b3ee",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "a7a2af35-6da0-5103-8fc7-81db766e2388",
"price": 0.00805,
"order_price": 0.00805,
"order_qty": 10,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 10,
"exec_fee": 5.094E-05,
"exec_value": 0.0849,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247686,
"trade_time_ms": 1652247686688
},
{
"order_id": "11ff4b3e-e659-4ef0-adc1-6c57f558b532",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "da2d8447-1a61-5f23-abea-0cd397c765fe",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 10,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00848,
"exec_type": "Trade",
"exec_qty": 10,
"exec_fee": 5.088E-05,
"exec_value": 0.0848,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247680,
"trade_time_ms": 1652247680433
},
{
"order_id": "319573bf-46b8-44e4-8457-febbb46b32b2",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "eec2a817-f309-5220-bf53-a38c221efdda",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 10,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00848,
"exec_type": "Trade",
"exec_qty": 10,
"exec_fee": 5.088E-05,
"exec_value": 0.0848,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247674,
"trade_time_ms": 1652247674072
},
{
"order_id": "92ec6efe-d74f-4b99-a64a-b171885ed43e",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "14598aca-d7c2-57f3-988c-42be2d787f20",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 20,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 20,
"exec_fee": 0.00010188,
"exec_value": 0.1698,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247667,
"trade_time_ms": 1652247667724
},
{
"order_id": "c065d797-c7b6-46e3-86d6-80116a94969d",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "458dee9f-92b7-5e24-81dd-14bc7a5530eb",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 20,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 20,
"exec_fee": 0.00010188,
"exec_value": 0.1698,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247661,
"trade_time_ms": 1652247661442
},
{
"order_id": "ff7c682b-6dd9-4e7e-b1fa-8c5ecfe31a7f",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "8a742877-3828-5356-b387-af07e82a912c",
"price": 0.00805,
"order_price": 0.00805,
"order_qty": 20,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00848,
"exec_type": "Trade",
"exec_qty": 20,
"exec_fee": 0.00010176,
"exec_value": 0.1696,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247655,
"trade_time_ms": 1652247655083
},
{
"order_id": "87e1de31-f802-4947-b330-e65c90d99726",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "7edcdd01-ba1f-52f9-b1b0-ee36a6a1a90f",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 20,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00848,
"exec_type": "Trade",
"exec_qty": 20,
"exec_fee": 0.00010176,
"exec_value": 0.1696,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247648,
"trade_time_ms": 1652247648724
},
{
"order_id": "d3e4146d-8eb4-4a62-8ff9-0f1b3b39e8b4",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "4c3907d7-36c4-5c05-898c-da18b9bf37e8",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 20,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 20,
"exec_fee": 0.00010188,
"exec_value": 0.1698,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247642,
"trade_time_ms": 1652247642508
},
{
"order_id": "9ecb8314-fee6-4113-bd21-cc8447735a5a",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "06c55ab3-a115-539e-8bf1-a64dc36cfa9f",
"price": 0.00807,
"order_price": 0.00807,
"order_qty": 30,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 30,
"exec_fee": 0.00015282,
"exec_value": 0.2547,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247636,
"trade_time_ms": 1652247636198
},
{
"order_id": "211d5c64-8ef2-45b2-9673-78e77db765b0",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "4f6127a7-9cc2-533f-b8cd-8557147c3cd0",
"price": 0.00805,
"order_price": 0.00805,
"order_qty": 30,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00848,
"exec_type": "Trade",
"exec_qty": 30,
"exec_fee": 0.00015264,
"exec_value": 0.2544,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247629,
"trade_time_ms": 1652247629964
},
{
"order_id": "7a0ae1ab-2c41-4159-a5ed-3e9b656743da",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "af2ddbf3-8500-5426-84d3-f32d78419121",
"price": 0.00808,
"order_price": 0.00808,
"order_qty": 30,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00851,
"exec_type": "Trade",
"exec_qty": 30,
"exec_fee": 0.00015318,
"exec_value": 0.2553,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247623,
"trade_time_ms": 1652247623716
},
{
"order_id": "4dc6ff6c-a662-4d53-9e70-8cf5e177c32b",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "9a8dbeb2-81fe-5bd3-b8a2-cfc24a194ebb",
"price": 0.00808,
"order_price": 0.00808,
"order_qty": 40,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00851,
"exec_type": "Trade",
"exec_qty": 40,
"exec_fee": 0.00020424,
"exec_value": 0.3404,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247617,
"trade_time_ms": 1652247617414
},
{
"order_id": "243f1957-f127-49d7-87ff-62f8ce882cf3",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "cbbcf94c-b4b7-55b2-800d-d1ad5b175e65",
"price": 0.0081,
"order_price": 0.0081,
"order_qty": 40,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00852,
"exec_type": "Trade",
"exec_qty": 40,
"exec_fee": 0.00020448,
"exec_value": 0.3408,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247611,
"trade_time_ms": 1652247611031
},
{
"order_id": "95a2a92c-0de9-4276-93af-ecd4c30f6d77",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "656718c1-1031-551b-b3a6-7a7e43ceea58",
"price": 0.00809,
"order_price": 0.00809,
"order_qty": 40,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00851,
"exec_type": "Trade",
"exec_qty": 40,
"exec_fee": 0.00020424,
"exec_value": 0.3404,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247604,
"trade_time_ms": 1652247604726
},
{
"order_id": "044348ca-0c91-4dc0-8222-0f7fa63ae757",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "e959cd1c-2cd5-5cff-8812-4258d8a8fc13",
"price": 0.00809,
"order_price": 0.00809,
"order_qty": 50,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00851,
"exec_type": "Trade",
"exec_qty": 50,
"exec_fee": 0.0002553,
"exec_value": 0.4255,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247598,
"trade_time_ms": 1652247598475
},
{
"order_id": "68f67bca-e3a6-487b-a4d0-0ac2e7975f60",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "e2cf419f-9ee9-512c-875f-9ed62d90c333",
"price": 0.00807,
"order_price": 0.00807,
"order_qty": 60,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 60,
"exec_fee": 0.00030564,
"exec_value": 0.5094,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247591,
"trade_time_ms": 1652247591998
},
{
"order_id": "54794915-27b9-405b-9000-434a3e18010d",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "deee175b-202f-5b52-8897-cddac9a8a5d1",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 60,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 60,
"exec_fee": 0.00030564,
"exec_value": 0.5094,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247585,
"trade_time_ms": 1652247585675
},
{
"order_id": "b4725338-e0e8-4a71-a489-07c46058eda2",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "411aa17d-eb36-5ebb-b976-871d76fadf8b",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 70,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 70,
"exec_fee": 0.00035658,
"exec_value": 0.5943,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247579,
"trade_time_ms": 1652247579465
},
{
"order_id": "7284f53e-78b2-4149-b994-ac949de415b1",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "403eedb5-c61f-52bf-970e-f9bb78977315",
"price": 0.00807,
"order_price": 0.00807,
"order_qty": 80,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 80,
"exec_fee": 0.00040752,
"exec_value": 0.6792,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247573,
"trade_time_ms": 1652247573258
},
{
"order_id": "0459fd1d-413e-4068-a083-499f90278790",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "c0f5dc55-086c-54d0-b201-3462ab604af6",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 80,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 80,
"exec_fee": 0.00040752,
"exec_value": 0.6792,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247566,
"trade_time_ms": 1652247566899
},
{
"order_id": "ec55e01a-387e-4570-a576-1225aa917aad",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "7e99d2f2-effd-523d-ab04-77e883239e9e",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 90,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 90,
"exec_fee": 0.00045846,
"exec_value": 0.7641,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247560,
"trade_time_ms": 1652247560648
},
{
"order_id": "34c649c2-21d0-4089-9018-f5c058b62967",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "79fb55e1-9dab-535e-8443-b857b1530d27",
"price": 0.00806,
"order_price": 0.00806,
"order_qty": 100,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 100,
"exec_fee": 0.0005094,
"exec_value": 0.849,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247554,
"trade_time_ms": 1652247554308
},
{
"order_id": "055eabc7-6e9b-4461-91e0-2808fc724a92",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "af72c249-a8ff-521a-aeca-5d13a0aa8ded",
"price": 0.00807,
"order_price": 0.00807,
"order_qty": 120,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 120,
"exec_fee": 0.00061128,
"exec_value": 1.0188,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247548,
"trade_time_ms": 1652247548001
},
{
"order_id": "2e450222-1a13-490d-953a-5e928f8218b0",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "c84f4e11-9bba-53b2-90e5-106fcd03df15",
"price": 0.00807,
"order_price": 0.00807,
"order_qty": 130,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.0085,
"exec_type": "Trade",
"exec_qty": 130,
"exec_fee": 0.000663,
"exec_value": 1.105,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247541,
"trade_time_ms": 1652247541699
},
{
"order_id": "9dbadad8-e139-417c-9f77-4fe7e809a74c",
"order_link_id": "",
"side": "Sell",
"symbol": "SLPUSDT",
"exec_id": "174e651d-bdbe-5575-a9c3-6b5f04564ea9",
"price": 0.00807,
"order_price": 0.00807,
"order_qty": 140,
"order_type": "Market",
"fee_rate": 0.0006,
"exec_price": 0.00849,
"exec_type": "Trade",
"exec_qty": 140,
"exec_fee": 0.00071316,
"exec_value": 1.1886,
"leaves_qty": 0,
"closed_size": 0,
"last_liquidity_ind": "RemovedLiquidity",
"trade_time": 1652247535,
"trade_time_ms": 1652247535086
}
]
},
"time_now": "1652257599.243318",
"rate_limit_status": 118,
"rate_limit_reset_ms": 1652257599237,
"rate_limit": 120
}

UsdPerpetualApi.Trading.PlaceOrderAsync Error

When I excute PlaceOrderAsync(), the following error occurs.

invalid request, please check your timestamp and recv_window param. req_timestamp: 1656380988818 server_timestamp: 1656380994889 recv_window: 5000

To solve this, change th recv_window parameter to 6000, the order request will be delayed by 6 seconds.

How to wolve this problem?

UsdPerpetualApi.Account.GetPositionAsync always returns 2 positions

using UsdPerpetualApi.Account.GetPositionAsync always returns 2 positions even tho I have closed all the positions from both api and the website

2022/05/18 04:37:52:191 | Information | Bybit | [14] Creating request for https://api.bytick.com/private/linear/order/cancel-all
2022/05/18 04:37:52:193 | Trace | Bybit | [14] Sending POST signed request to https://api.bytick.com/private/linear/order/cancel-all with request body 'api_key=oItbqDLH4CW8nyYeER&recv_window=10000&symbol=GMTUSDT&timestamp=1652832472193&sign=C6677AD6FFB0BCF6A870357629F162BA933E02904B8217471E5D4B7C1C590FE5' with headers Accept=[application/json], x-referer=[JKorf]
2022/05/18 04:37:52:822 | Debug | Bybit | [14] Response received in 459ms: {"ret_code":0,"ret_msg":"OK","ext_code":"","ext_info":"","result":null,"time_now":"1652832474.491359","rate_limit_status":90,"rate_limit_reset_ms":1652832474489,"rate_limit":100}
2022/05/18 04:37:52:837 | Information | Bybit | [17] Creating request for https://api.bytick.com/private/linear/position/list
2022/05/18 04:37:52:838 | Trace | Bybit | [17] Sending GET signed request to https://api.bytick.com/private/linear/position/list?api_key=oItbqDLH4CW8nyYeER&recv_window=10000&symbol=GMTUSDT&timestamp=1652832472838&sign=D49208FB45924205109BF071A867C3F787CD325A42EBF53E7BB25065EEBB2C79 with headers Accept=[application/json], x-referer=[JKorf]
2022/05/18 04:37:53:158 | Debug | Bybit | [17] Response received in 317ms: {"ret_code":0,"ret_msg":"OK","ext_code":"","ext_info":"","result":[{"user_id":24638417,"symbol":"GMTUSDT","side":"Buy","size":0,"position_value":0,"entry_price":0,"liq_price":0,"bust_price":0,"leverage":10,"auto_add_margin":0,"is_isolated":true,"position_margin":0,"occ_closing_fee":0,"realised_pnl":0,"cum_realised_pnl":-1.3423082,"free_qty":0,"tp_sl_mode":"Full","unrealised_pnl":0,"deleverage_indicator":0,"risk_id":1,"stop_loss":0,"take_profit":0,"trailing_stop":0,"position_idx":1,"mode":"BothSide"},{"user_id":24638417,"symbol":"GMTUSDT","side":"Sell","size":0,"position_value":0,"entry_price":0,"liq_price":0,"bust_price":0,"leverage":10,"auto_add_margin":0,"is_isolated":true,"position_margin":0,"occ_closing_fee":0,"realised_pnl":0,"cum_realised_pnl":-0.23675725,"free_qty":0,"tp_sl_mode":"Full","unrealised_pnl":0,"deleverage_indicator":0,"risk_id":1,"stop_loss":0,"take_profit":0,"trailing_stop":0,"position_idx":2,"mode":"BothSide"}],"time_now":"1652832474.978014","rate_limit_status":119,"rate_limit_reset_ms":1652832474974,"rate_limit":120}

Wrong PropertyNames in BybitOrderUpdate

ETHUSDT perp contract. Base asset is ETH, quote asset is USDT
I placed order and reseive this order state
..."symbol":"ETHUSDT","side":"Buy","order_type":"Limit","price":2606.45,"qty":0.01,"leaves_qty":0,"last_exec_price":2606.45,"cum_exec_qty":0.01,"cum_exec_value":26.064499,"cum_exec_fee":-0.00651612,"time_in_force":"GoodTillCancel","create_type":"CreateByUser","cancel_type":"UNKNOWN","order_status":"Filled"...

"cum_exec_value":26.064499," - USDT value or order (quote)
"cum_exec_qty":0.01 - ETH value of order (base)

But in code this Properties is mixed up

   /// <summary>
  /// Quote quantity filled
  /// </summary>
  [JsonProperty("cum_exec_qty")]
  public decimal QuoteQuantityFilled { get; set; }
  /// <summary>
  /// Base quantity filled
  /// </summary>
  [JsonProperty("cum_exec_value")]
  public decimal BaseQuantityFilled { get; set; }

Wrong sort direction of Spot OrderBook entries

Example of ETHUSDT orderbook
Wrong Top prices

Ask quantity Ask price | Bid price Bid quantity
[ 0.0056] 2630.25 | 2651.4 [0.06808 ]
[ 2.04] 2631.34 | 2650 [0.05759 ]
[ 7.74686] 2631.36 | 2648.61 [2.04 ]

Deserialize JsonSerializationException: Cannot deserialize the current JSON object

Hello,
By giving symbol parameter via InversePerpetualApi, a JsonSerialize error is received for which position information is requested. However, when the symbol parameter is not given, the query works properly.

The code block below throws an error:
var positionResult = await client.InversePerpetualApi.Account.GetPositionsAsync("BITUSD").ConfigureAwait(false);

The code block below is working correctly:
var positionResult = await client.InversePerpetualApi.Account.GetPositionsAsync().ConfigureAwait(false);

Error details:

Version: 0.0.1-beta7

Deserialize JsonSerializationException: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.Generic.IEnumerable`1[Bybit.Net.Objects.Internal.BybitPositionData]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.
Path 'result.id', line 1, position 72.

api copytading

Hi Mr. Jan Korf @JKorf - Thank you very much for this excellent DLL - Please add api copytrading to it - Good luck

How can use it in testnet? thx

Hi, I would like to point to Testnet.. how can I do it?
like in Binance.Net I can use -> BinanceClient.SetDefaultOptions(new BinanceClientOptions(BinanceApiAddresses.TestNet ) . Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.