chore: test different logic
This commit is contained in:
@@ -312,31 +312,38 @@ export function publishGroupings(
|
|||||||
|
|
||||||
// Count crossed levels at the beginning
|
// Count crossed levels at the beginning
|
||||||
let crossedBids = 0;
|
let crossedBids = 0;
|
||||||
const bestAsk = fullAggregatedAsks[0]?.[0];
|
const bestAsk = fullAggregatedAsks[0]?.price;
|
||||||
if (bestAsk !== undefined) {
|
if (bestAsk !== undefined) {
|
||||||
for (const bid of fullAggregatedBids) {
|
for (const bid of fullAggregatedBids) {
|
||||||
if (bid[0] >= bestAsk) {
|
if (bid.price >= bestAsk) {
|
||||||
crossedBids++;
|
crossedBids++;
|
||||||
} else {
|
} else {
|
||||||
break; // Stop at first uncrossed level
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let crossedAsks = 0;
|
let crossedAsks = 0;
|
||||||
const bestBid = fullAggregatedBids[0]?.[0];
|
const bestBid = fullAggregatedBids[0]?.price;
|
||||||
if (bestBid !== undefined) {
|
if (bestBid !== undefined) {
|
||||||
for (const ask of fullAggregatedAsks) {
|
for (const ask of fullAggregatedAsks) {
|
||||||
if (ask[0] <= bestBid) {
|
if (ask.price <= bestBid) {
|
||||||
crossedAsks++;
|
crossedAsks++;
|
||||||
} else {
|
} else {
|
||||||
break; // Stop at first uncrossed level
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const aggregatedBids = fullAggregatedBids.slice(0, 20 + crossedBids);
|
const maxCrossed = Math.max(crossedBids, crossedAsks);
|
||||||
const aggregatedAsks = fullAggregatedAsks.slice(0, 20 + crossedAsks);
|
const levelsToTake = 20 + maxCrossed;
|
||||||
|
|
||||||
|
if (group === 10) {
|
||||||
|
console.log(bestAsk, bestBid, crossedAsks, crossedBids, levelsToTake);
|
||||||
|
}
|
||||||
|
|
||||||
|
const aggregatedBids = fullAggregatedBids.slice(0, levelsToTake);
|
||||||
|
const aggregatedAsks = fullAggregatedAsks.slice(0, levelsToTake);
|
||||||
|
|
||||||
const l2Formatted_grouped20 = Object.assign({}, l2Formatted, {
|
const l2Formatted_grouped20 = Object.assign({}, l2Formatted, {
|
||||||
bids: aggregatedBids,
|
bids: aggregatedBids,
|
||||||
@@ -719,7 +726,8 @@ export function createMarketBasedAuctionParams(
|
|||||||
// Set market-specific defaults (only used if values are undefined)
|
// Set market-specific defaults (only used if values are undefined)
|
||||||
const marketSpecificDefaults: Partial<AuctionParamArgs> = {
|
const marketSpecificDefaults: Partial<AuctionParamArgs> = {
|
||||||
...DEFAULT_AUCTION_PARAMS,
|
...DEFAULT_AUCTION_PARAMS,
|
||||||
auctionStartPriceOffsetFrom: isMajorMarket && version === 1 ? 'mark' : 'bestOffer',
|
auctionStartPriceOffsetFrom:
|
||||||
|
isMajorMarket && version === 1 ? 'mark' : 'bestOffer',
|
||||||
auctionStartPriceOffset: isMajorMarket && version === 1 ? 0 : -0.1,
|
auctionStartPriceOffset: isMajorMarket && version === 1 ? 0 : -0.1,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1490,7 +1498,10 @@ export const calculateDynamicSlippage = (
|
|||||||
const minSlippage = parseFloat(process.env.DYNAMIC_SLIPPAGE_MIN || '0.035'); // 0.035% minimum
|
const minSlippage = parseFloat(process.env.DYNAMIC_SLIPPAGE_MIN || '0.035'); // 0.035% minimum
|
||||||
const maxSlippage = parseFloat(process.env.DYNAMIC_SLIPPAGE_MAX || '5'); // 5% maximum
|
const maxSlippage = parseFloat(process.env.DYNAMIC_SLIPPAGE_MAX || '5'); // 5% maximum
|
||||||
|
|
||||||
let finalSlippage = Math.min(Math.max(dynamicSlippage, minSlippage), maxSlippage);
|
let finalSlippage = Math.min(
|
||||||
|
Math.max(dynamicSlippage, minSlippage),
|
||||||
|
maxSlippage
|
||||||
|
);
|
||||||
|
|
||||||
// Apply 10% boost for API v2
|
// Apply 10% boost for API v2
|
||||||
if (apiVersion === 2) {
|
if (apiVersion === 2) {
|
||||||
|
|||||||
Reference in New Issue
Block a user