Сократил объем информации по стаканам
parent
45b34b4509
commit
62de4169b8
|
@ -9,7 +9,7 @@ namespace KLHZ.Trader.Core.Contracts.Declisions.Interfaces
|
||||||
public ValueTask AddData(INewPrice priceChange);
|
public ValueTask AddData(INewPrice priceChange);
|
||||||
public ValueTask<(DateTime[] timestamps, float[] prices)> GetData();
|
public ValueTask<(DateTime[] timestamps, float[] prices)> GetData();
|
||||||
public ValueTask AddOrderbook(IOrderbook orderbook);
|
public ValueTask AddOrderbook(IOrderbook orderbook);
|
||||||
public int AsksCount { get; }
|
public long AsksCount { get; }
|
||||||
public int BidsCount { get; }
|
public long BidsCount { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
{
|
{
|
||||||
public string Ticker { get; }
|
public string Ticker { get; }
|
||||||
public string Figi { get; }
|
public string Figi { get; }
|
||||||
public int AsksCount {get;}
|
public long AsksCount { get; }
|
||||||
public int BidsCount {get;}
|
public long BidsCount { get; }
|
||||||
public DateTime Time { get; }
|
public DateTime Time { get; }
|
||||||
public IOrderbookItem[] Asks { get; }
|
public IOrderbookItem[] Asks { get; }
|
||||||
public IOrderbookItem[] Bids { get; }
|
public IOrderbookItem[] Bids { get; }
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{
|
{
|
||||||
public interface IOrderbookItem
|
public interface IOrderbookItem
|
||||||
{
|
{
|
||||||
public decimal Count { get; }
|
public long Count { get; }
|
||||||
public decimal Price { get; }
|
public decimal Price { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ namespace KLHZ.Trader.Core.Contracts.Messaging.Dtos
|
||||||
public DateTime Time { get; init; }
|
public DateTime Time { get; init; }
|
||||||
public IOrderbookItem[] Asks { get; init; } = [];
|
public IOrderbookItem[] Asks { get; init; } = [];
|
||||||
public IOrderbookItem[] Bids { get; init; } = [];
|
public IOrderbookItem[] Bids { get; init; } = [];
|
||||||
public int AsksCount { get; init; }
|
public long AsksCount { get; init; }
|
||||||
public int BidsCount { get; init; }
|
public long BidsCount { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,8 +20,8 @@ namespace KLHZ.Trader.Core.Math.Declisions.Services.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int AsksCount => 1;
|
public long AsksCount => 1;
|
||||||
public int BidsCount => 1;
|
public long BidsCount => 1;
|
||||||
|
|
||||||
private readonly object _locker = new();
|
private readonly object _locker = new();
|
||||||
private readonly float[] Prices = new float[CacheMaxLength];
|
private readonly float[] Prices = new float[CacheMaxLength];
|
||||||
|
|
|
@ -21,18 +21,18 @@ namespace KLHZ.Trader.Core.Math.Declisions.Services.Cache
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int AsksCount
|
public long AsksCount
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
{
|
||||||
|
lock (_locker)
|
||||||
{
|
{
|
||||||
lock (_locker)
|
return _asksCount;
|
||||||
{
|
|
||||||
return _asksCount;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public int BidsCount
|
public long BidsCount
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -50,8 +50,8 @@ namespace KLHZ.Trader.Core.Math.Declisions.Services.Cache
|
||||||
private int _length = 0;
|
private int _length = 0;
|
||||||
private int _pointer = -1;
|
private int _pointer = -1;
|
||||||
|
|
||||||
private int _asksCount = 1;
|
private long _asksCount = 1;
|
||||||
private int _bidsCount = 1;
|
private long _bidsCount = 1;
|
||||||
|
|
||||||
public ValueTask AddData(INewPrice priceChange)
|
public ValueTask AddData(INewPrice priceChange)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace KLHZ.Trader.Core.DataLayer.Entities.Orders
|
||||||
public decimal Price { get; set; }
|
public decimal Price { get; set; }
|
||||||
|
|
||||||
[Column("count")]
|
[Column("count")]
|
||||||
public decimal Count { get; set; }
|
public long Count { get; set; }
|
||||||
|
|
||||||
[Column("figi")]
|
[Column("figi")]
|
||||||
public required string Figi { get; set; }
|
public required string Figi { get; set; }
|
||||||
|
|
|
@ -109,17 +109,17 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
||||||
|
|
||||||
foreach (var f in _instrumentsFigis)
|
foreach (var f in _instrumentsFigis)
|
||||||
{
|
{
|
||||||
//request.Instruments.Add(
|
request.Instruments.Add(
|
||||||
// new LastPriceInstrument()
|
new LastPriceInstrument()
|
||||||
// {
|
{
|
||||||
// InstrumentId = f
|
InstrumentId = f
|
||||||
// });
|
});
|
||||||
|
|
||||||
//tradesRequest.Instruments.Add(
|
tradesRequest.Instruments.Add(
|
||||||
// new TradeInstrument()
|
new TradeInstrument()
|
||||||
// {
|
{
|
||||||
// InstrumentId = f
|
InstrumentId = f
|
||||||
// });
|
});
|
||||||
|
|
||||||
bookRequest.Instruments.Add(
|
bookRequest.Instruments.Add(
|
||||||
new OrderBookInstrument()
|
new OrderBookInstrument()
|
||||||
|
@ -176,51 +176,35 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
||||||
}
|
}
|
||||||
if (response.Orderbook != null)
|
if (response.Orderbook != null)
|
||||||
{
|
{
|
||||||
var asks = response.Orderbook.Asks.Select(a => new OrderbookItem()
|
var asksSummary = new OrderbookItem()
|
||||||
{
|
{
|
||||||
Figi = response.Orderbook.Figi,
|
Figi = response.Orderbook.Figi,
|
||||||
Ticker = GetTickerByFigi(response.Orderbook.Figi),
|
Ticker = GetTickerByFigi(response.Orderbook.Figi),
|
||||||
ItemType = DataLayer.Entities.Orders.Enums.OrderbookItemType.Ask,
|
Count = response.Orderbook.Asks.Sum(a => (int)a.Quantity),
|
||||||
|
ItemType = DataLayer.Entities.Orders.Enums.OrderbookItemType.AsksSummary,
|
||||||
Time = response.Orderbook.Time.ToDateTime().ToUniversalTime(),
|
Time = response.Orderbook.Time.ToDateTime().ToUniversalTime(),
|
||||||
Price = a.Price,
|
};
|
||||||
Count = a.Quantity,
|
|
||||||
}).ToArray();
|
var bidsSummary = new OrderbookItem()
|
||||||
orderbookItemsBuffer.AddRange(asks);
|
|
||||||
var bids = response.Orderbook.Bids.Select(a => new OrderbookItem()
|
|
||||||
{
|
{
|
||||||
Figi = response.Orderbook.Figi,
|
Figi = response.Orderbook.Figi,
|
||||||
Ticker = GetTickerByFigi(response.Orderbook.Figi),
|
Ticker = GetTickerByFigi(response.Orderbook.Figi),
|
||||||
ItemType = DataLayer.Entities.Orders.Enums.OrderbookItemType.Bid,
|
Count = response.Orderbook.Bids.Sum(a => (int)a.Quantity),
|
||||||
Time = response.Orderbook.Time.ToDateTime().ToUniversalTime(),
|
|
||||||
Price = a.Price,
|
|
||||||
Count = a.Quantity,
|
|
||||||
}).ToArray();
|
|
||||||
orderbookItemsBuffer.AddRange(bids);
|
|
||||||
orderbookItemsBuffer.Add(new OrderbookItem()
|
|
||||||
{
|
|
||||||
Figi = response.Orderbook.Figi,
|
|
||||||
Ticker = GetTickerByFigi(response.Orderbook.Figi),
|
|
||||||
Count = bids.Sum(a => (int)a.Count),
|
|
||||||
ItemType = DataLayer.Entities.Orders.Enums.OrderbookItemType.BidsSummary,
|
ItemType = DataLayer.Entities.Orders.Enums.OrderbookItemType.BidsSummary,
|
||||||
Time = response.Orderbook.Time.ToDateTime().ToUniversalTime(),
|
Time = response.Orderbook.Time.ToDateTime().ToUniversalTime(),
|
||||||
});
|
};
|
||||||
|
|
||||||
|
orderbookItemsBuffer.Add(asksSummary);
|
||||||
|
orderbookItemsBuffer.Add(bidsSummary);
|
||||||
|
|
||||||
var message = new NewOrderbookMessage()
|
var message = new NewOrderbookMessage()
|
||||||
{
|
{
|
||||||
Ticker = GetTickerByFigi(response.Orderbook.Figi),
|
Ticker = GetTickerByFigi(response.Orderbook.Figi),
|
||||||
Figi = response.Orderbook.Figi,
|
Figi = response.Orderbook.Figi,
|
||||||
Time = response.Orderbook.Time.ToDateTime().ToUniversalTime(),
|
Time = response.Orderbook.Time.ToDateTime().ToUniversalTime(),
|
||||||
Asks = asks,
|
AsksCount = asksSummary.Count,
|
||||||
Bids = bids,
|
BidsCount = bidsSummary.Count,
|
||||||
};
|
};
|
||||||
orderbookItemsBuffer.Add(new OrderbookItem()
|
|
||||||
{
|
|
||||||
Figi = response.Orderbook.Figi,
|
|
||||||
Ticker = GetTickerByFigi(response.Orderbook.Figi),
|
|
||||||
Count = asks.Sum(a => (int)a.Count),
|
|
||||||
ItemType = DataLayer.Entities.Orders.Enums.OrderbookItemType.AsksSummary,
|
|
||||||
Time = response.Orderbook.Time.ToDateTime().ToUniversalTime(),
|
|
||||||
});
|
|
||||||
await _eventBus.Broadcast(message);
|
await _eventBus.Broadcast(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue