фикс записи в бд
test / deploy_trader_prod (push) Successful in 6m41s Details

dev
vlad zverzhkhovskiy 2025-09-09 11:57:43 +03:00
parent 7d2618dd54
commit c2105ad019
3 changed files with 87 additions and 82 deletions

View File

@ -26,8 +26,6 @@ namespace KLHZ.Trader.Core.Math.Declisions.Utils
var bigWindowAv = 0m;
var smallWindowAv = 0m;
var s = 0;
try
{
var pricesForFinalComparison = new decimal[size];
var twavss = new decimal[size];
var twavbs = new decimal[size];
@ -123,11 +121,6 @@ namespace KLHZ.Trader.Core.Math.Declisions.Utils
}
}
}
}
catch (Exception ex)
{
}
return (res, bigWindowAv, smallWindowAv);
}
}

View File

@ -13,6 +13,7 @@ using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Tinkoff.InvestApi;
using Tinkoff.InvestApi.V1;
using static Google.Rpc.Context.AttributeContext.Types;
namespace KLHZ.Trader.Core.Exchange.Services
{
@ -55,7 +56,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
{
try
{
//_ = SubscribeUpdates();
_ = SubscribeMyTrades();
if (_exchangeDataRecievingEnabled)
{
_ = SubscribePrices();
@ -69,7 +70,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
}
}
private async Task SubscribeUpdates()
private async Task SubscribeMyTrades()
{
var req = new TradesStreamRequest();
foreach (var a in _tradeDataProvider.Accounts)
@ -81,6 +82,17 @@ namespace KLHZ.Trader.Core.Exchange.Services
{
if (response.OrderTrades != null)
{
foreach(var t in response.OrderTrades.Trades)
{
//await _tradeDataProvider.LogDeal(new Models.AssetsAccounting.DealResult()
//{
// AccountId = response.OrderTrades.AccountId,
// Figi = response.OrderTrades.Figi,
// Count = t.Quantity,
// Price = t.Price,
// Direction = Models.AssetsAccounting.DealDirection
//})
}
}
}
@ -210,7 +222,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
await _eventBus.Broadcast(message);
}
if (orderbookItemsBuffer.Count + pricesBuffer.Count + tradesBuffer.Count > 0 || (DateTime.UtcNow - lastWrite).TotalSeconds > 10)
if (orderbookItemsBuffer.Count + pricesBuffer.Count + tradesBuffer.Count > 100 || (DateTime.UtcNow - lastWrite).TotalSeconds > 5)
{
try
{

View File

@ -210,7 +210,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
{
var assetType = _tradeDataProvider.GetAssetTypeByFigi(message.Figi);
var loggedDeclisions = 0;
if (BotModeSwitcher.CanSell())
if (!message.IsHistoricalData && BotModeSwitcher.CanSell())
{
var assetsForClose = _tradeDataProvider.Accounts
.SelectMany(a => a.Value.Assets.Values)
@ -283,7 +283,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
Processor = processor,
Time = message.Time,
Value = value,
}, !message.IsHistoricalData);
}, false);
}
private async Task LogDeclision(DeclisionTradeAction action, INewPrice message, decimal? profit = null)
@ -297,7 +297,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
Price = message.Value,
Time = message.IsHistoricalData ? message.Time : DateTime.UtcNow,
Action = action,
}, !message.IsHistoricalData);
}, false);
}
public Task StopAsync(CancellationToken cancellationToken)