Trading bot grain (#33)
* Trading bot Grain * Fix a bit more of the trading bot * Advance on the tradingbot grain * Fix build * Fix db script * Fix user login * Fix a bit backtest * Fix cooldown and backtest * start fixing bot start * Fix startup * Setup local db * Fix build and update candles and scenario * Add bot registry * Add reminder * Updateing the grains * fix bootstraping * Save stats on tick * Save bot data every tick * Fix serialization * fix save bot stats * Fix get candles * use dict instead of list for position * Switch hashset to dict * Fix a bit * Fix bot launch and bot view * add migrations * Remove the tolist * Add agent grain * Save agent summary * clean * Add save bot * Update get bots * Add get bots * Fix stop/restart * fix Update config * Update scanner table on new backtest saved * Fix backtestRowDetails.tsx * Fix agentIndex * Update agentIndex * Fix more things * Update user cache * Fix * Fix account load/start/restart/run
This commit is contained in:
@@ -45,7 +45,7 @@ namespace Managing.Application.Abstractions.Services
|
||||
/// <returns>The lightweight backtest results</returns>
|
||||
Task<LightBacktest> RunTradingBotBacktest(
|
||||
TradingBotConfig config,
|
||||
List<Candle> candles,
|
||||
HashSet<Candle> candles,
|
||||
User user = null,
|
||||
bool withCandles = false,
|
||||
string requestId = null,
|
||||
|
||||
@@ -45,16 +45,18 @@ public interface IExchangeService
|
||||
Task<List<Trade>> GetTrades(Account account, Ticker ticker);
|
||||
Task<bool> CancelOrder(Account account, Ticker ticker);
|
||||
decimal GetFee(Account account, bool isForPaperTrading = false);
|
||||
Candle GetCandle(Account account, Ticker ticker, DateTime date);
|
||||
Task<Candle> GetCandle(Account account, Ticker ticker, DateTime date);
|
||||
Task<decimal> GetQuantityInPosition(Account account, Ticker ticker);
|
||||
|
||||
Task<List<Candle>> GetCandlesInflux(TradingExchanges exchange, Ticker ticker, DateTime startDate,
|
||||
Timeframe timeframe);
|
||||
Task<HashSet<Candle>> GetCandlesInflux(TradingExchanges exchange, Ticker ticker, DateTime startDate,
|
||||
Timeframe timeframe, int? limit = null);
|
||||
|
||||
Task<List<Candle>> GetCandlesInflux(TradingExchanges exchange, Ticker ticker, DateTime startDate,
|
||||
Timeframe timeframe, DateTime endDate);
|
||||
Task<HashSet<Candle>> GetCandlesInflux(TradingExchanges exchange, Ticker ticker, DateTime startDate,
|
||||
Timeframe timeframe, DateTime endDate, int? limit = null);
|
||||
|
||||
Task<decimal> GetBestPrice(Account account, Ticker ticker, decimal lastPrice, decimal quantity,
|
||||
TradeDirection direction);
|
||||
|
||||
Task<decimal> GetBestPrice(Account account, Ticker ticker, decimal lastPrice, decimal quantity, TradeDirection direction);
|
||||
Orderbook GetOrderbook(Account account, Ticker ticker);
|
||||
|
||||
Trade BuildEmptyTrade(Ticker ticker, decimal price, decimal quantity, TradeDirection direction, decimal? leverage,
|
||||
|
||||
@@ -28,4 +28,6 @@ public interface IStatisticService
|
||||
Task UpdateTopVolumeTicker(Enums.TradingExchanges exchange, int top);
|
||||
Task UpdateFundingRates();
|
||||
Task<List<FundingRate>> GetFundingRates();
|
||||
Task SaveOrUpdateAgentSummary(AgentSummary agentSummary);
|
||||
Task<IEnumerable<AgentSummary>> GetAllAgentSummaries();
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Managing.Domain.Bots;
|
||||
using Managing.Domain.Indicators;
|
||||
using Managing.Domain.Synth.Models;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
@@ -94,7 +95,7 @@ public interface ISynthPredictionService
|
||||
/// <param name="botConfig">Bot configuration with Synth settings</param>
|
||||
/// <returns>Risk assessment result</returns>
|
||||
Task<SynthRiskResult> MonitorPositionRiskAsync(Ticker ticker, TradeDirection direction, decimal currentPrice,
|
||||
decimal liquidationPrice, string positionIdentifier, TradingBotConfig botConfig);
|
||||
decimal liquidationPrice, Guid positionIdentifier, TradingBotConfig botConfig);
|
||||
|
||||
/// <summary>
|
||||
/// Estimates liquidation price based on money management settings
|
||||
@@ -103,5 +104,6 @@ public interface ISynthPredictionService
|
||||
/// <param name="direction">Position direction</param>
|
||||
/// <param name="moneyManagement">Money management settings</param>
|
||||
/// <returns>Estimated liquidation price</returns>
|
||||
decimal EstimateLiquidationPrice(decimal currentPrice, TradeDirection direction, LightMoneyManagement moneyManagement);
|
||||
decimal EstimateLiquidationPrice(decimal currentPrice, TradeDirection direction,
|
||||
LightMoneyManagement moneyManagement);
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
using Managing.Domain.Accounts;
|
||||
using Managing.Domain.Bots;
|
||||
using Managing.Domain.Candles;
|
||||
using Managing.Domain.Indicators;
|
||||
using Managing.Domain.Scenarios;
|
||||
using Managing.Domain.Statistics;
|
||||
using Managing.Domain.Strategies;
|
||||
using Managing.Domain.Strategies.Base;
|
||||
using Managing.Domain.Synth.Models;
|
||||
using Managing.Domain.Trades;
|
||||
using Managing.Domain.Users;
|
||||
using Managing.Infrastructure.Evm.Models.Privy;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
@@ -17,20 +19,20 @@ public interface ITradingService
|
||||
Task<Scenario> GetScenarioByNameAsync(string scenario);
|
||||
Task InsertPositionAsync(Position position);
|
||||
Task UpdatePositionAsync(Position position);
|
||||
Task<Indicator> GetStrategyByNameAsync(string strategy);
|
||||
Task<IndicatorBase> GetIndicatorByNameAsync(string strategy);
|
||||
Task InsertScenarioAsync(Scenario scenario);
|
||||
Task InsertStrategyAsync(Indicator indicator);
|
||||
Task InsertIndicatorAsync(IndicatorBase indicatorBase);
|
||||
Task<IEnumerable<Scenario>> GetScenariosAsync();
|
||||
Task<IEnumerable<Indicator>> GetStrategiesAsync();
|
||||
Task<IEnumerable<IndicatorBase>> GetIndicatorsAsync();
|
||||
Task DeleteScenarioAsync(string name);
|
||||
Task DeleteStrategyAsync(string name);
|
||||
Task<Position> GetPositionByIdentifierAsync(string identifier);
|
||||
Task DeleteIndicatorAsync(string name);
|
||||
Task<Position> GetPositionByIdentifierAsync(Guid identifier);
|
||||
Task<Position> ManagePosition(Account account, Position position);
|
||||
|
||||
Task WatchTrader();
|
||||
Task<IEnumerable<Trader>> GetTradersWatch();
|
||||
Task UpdateScenarioAsync(Scenario scenario);
|
||||
Task UpdateStrategyAsync(Indicator indicator);
|
||||
Task UpdateIndicatorAsync(IndicatorBase indicatorBase);
|
||||
Task<IEnumerable<Position>> GetBrokerPositions(Account account);
|
||||
Task<PrivyInitAddressResponse> InitPrivyWallet(string publicAddress);
|
||||
|
||||
@@ -43,7 +45,7 @@ public interface ITradingService
|
||||
TradingBotConfig botConfig, bool isBacktest);
|
||||
|
||||
Task<SynthRiskResult> MonitorSynthPositionRiskAsync(Ticker ticker, TradeDirection direction, decimal currentPrice,
|
||||
decimal liquidationPrice, string positionIdentifier, TradingBotConfig botConfig);
|
||||
decimal liquidationPrice, Guid positionIdentifier, TradingBotConfig botConfig);
|
||||
|
||||
/// <summary>
|
||||
/// Calculates indicators values for a given scenario and candles.
|
||||
@@ -53,5 +55,8 @@ public interface ITradingService
|
||||
/// <returns>A dictionary of indicator types to their calculated values.</returns>
|
||||
Dictionary<IndicatorType, IndicatorsResultBase> CalculateIndicatorsValuesAsync(
|
||||
Scenario scenario,
|
||||
List<Candle> candles);
|
||||
HashSet<Candle> candles);
|
||||
|
||||
Task<IndicatorBase?> GetIndicatorByNameUserAsync(string name, User user);
|
||||
Task<Scenario?> GetScenarioByNameUserAsync(string scenarioName, User user);
|
||||
}
|
||||
@@ -5,9 +5,10 @@ namespace Managing.Application.Abstractions.Services;
|
||||
public interface IUserService
|
||||
{
|
||||
Task<User> Authenticate(string name, string address, string message, string signature);
|
||||
Task<User> GetUserByAddressAsync(string address);
|
||||
Task<User> GetUserByAddressAsync(string address, bool useCache = true);
|
||||
Task<User> UpdateAgentName(User user, string agentName);
|
||||
Task<User> UpdateAvatarUrl(User user, string avatarUrl);
|
||||
Task<User> UpdateTelegramChannel(User user, string telegramChannel);
|
||||
Task<User> GetUser(string name);
|
||||
Task<User> GetUserByName(string name);
|
||||
Task<User> GetUserByAgentName(string agentName);
|
||||
}
|
||||
Reference in New Issue
Block a user