Skip to content

Commit 52a411f

Browse files
authored
More command line options for testing (#658)
* [Binance] sapi endpoint, cleanup * [Binance] refactor namespaces * [Binance] OnGetCurrenciesAsync * DepositAddress + Withdraw option for testing
1 parent 0443882 commit 52a411f

File tree

6 files changed

+101
-1
lines changed

6 files changed

+101
-1
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using CommandLine;
2+
using ExchangeSharpConsole.Options.Interfaces;
3+
using System;
4+
using System.Threading.Tasks;
5+
6+
namespace ExchangeSharpConsole.Options
7+
{
8+
[Verb("deposit-address", HelpText = "Get a deposit address for given currency")]
9+
public class DepositAddressOption : BaseOption, IOptionPerExchange, IOptionWithCurrency
10+
{
11+
public string ExchangeName { get; set; }
12+
13+
public string Currency { get; set; }
14+
15+
public override async Task RunCommand()
16+
{
17+
using var api = GetExchangeInstance(ExchangeName);
18+
19+
Authenticate(api);
20+
21+
var address = await api.GetDepositAddressAsync(Currency);
22+
23+
Console.WriteLine($"Address: {address}");
24+
}
25+
}
26+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using CommandLine;
2+
3+
namespace ExchangeSharpConsole.Options.Interfaces
4+
{
5+
public interface IOptionWithAddress
6+
{
7+
[Option('d', "address", Required = true, HelpText = "Crypto address")]
8+
string Address { get; set; }
9+
10+
[Option('t', "address-tag", Required = false, HelpText = "Tag describing the address")]
11+
string Tag { get; set; }
12+
}
13+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using CommandLine;
2+
3+
namespace ExchangeSharpConsole.Options.Interfaces
4+
{
5+
public interface IOptionWithCurrencyAmount : IOptionWithCurrency
6+
{
7+
[Option('a', "amount", Required = true, HelpText = "Amount of the currency.")]
8+
decimal Amount { get; set; }
9+
}
10+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using CommandLine;
2+
3+
namespace ExchangeSharpConsole.Options.Interfaces
4+
{
5+
public interface IOptionWithCurrency
6+
{
7+
[Option('c', "currency", Required = true, HelpText = "Currency, e.g. BTC.")]
8+
string Currency { get; set; }
9+
}
10+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using CommandLine;
2+
using ExchangeSharp;
3+
using ExchangeSharpConsole.Options.Interfaces;
4+
using System;
5+
using System.Threading.Tasks;
6+
7+
namespace ExchangeSharpConsole.Options
8+
{
9+
[Verb("withdraw", HelpText = "Withdraw given amount in given currency to target address")]
10+
public class WithdrawOption : BaseOption, IOptionPerExchange, IOptionWithAddress, IOptionWithCurrencyAmount
11+
{
12+
public string ExchangeName { get; set; }
13+
14+
public string Address { get; set; }
15+
16+
public string Tag { get; set; }
17+
18+
public decimal Amount { get; set; }
19+
20+
public string Currency { get; set; }
21+
22+
public override async Task RunCommand()
23+
{
24+
using var api = GetExchangeInstance(ExchangeName);
25+
26+
Authenticate(api);
27+
28+
var result = await api.WithdrawAsync(new ExchangeWithdrawalRequest
29+
{
30+
Address = Address,
31+
AddressTag = Tag,
32+
Amount = Amount,
33+
Currency = Currency
34+
});
35+
36+
Console.WriteLine($"Withdrawal successful: {result.Success}, id: {result.Id}, optional message: {result.Message}");
37+
}
38+
}
39+
}

src/ExchangeSharpConsole/Program.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public partial class Program
1818
typeof(CancelOrderOption),
1919
typeof(CandlesOption),
2020
typeof(ConvertOption),
21+
typeof(DepositAddressOption),
2122
typeof(CurrenciesOption),
2223
typeof(ExampleOption),
2324
typeof(ExportOption),
@@ -38,7 +39,8 @@ public partial class Program
3839
typeof(WebSocketsPositionsOption),
3940
typeof(WebSocketsTickersOption),
4041
typeof(WebSocketsTradesOption),
41-
typeof(WebSocketsCandlesOption)
42+
typeof(WebSocketsCandlesOption),
43+
typeof(WithdrawOption)
4244
};
4345

4446
public Program()

0 commit comments

Comments
 (0)