Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Jun 10, 2024
1 parent 4e01181 commit 4ffff8f
Show file tree
Hide file tree
Showing 844 changed files with 138,036 additions and 3 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: JKorf
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
What endpoints and subscriptions are called.

**Expected behavior**
A clear and concise description of what you expected to happen.

**Debug logging**
Add debug logging related to the issue. Enable Debug logging in the client options by settings LogLevel to Debug.
25 changes: 25 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: .NET

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
31 changes: 31 additions & 0 deletions Examples/Examples.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32002.185
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TODO.Examples.Api", "TODO.Api\TODO.Examples.Api.csproj", "{8D7694ED-912A-4F92-B924-CFD107EB20CA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TODO.Examples.Console", "TODO.Console\TODO.Examples.Console.csproj", "{5B869493-8271-45C5-93AE-5357B45FE005}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8D7694ED-912A-4F92-B924-CFD107EB20CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D7694ED-912A-4F92-B924-CFD107EB20CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D7694ED-912A-4F92-B924-CFD107EB20CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D7694ED-912A-4F92-B924-CFD107EB20CA}.Release|Any CPU.Build.0 = Release|Any CPU
{5B869493-8271-45C5-93AE-5357B45FE005}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B869493-8271-45C5-93AE-5357B45FE005}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B869493-8271-45C5-93AE-5357B45FE005}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B869493-8271-45C5-93AE-5357B45FE005}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0FC03929-769B-4314-AF91-AF01E06278DD}
EndGlobalSection
EndGlobal
7 changes: 7 additions & 0 deletions Examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Examples

### TODO.Examples.Api
A minimal API showing how to integrate TODO.Net in a web API project

### TODO.Examples.Console
A simple console client demonstrating basic usage
44 changes: 44 additions & 0 deletions Examples/TODO.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Microsoft.AspNetCore.Mvc;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

// Add the TODO services
builder.Services.AddTODO();

// OR to provide API credentials for accessing private endpoints, or setting other options:
/*
builder.Services.AddTODO(restOptions =>
{
restOptions.ApiCredentials = new ApiCredentials("<APIKEY>", "<APISECRET>");
restOptions.RequestTimeout = TimeSpan.FromSeconds(5);
}, socketOptions =>
{
socketOptions.ApiCredentials = new ApiCredentials("<APIKEY>", "<APISECRET>");
});
*/

var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
app.UseHttpsRedirection();

// Map the endpoint and inject the rest client
app.MapGet("/{Symbol}", async ([FromServices] ITODORestClient client, string symbol) =>
{
var result = await client.SpotApi.ExchangeData.GetSpotTickersAsync(symbol);
return result.Data.List.First().LastPrice;
})
.WithOpenApi();


app.MapGet("/Balances", async ([FromServices] ITODORestClient client) =>
{
var result = await client.SpotApi.Account.GetBalancesAsync();
return (object)(result.Success ? result.Data : result.Error!);
})
.WithOpenApi();

app.Run();
41 changes: 41 additions & 0 deletions Examples/TODO.Api/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:23442",
"sslPort": 44376
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "http://localhost:5114",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "swagger",
"applicationUrl": "https://localhost:7266;http://localhost:5114",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
16 changes: 16 additions & 0 deletions Examples/TODO.Api/TODO.Examples.Api.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="TODO.Net" Version="3.5.2" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions Examples/TODO.Api/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}
9 changes: 9 additions & 0 deletions Examples/TODO.Api/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
20 changes: 20 additions & 0 deletions Examples/TODO.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

using TODO.Net.Clients;

// REST
var restClient = new TODORestClient();
var ticker = await restClient.V5Api.ExchangeData.GetSpotTickersAsync("ETHUSDT");
Console.WriteLine($"Rest client ticker price for ETHUSDT: {ticker.Data.List.First().LastPrice}");

Console.WriteLine();
Console.WriteLine("Press enter to start websocket subscription");
Console.ReadLine();

// Websocket
var socketClient = new TODOSocketClient();
var subscription = await socketClient.V5SpotApi.SubscribeToTickerUpdatesAsync("ETHUSDT", update =>
{
Console.WriteLine($"Websocket client ticker price for ETHUSDT: {update.Data.LastPrice}");
});

Console.ReadLine();
14 changes: 14 additions & 0 deletions Examples/TODO.Console/TODO.Examples.Console.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="TODO.Net" Version="3.5.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
GET
/api/v4/futures/usdt/accounts
true
{
"user": 1666,
"currency": "USDT",
"total": "9707.803567115145",
"unrealised_pnl": "3371.248828",
"position_margin": "38.712189181",
"order_margin": "0",
"available": "9669.091377934145",
"point": "0",
"bonus": "0",
"in_dual_mode": false,
"enable_evolved_classic": false,
"history": {
"dnw": "10000",
"pnl": "68.3685",
"fee": "-1.645812875",
"refr": "0",
"fund": "-358.919120009855",
"point_dnw": "0",
"point_fee": "0",
"point_refr": "0",
"bonus_dnw": "0",
"bonus_offset": "0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
GET
/api/v4/futures/usdt/account_book
true
[
{
"time": 1682294400.123456,
"change": "0.000010152188",
"balance": "4.59316525194",
"text": "ETH_USD:6086261",
"type": "fee",
"contract": "ETH_USD",
"trade_id": "1"
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
GET
/api/v4/futures/usdt/fee
true
{
"1INCH_USDT": {
"taker_fee": "0.00025",
"maker_fee": "-0.00010"
},
"AAVE_USDT": {
"taker_fee": "0.00025",
"maker_fee": "-0.00010"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
POST
/api/v4/futures/usdt/dual_mode
true
{
"user": 1666,
"currency": "USDT",
"total": "9707.803567115145",
"unrealised_pnl": "3371.248828",
"position_margin": "38.712189181",
"order_margin": "0",
"available": "9669.091377934145",
"point": "0",
"bonus": "0",
"in_dual_mode": false,
"enable_evolved_classic": false,
"history": {
"dnw": "10000",
"pnl": "68.3685",
"fee": "-1.645812875",
"refr": "0",
"fund": "-358.919120009855",
"point_dnw": "0",
"point_fee": "0",
"point_refr": "0",
"bonus_dnw": "0",
"bonus_offset": "0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
GET
/api/v4/futures/usdt/contracts/ETH_USDT
false
{
"name": "BTC_USDT",
"type": "direct",
"quanto_multiplier": "0.0001",
"ref_discount_rate": "0",
"order_price_deviate": "0.5",
"maintenance_rate": "0.005",
"mark_type": "index",
"last_price": "38026",
"mark_price": "37985.6",
"index_price": "37954.92",
"funding_rate_indicative": "0.000219",
"mark_price_round": "0.01",
"funding_offset": 0,
"in_delisting": false,
"risk_limit_base": "1000000",
"interest_rate": "0.0003",
"order_price_round": "0.1",
"order_size_min": 1,
"ref_rebate_rate": "0.2",
"funding_interval": 28800,
"risk_limit_step": "1000000",
"leverage_min": "1",
"leverage_max": "100",
"risk_limit_max": "8000000",
"maker_fee_rate": "-0.00025",
"taker_fee_rate": "0.00075",
"funding_rate": "0.002053",
"order_size_max": 1000000,
"funding_next_apply": 1610035200,
"short_users": 977,
"config_change_time": 1609899548,
"trade_size": 28530850594,
"position_size": 5223816,
"long_users": 455,
"funding_impact_value": "60000",
"orders_limit": 50,
"trade_id": 10851092,
"orderbook_id": 2129638396,
"enable_bonus": true,
"enable_credit": true,
"create_time": 1669688556,
"funding_cap_ratio": "0.75"
}
Loading

0 comments on commit 4ffff8f

Please sign in to comment.