Фиксы багов купли продажи по решению
test / deploy_trader_prod (push) Successful in 2m0s
Details
test / deploy_trader_prod (push) Successful in 2m0s
Details
parent
f95a34e5a1
commit
83e1b0fe43
|
@ -1,19 +1,4 @@
|
|||
using Castle.Core.Logging;
|
||||
using KLHZ.Trader.Core.Common;
|
||||
using KLHZ.Trader.Core.Common.Messaging.Services;
|
||||
using KLHZ.Trader.Core.DataLayer;
|
||||
using KLHZ.Trader.Core.Exchange.Models.AssetsAccounting;
|
||||
using KLHZ.Trader.Core.Exchange.Models.Configs;
|
||||
using KLHZ.Trader.Core.Math.Common;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using NSubstitute;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using KLHZ.Trader.Core.Exchange.Models.AssetsAccounting;
|
||||
|
||||
namespace KLHZ.Trader.Core.Tests
|
||||
{
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
public static class BotModeSwitcher
|
||||
{
|
||||
private readonly static object _locker = new();
|
||||
private static bool _canSell = true;
|
||||
private static bool _canPurchase = true;
|
||||
private static bool _canSell = false;
|
||||
private static bool _canPurchase = false;
|
||||
|
||||
public static bool CanSell()
|
||||
{
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
if (_instrumentsFigis.Contains(future.Figi))
|
||||
{
|
||||
_tickersCache.TryAdd(future.Figi, future.Ticker);
|
||||
_assetTypesCache.TryAdd(future.Figi, AssetType.Common);
|
||||
_assetTypesCache.TryAdd(future.Figi, AssetType.Futures);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
DeferredLongOpens.TryRemove(message.Figi, out _);
|
||||
if (message.Value - longOpen.Price < 1)
|
||||
{
|
||||
if (!message.IsHistoricalData)
|
||||
if (!message.IsHistoricalData && BotModeSwitcher.CanPurchase())
|
||||
{
|
||||
var accounts = _tradeDataProvider.Accounts
|
||||
.Where(a => !a.Value.Assets.ContainsKey(message.Figi))
|
||||
|
@ -158,7 +158,8 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
DeferredLongCloses.TryRemove(message.Figi, out _);
|
||||
if (longClose.Price - message.Value < 1)
|
||||
{
|
||||
if (!message.IsHistoricalData)
|
||||
var assetType = _tradeDataProvider.GetAssetTypeByFigi(message.Figi);
|
||||
if (!message.IsHistoricalData && BotModeSwitcher.CanSell())
|
||||
{
|
||||
var assetsForClose = _tradeDataProvider.Accounts
|
||||
.SelectMany(a => a.Value.Assets.Values)
|
||||
|
@ -167,7 +168,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
foreach (var asset in assetsForClose)
|
||||
{
|
||||
var profit = 0m;
|
||||
var assetType = _tradeDataProvider.GetAssetTypeByFigi(message.Figi);
|
||||
|
||||
if (assetType == AssetType.Common && asset.Count > 0)
|
||||
{
|
||||
profit = TradingCalculator.CaclProfit(asset.BoughtPrice, message.Value,
|
||||
|
@ -236,10 +237,22 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
|
||||
|
||||
res |= (uptrendStarts & TradingEvent.UptrendStart);
|
||||
//res |= (uptrendStarts2 & TradingEvent.UptrendStart);
|
||||
//res |= downtrendEnds;
|
||||
res |= resultLongClose;
|
||||
res |= resultMoveAvFull.events;
|
||||
|
||||
//res = TradingEvent.None;
|
||||
|
||||
//if (!stopBuy &&RandomNumberGenerator.GetInt32(100) < 20)
|
||||
//{
|
||||
// res |= TradingEvent.UptrendStart;
|
||||
//}
|
||||
//else if (!stopSell && (RandomNumberGenerator.GetInt32(100) < 20))
|
||||
//{
|
||||
// res |= TradingEvent.UptrendEnd;
|
||||
//}
|
||||
|
||||
|
||||
|
||||
if (resultMoveAvFull.bigWindowAv != 0)
|
||||
{
|
||||
LogPrice(processedPrices, message, bigWindowProcessor, resultMoveAvFull.bigWindowAv);
|
||||
|
@ -247,7 +260,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
}
|
||||
if ((resultLongClose & TradingEvent.StopBuy) == TradingEvent.StopBuy)
|
||||
{
|
||||
var stopTo = (message.IsHistoricalData ? message.Time : DateTime.UtcNow).AddMinutes(_buyStopLength/2);
|
||||
var stopTo = (message.IsHistoricalData ? message.Time : DateTime.UtcNow).AddMinutes(_buyStopLength / 2);
|
||||
OpeningStops.AddOrUpdate(message.Figi, stopTo, (k, v) => stopTo);
|
||||
//LogDeclision(declisionsForSave, DeclisionTradeAction.StopBuy, message);
|
||||
}
|
||||
|
|
|
@ -10,11 +10,11 @@ namespace KLHZ.Trader.Core.Exchange.Utils
|
|||
private readonly static TimeOnly _openTimeHoliday = new(7, 10);
|
||||
private readonly static TimeOnly _closeTimeHoliday = new(17, 45);
|
||||
|
||||
private readonly static TimeOnly _firstClearingStart = new(10, 55);
|
||||
private readonly static TimeOnly _firstClearingStart = new(10, 45);
|
||||
private readonly static TimeOnly _firstClearingEnd = new(11, 10);
|
||||
|
||||
private readonly static TimeOnly _mainClearingStart = new(15, 50);
|
||||
private readonly static TimeOnly _mainClearingEnd = new(16, 5);
|
||||
private readonly static TimeOnly _mainClearingStart = new(15, 45);
|
||||
private readonly static TimeOnly _mainClearingEnd = new(16, 10);
|
||||
|
||||
internal static ExchangeState GetCurrentState(DateTime? currentDt = null)
|
||||
{
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
using KLHZ.Trader.Core.Contracts.Messaging.Dtos;
|
||||
using KLHZ.Trader.Core.Contracts.Messaging.Dtos.Interfaces;
|
||||
using KLHZ.Trader.Core.DataLayer.Entities.Declisions;
|
||||
using KLHZ.Trader.Core.DataLayer.Entities.Declisions.Enums;
|
||||
using KLHZ.Trader.Core.Exchange.Models.AssetsAccounting;
|
||||
using KLHZ.Trader.Core.Exchange.Services;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KLHZ.Trader.Core.Exchange.Utils
|
||||
{
|
||||
internal static class TraderFuncs
|
||||
{
|
||||
//internal static TradeCommand[] CreateBuyCommands(ConcurrentDictionary<string, ManagedAccount> accounts, INewPrice message, List<Declision> declisions)
|
||||
//{
|
||||
// var accs = accounts.Where(a => !a.Value.Assets.ContainsKey(message.Figi))
|
||||
// .ToArray();
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
using KLHZ.Trader.Core.Common;
|
||||
using KLHZ.Trader.Core.Common.Messaging.Services;
|
||||
using KLHZ.Trader.Core.Contracts.Messaging.Interfaces;
|
||||
using KLHZ.Trader.Core.DataLayer;
|
||||
|
|
Loading…
Reference in New Issue