16 changed files with 132 additions and 102 deletions
@ -1,12 +0,0 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<OutputType>Exe</OutputType> |
|||
<TargetFramework>netcoreapp3.1</TargetFramework> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Binance.Net" Version="8.0.1" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
@ -1,27 +0,0 @@ |
|||
using Binance.Net.Clients; |
|||
using Binance.Net.Objects; |
|||
using CryptoExchange.Net.Authentication; |
|||
using System; |
|||
|
|||
namespace Binance.SDK.Test |
|||
{ |
|||
internal class Program |
|||
{ |
|||
static void Main(string[] args) |
|||
{ |
|||
var apiKey = "muiZ1IA2sPMQ2m0YFPubEvZepjzn2nxeuPHqQ6mejKVXljYDQTOIYbm22NlXxKcv"; |
|||
var apiSecret = "3Clur3D1hDeZYhtVSJzPBiEBb7S0ktC8WpaRQ3F7ysQe55kbsPTBZ6U4X9XsX4Ww"; |
|||
var client = new BinanceClient(new BinanceClientOptions() |
|||
{ |
|||
UsdFuturesApiOptions = new BinanceApiClientOptions() |
|||
{ |
|||
BaseAddress = "https://fapi.binance.com", |
|||
ApiCredentials = new ApiCredentials(apiKey, apiSecret) |
|||
} |
|||
}); |
|||
|
|||
var result = client.UsdFuturesApi.Account.GetBalancesAsync().Result; |
|||
Console.WriteLine(result); |
|||
} |
|||
} |
|||
} |
@ -1,14 +0,0 @@ |
|||
using Binance.Net.Clients; |
|||
using Binance.Net.Objects; |
|||
using CryptoExchange.Net.Authentication; |
|||
|
|||
namespace Binance.SDK |
|||
{ |
|||
public class BinanceContractTest |
|||
{ |
|||
public BinanceContractTest() |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,14 @@ |
|||
using Binance.TradeRobot.Common.DI; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
|
|||
namespace Binance.TradeRobot.Business |
|||
{ |
|||
[BatchRegistration(ServiceLifetime.Singleton, RegistrationType.Self)] |
|||
public class GlobalContext |
|||
{ |
|||
public GlobalContext() |
|||
{ |
|||
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,57 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Text; |
|||
|
|||
namespace SDKAdapter.WebSockets.Market |
|||
{ |
|||
public class SpotMarketWebSocketClient |
|||
{ |
|||
/// <summary>
|
|||
/// 更新间隔(ms)
|
|||
/// </summary>
|
|||
protected int updateInterval = 3000; |
|||
|
|||
/// <summary>
|
|||
/// 交易对
|
|||
/// </summary>
|
|||
public string Symbol { get; private set; } |
|||
|
|||
/// <summary>
|
|||
/// 最新成交价
|
|||
/// </summary>
|
|||
public decimal NewestPrice { get; private set; } |
|||
|
|||
/// <summary>r
|
|||
/// 上一次价格更新时间
|
|||
/// </summary>
|
|||
public DateTime? LastUpdateTime { get; private set; } |
|||
|
|||
public NLog.ILogger logger { get; private set; } |
|||
|
|||
public SpotMarketWebSocketClient(string symbol, NLog.ILogger logger) |
|||
{ |
|||
this.Symbol = symbol; |
|||
this.logger = logger; |
|||
} |
|||
|
|||
public virtual void Start() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public virtual void Stop() |
|||
{ |
|||
|
|||
} |
|||
|
|||
protected virtual void OnReceived(decimal newestPrice) |
|||
{ |
|||
NewestPrice = newestPrice; |
|||
if (LastUpdateTime == null || (DateTime.Now - LastUpdateTime.Value).TotalMilliseconds >= updateInterval) |
|||
{ |
|||
logger.Info($"NewestPrice:{newestPrice}"); |
|||
LastUpdateTime = DateTime.Now; |
|||
} |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue