Refactoring TradingBotBase.cs + clean architecture (#38)
* Refactoring TradingBotBase.cs + clean architecture * Fix basic tests * Fix tests * Fix workers * Fix open positions * Fix closing position stucking the grain * Fix comments * Refactor candle handling to use IReadOnlyList for chronological order preservation across various components
This commit is contained in:
@@ -121,26 +121,14 @@ namespace Managing.Infrastructure.Exchanges
|
||||
reduceOnly: true);
|
||||
}
|
||||
|
||||
public async Task<Trade> ClosePosition(Account account, Position position, decimal lastPrice,
|
||||
bool isForPaperTrading = false)
|
||||
public async Task<Trade> ClosePosition(Account account, Position position, decimal lastPrice)
|
||||
{
|
||||
var direction = position.OriginDirection == TradeDirection.Long
|
||||
? TradeDirection.Short
|
||||
: TradeDirection.Long;
|
||||
|
||||
if (isForPaperTrading)
|
||||
{
|
||||
var fake = BuildEmptyTrade(position.Open.Ticker,
|
||||
lastPrice,
|
||||
position.Open.Quantity,
|
||||
direction,
|
||||
position.Open.Leverage,
|
||||
TradeType.Market,
|
||||
position.Open.Date,
|
||||
TradeStatus.Filled);
|
||||
return fake;
|
||||
}
|
||||
|
||||
// Paper trading logic has been moved to CloseBacktestFuturesPositionCommandHandler
|
||||
// This method now only handles live trading
|
||||
var processor = GetProcessor(account);
|
||||
var closedTrade = await processor.OpenTrade(
|
||||
account,
|
||||
|
||||
Reference in New Issue
Block a user