feat(trading): copy order book volume value to deal ticket (#4333)
This commit is contained in:
parent
53048ac8ef
commit
737ffb4c35
@ -9,6 +9,7 @@ const bidCumulative = 'cumulative-vol-9889001';
|
|||||||
const midPrice = 'middle-mark-price-4612690000';
|
const midPrice = 'middle-mark-price-4612690000';
|
||||||
const priceResolution = 'resolution';
|
const priceResolution = 'resolution';
|
||||||
const dealTicketPrice = 'order-price';
|
const dealTicketPrice = 'order-price';
|
||||||
|
const dealTicketSize = 'order-size';
|
||||||
const resPrice = 'price-990';
|
const resPrice = 'price-990';
|
||||||
|
|
||||||
describe('order book', { tags: '@smoke' }, () => {
|
describe('order book', { tags: '@smoke' }, () => {
|
||||||
@ -74,6 +75,18 @@ describe('order book', { tags: '@smoke' }, () => {
|
|||||||
cy.getByTestId(dealTicketPrice).should('have.value', '98.94585');
|
cy.getByTestId(dealTicketPrice).should('have.value', '98.94585');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('copy size to deal ticket form', () => {
|
||||||
|
// 6003-ORDB-009
|
||||||
|
cy.getByTestId(bidCumulative).click();
|
||||||
|
cy.getByTestId(dealTicketSize).should('have.value', '7');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('copy size to deal ticket form', () => {
|
||||||
|
// 6003-ORDB-009
|
||||||
|
cy.getByTestId(bidVolume).click();
|
||||||
|
cy.getByTestId(dealTicketSize).should('have.value', '1');
|
||||||
|
});
|
||||||
|
|
||||||
it('change price resolution', () => {
|
it('change price resolution', () => {
|
||||||
// 6003-ORDB-008
|
// 6003-ORDB-008
|
||||||
const resolutions = [
|
const resolutions = [
|
||||||
|
@ -66,10 +66,13 @@ export const OrderbookManager = ({ marketId }: OrderbookManagerProps) => {
|
|||||||
decimalPlaces={market?.decimalPlaces ?? 0}
|
decimalPlaces={market?.decimalPlaces ?? 0}
|
||||||
positionDecimalPlaces={market?.positionDecimalPlaces ?? 0}
|
positionDecimalPlaces={market?.positionDecimalPlaces ?? 0}
|
||||||
assetSymbol={market?.tradableInstrument.instrument.product.quoteName}
|
assetSymbol={market?.tradableInstrument.instrument.product.quoteName}
|
||||||
onClick={(price: string) => {
|
onClick={({ price, size }) => {
|
||||||
if (price) {
|
if (price) {
|
||||||
updateOrder(marketId, { price });
|
updateOrder(marketId, { price });
|
||||||
}
|
}
|
||||||
|
if (size) {
|
||||||
|
updateOrder(marketId, { size });
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
midPrice={marketData?.midPrice}
|
midPrice={marketData?.midPrice}
|
||||||
/>
|
/>
|
||||||
|
@ -11,7 +11,7 @@ interface OrderbookRowProps {
|
|||||||
decimalPlaces: number;
|
decimalPlaces: number;
|
||||||
positionDecimalPlaces: number;
|
positionDecimalPlaces: number;
|
||||||
price: string;
|
price: string;
|
||||||
onClick?: (price: string) => void;
|
onClick?: (args: { price?: string; size?: string }) => void;
|
||||||
type: VolumeType;
|
type: VolumeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +43,7 @@ const CumulativeVol = memo(
|
|||||||
testId,
|
testId,
|
||||||
positionDecimalPlaces,
|
positionDecimalPlaces,
|
||||||
cumulativeValue,
|
cumulativeValue,
|
||||||
|
onClick,
|
||||||
}: {
|
}: {
|
||||||
ask?: number;
|
ask?: number;
|
||||||
bid?: number;
|
bid?: number;
|
||||||
@ -50,6 +51,7 @@ const CumulativeVol = memo(
|
|||||||
testId?: string;
|
testId?: string;
|
||||||
className?: string;
|
className?: string;
|
||||||
positionDecimalPlaces: number;
|
positionDecimalPlaces: number;
|
||||||
|
onClick?: (size?: string | number) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const volume = cumulativeValue ? (
|
const volume = cumulativeValue ? (
|
||||||
<NumericCell
|
<NumericCell
|
||||||
@ -61,7 +63,15 @@ const CumulativeVol = memo(
|
|||||||
/>
|
/>
|
||||||
) : null;
|
) : null;
|
||||||
|
|
||||||
return (
|
return onClick && volume ? (
|
||||||
|
<button
|
||||||
|
data-testid={testId}
|
||||||
|
onClick={() => onClick(cumulativeValue)}
|
||||||
|
className="hover:dark:bg-neutral-800 hover:bg-neutral-200 text-right pr-1"
|
||||||
|
>
|
||||||
|
{volume}
|
||||||
|
</button>
|
||||||
|
) : (
|
||||||
<div className="pr-1" data-testid={testId}>
|
<div className="pr-1" data-testid={testId}>
|
||||||
{volume}
|
{volume}
|
||||||
</div>
|
</div>
|
||||||
@ -89,7 +99,9 @@ export const OrderbookRow = React.memo(
|
|||||||
<PriceCell
|
<PriceCell
|
||||||
testId={`price-${price}`}
|
testId={`price-${price}`}
|
||||||
value={BigInt(price)}
|
value={BigInt(price)}
|
||||||
onClick={() => onClick && onClick(addDecimal(price, decimalPlaces))}
|
onClick={() =>
|
||||||
|
onClick && onClick({ price: addDecimal(price, decimalPlaces) })
|
||||||
|
}
|
||||||
valueFormatted={addDecimalsFixedFormatNumber(price, decimalPlaces)}
|
valueFormatted={addDecimalsFixedFormatNumber(price, decimalPlaces)}
|
||||||
className={
|
className={
|
||||||
type === VolumeType.ask
|
type === VolumeType.ask
|
||||||
@ -97,8 +109,15 @@ export const OrderbookRow = React.memo(
|
|||||||
: 'text-market-green-600 dark:text-market-green'
|
: 'text-market-green-600 dark:text-market-green'
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<NumericCell
|
<PriceCell
|
||||||
testId={`${txtId}-vol-${price}`}
|
testId={`${txtId}-vol-${price}`}
|
||||||
|
onClick={(value) =>
|
||||||
|
onClick &&
|
||||||
|
value &&
|
||||||
|
onClick({
|
||||||
|
size: addDecimal(value, positionDecimalPlaces),
|
||||||
|
})
|
||||||
|
}
|
||||||
value={value}
|
value={value}
|
||||||
valueFormatted={addDecimalsFixedFormatNumber(
|
valueFormatted={addDecimalsFixedFormatNumber(
|
||||||
value,
|
value,
|
||||||
@ -107,6 +126,13 @@ export const OrderbookRow = React.memo(
|
|||||||
/>
|
/>
|
||||||
<CumulativeVol
|
<CumulativeVol
|
||||||
testId={`cumulative-vol-${price}`}
|
testId={`cumulative-vol-${price}`}
|
||||||
|
onClick={() =>
|
||||||
|
onClick &&
|
||||||
|
cumulativeValue &&
|
||||||
|
onClick({
|
||||||
|
size: addDecimal(cumulativeValue, positionDecimalPlaces),
|
||||||
|
})
|
||||||
|
}
|
||||||
positionDecimalPlaces={positionDecimalPlaces}
|
positionDecimalPlaces={positionDecimalPlaces}
|
||||||
cumulativeValue={cumulativeValue}
|
cumulativeValue={cumulativeValue}
|
||||||
/>
|
/>
|
||||||
|
@ -70,7 +70,7 @@ describe('Orderbook', () => {
|
|||||||
).toBeInTheDocument();
|
).toBeInTheDocument();
|
||||||
// Before resolution change the price is 122.934
|
// Before resolution change the price is 122.934
|
||||||
await fireEvent.click(await screen.getByTestId('price-122901'));
|
await fireEvent.click(await screen.getByTestId('price-122901'));
|
||||||
expect(onClickSpy).toBeCalledWith('122.901');
|
expect(onClickSpy).toBeCalledWith({ price: '122.901' });
|
||||||
const resolutionSelect = screen.getByTestId(
|
const resolutionSelect = screen.getByTestId(
|
||||||
'resolution'
|
'resolution'
|
||||||
) as HTMLSelectElement;
|
) as HTMLSelectElement;
|
||||||
@ -86,6 +86,6 @@ describe('Orderbook', () => {
|
|||||||
10
|
10
|
||||||
);
|
);
|
||||||
await fireEvent.click(await screen.getByTestId('price-12294'));
|
await fireEvent.click(await screen.getByTestId('price-12294'));
|
||||||
expect(onClickSpy).toBeCalledWith('122.94');
|
expect(onClickSpy).toBeCalledWith({ price: '122.94' });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -32,7 +32,7 @@ const OrderbookTable = ({
|
|||||||
decimalPlaces: number;
|
decimalPlaces: number;
|
||||||
positionDecimalPlaces: number;
|
positionDecimalPlaces: number;
|
||||||
type: VolumeType;
|
type: VolumeType;
|
||||||
onClick?: (price: string) => void;
|
onClick?: (args: { price?: string; size?: string }) => void;
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -69,7 +69,7 @@ const OrderbookTable = ({
|
|||||||
interface OrderbookProps {
|
interface OrderbookProps {
|
||||||
decimalPlaces: number;
|
decimalPlaces: number;
|
||||||
positionDecimalPlaces: number;
|
positionDecimalPlaces: number;
|
||||||
onClick?: (price: string) => void;
|
onClick?: (args: { price?: string; size?: string }) => void;
|
||||||
midPrice?: string;
|
midPrice?: string;
|
||||||
bids: PriceLevelFieldsFragment[];
|
bids: PriceLevelFieldsFragment[];
|
||||||
asks: PriceLevelFieldsFragment[];
|
asks: PriceLevelFieldsFragment[];
|
||||||
|
Loading…
Reference in New Issue
Block a user