coin_alerts/Brian.cs

83 lines
2.3 KiB
C#

using BinanceExchange.API.Client;
using BinanceExchange.API.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SignalsTest
{
public class Brian
{
private static BinanceClient m_client;
public static BinanceClient Client
{
get
{
if (m_client == null)
{
m_client = new BinanceClient(new ClientConfiguration()
{
ApiKey = Secrets.BINANCE_API_PK,
SecretKey = Secrets.BINANCE_API_SK,
});
}
return m_client;
}
}
public static List<CoinWatch> watches = new List<CoinWatch>();
public static CoinWatch GetCoinWatch(string symbol, KlineInterval interval){
foreach(CoinWatch watch in watches){
if(watch.pair == symbol && watch.interval == interval){
return watch;
}
}
return watches[0];
}
public static CoinWatch GetCoinWatchLongest(string symbol){
CoinWatch match = watches[0];
foreach(CoinWatch watch in watches){
if(watch.pair == symbol){
if(match.pair != watch.pair){
match = watch;
}
if(Utils.GetMinutesForInterval(match.interval) < Utils.GetMinutesForInterval(watch.interval)){
match = watch;
}
}
}
return match;
}
public static List<decimal> GetCombinedResPoints(string symbol){
List<decimal> output = new List<decimal>();
foreach(CoinWatch watch in watches){
if(watch.pair == symbol){
output.AddRange(watch.resistancePoints);
}
}
return output;
}
public static List<decimal> GetCombinedSupPoints(string symbol){
List<decimal> output = new List<decimal>();
foreach(CoinWatch watch in watches){
if(watch.pair == symbol){
output.AddRange(watch.supportPoints);
}
}
return output;
}
}
}