Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 23 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
- [Usage](#usage)
- [Contact](#contact)
- [Contributors](#contributors)
- [Donations](#donations)

## About
**Bybit.Net.Api** offers an official, powerful, and efficient .NET connector to the [Bybit public Trading API](https://bybit-exchange.github.io/docs/v5/intro)
Expand Down Expand Up @@ -59,8 +58,8 @@ Furthermore methods to install pakcage, please check [Nuget Repository](https://
- Base URL Setting: Allows setting to testnet or mainnet. by default [HTTP_MAINNET_URL](https://api.bybit.com)
- Trade API: For create/amend/cancel single & batch orders, now supports dedicated class, dictionary.
- Asset API: Deposit and withdrawal operations will automatically generate a transfer ID.
- Account API : Add new function Set Spot Hedging
- Position API : Add new function Confirm New Risk Limit
- Account API: Add new function Set Spot Hedging
- Position API: Add new function Confirm New Risk Limit

### WebSocket
- Ping Pong Interval Parameter: Added by default (20 seconds).
Expand Down Expand Up @@ -89,7 +88,7 @@ var orderInfo = await tradeService.PlaceOrder(category: Category.LINEAR, symbol:
Console.WriteLine(orderInfo);
```

- Place Bacth Order by Dictionary
- Place Batch Order by Dictionary
```DotNet
Dictionary<string, object> dict1 = new() { { "symbol", "XRPUSDT" }, { "orderType", "Limit" }, { "side", "Buy" }, { "qty", "10" }, { "price", "0.6080" }, { "timeInForce", "GTC" } };
Dictionary<string, object> dict2 = new() { { "symbol", "BLZUSDT" }, { "orderType", "Limit" }, { "side", "Buy" }, { "qty", "10" }, { "price", "0.6080" }, { "timeInForce", "GTC" } };
Expand All @@ -98,7 +97,7 @@ var orderInfoString = await TradeService.PlaceBatchOrder(category: Category.LINE
Console.WriteLine(orderInfoString);
```

- Place Bacth Order by dedicated OrderRequest Class
- Place Batch Order by dedicated OrderRequest Class
```DotNet
var order1 = new OrderRequest { Symbol = "XRPUSDT", OrderType = OrderType.LIMIT.Value, Side = Side.BUY.Value, Qty = "10", Price = "0.6080", TimeInForce = TimeInForce.GTC.Value };
var order2 = new OrderRequest { Symbol = "BLZUSDT", OrderType = OrderType.LIMIT.Value, Side = Side.BUY.Value, Qty = "10", Price = "0.6080", TimeInForce = TimeInForce.GTC.Value };
Expand All @@ -120,7 +119,7 @@ var positionInfo = await positionService.GetPositionInfo(category: Category.LINE
Console.WriteLine(positionInfo);
```

### Websocket public channel
### WebSocket public channel
- Trade Subscribe
```DotNet
var linearWebsocket = new BybitLinearWebSocket(useTestNet: true, pingIntevral: 5);
Expand All @@ -133,10 +132,10 @@ linearWebsocket.OnMessageReceived(
await linearWebsocket.ConnectAsync(new string[] { "publicTrade.BTCUSDT" }, CancellationToken.None);
```

### Websocket private channel
### WebSocket private channel
- Order Subscribe
```DotNet
var privateWebsocket = new(apiKey: "xxxxxxxxxxx", apiSecret: "xxxxxxxxxxxxxxx", useTestNet: true, pingIntevral: 5, maxAliveTime:"120s");
var privateWebsocket = new BybitPrivateWebsocket(apiKey: "xxxxxxxxxxx", apiSecret: "xxxxxxxxxxxxxxx", useTestNet: true, pingIntevral: 5, maxAliveTime:"120s");
Copy link

Copilot AI Oct 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'pingIntevral' to 'pingInterval'.

Copilot uses AI. Check for mistakes.
privateWebsocket.OnMessageReceived(
(data) =>
{
Expand All @@ -154,20 +153,28 @@ List of other contributors
<table>
<tr>
<td align="center">
<a href="https://github.com/wuhewuhe">
<a href="https://github.com/VictorFrWu">
<img src="https://avatars.githubusercontent.com/u/32245754?v=4" width="100px;" alt=""/>
<br />
<sub>
<b>Victor</b>
</sub>
</a>
<br />
<a href="https://github.com/wuhewuhe/bybit.net.api/commits?author=wuhewuhe" title="Code">💻</a>
<a href="https://github.com/wuhewuhe/bybit.net.api/commits?author=wuhewuhe" title="Documentation">📖</a>
<a href="https://github.com/VictorFrWu/bybit.net.api/commits?author=VictorFrWu" title="Code">💻</a>
<a href="https://github.com/VictorFrWu/bybit.net.api/commits?author=VictorFrWu" title="Documentation">📖</a>
</td>
<td align="center">
<a href="https://github.com/kolya5544">
<img src="https://avatars.githubusercontent.com/u/20096248?v=4" width="100px;" alt=""/>
<br />
<sub>
<b>Kolya</b>
</sub>
</a>
<br />
<a href="https://github.com/VictorFrWu/bybit.net.api/commits?author=kolya5544" title="Code">💻</a>
<a href="https://github.com/VictorFrWu/bybit.net.api/commits?author=kolya5544" title="Documentation">📖</a>
</td>
</tr>
</table>

## Donations
Your donations keep our development active and our community growing. Donate USDT to our [ERC20 Wallet Address](0x238bbb45af1254e2fd76564c9b56042c452f3d6e).

</table>
42 changes: 42 additions & 0 deletions Src/Common/ApiServiceImp/BybitAccountService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,5 +435,47 @@ public BybitAccountService(HttpClient httpClient, string apiKey, string apiSecre
var result = await this.SendSignedAsync<string>(MMP_STATE, HttpMethod.Get, query: query);
return result;
}

private const string ACCOUNT_MANUAL_BORROW = "/v5/account/borrow";

/// <summary>
/// Manual Borrow — POST /v5/account/borrow
/// </summary>
public async Task<string?> ManualBorrow(string coin, string amount)
{
var body = new Dictionary<string, object>
{
{ "coin", coin },
{ "amount", amount }
};

var result = await this.SendSignedAsync<string>(
ACCOUNT_MANUAL_BORROW,
HttpMethod.Post,
query: body);

return result;
}

private const string ACCOUNT_MANUAL_REPAY = "/v5/account/repay";

/// <summary>
/// Manual Repay — POST /v5/account/repay
/// </summary>
public async Task<string?> ManualRepay(string? coin = null, string? amount = null)
{
var body = new Dictionary<string, object>();
BybitParametersUtils.AddOptionalParameters(body,
("coin", coin),
("amount", amount)
);

var result = await this.SendSignedAsync<string>(
ACCOUNT_MANUAL_REPAY,
HttpMethod.Post,
query: body);

return result;
}
}
}
2 changes: 1 addition & 1 deletion Src/Common/ApiServiceImp/BybitEarnService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace bybit.net.api.ApiServiceImp
{
internal class BybitEarnService : BybitApiService
public class BybitEarnService : BybitApiService
{
public BybitEarnService(string apiKey, string apiSecret, string? url = null, string recvWindow = BybitConstants.DEFAULT_REC_WINDOW, bool debugMode = false)
: this(httpClient: new HttpClient(), apiKey: apiKey, apiSecret: apiSecret, url: url, recvWindow: recvWindow, debugMode: debugMode)
Expand Down
2 changes: 1 addition & 1 deletion Src/Common/ApiServiceImp/BybitNewCryptoLoanService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace bybit.net.api.ApiServiceImp
{
internal class BybitNewCryptoLoanService : BybitApiService
public class BybitNewCryptoLoanService : BybitApiService
{
public BybitNewCryptoLoanService(string apiKey, string apiSecret, string? url = null, string recvWindow = BybitConstants.DEFAULT_REC_WINDOW, bool debugMode = false)
: this(httpClient: new HttpClient(), apiKey: apiKey, apiSecret: apiSecret, url: url, recvWindow: recvWindow, debugMode: debugMode)
Expand Down
2 changes: 1 addition & 1 deletion Src/Common/ApiServiceImp/BybitP2PService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace bybit.net.api.ApiServiceImp
{
internal class BybitP2PService : BybitApiService
public class BybitP2PService : BybitApiService
{
public BybitP2PService(string apiKey, string apiSecret, string? url = null, string recvWindow = BybitConstants.DEFAULT_REC_WINDOW, bool debugMode = false)
: this(httpClient: new HttpClient(), apiKey: apiKey, apiSecret: apiSecret, url: url, recvWindow: recvWindow, debugMode: debugMode)
Expand Down
Loading
Loading