Skip to content

Commit

Permalink
Adding slippage check to IOC orders
Browse files Browse the repository at this point in the history
  • Loading branch information
poly-rodr committed Jun 23, 2022
1 parent 89ad416 commit 9381a1b
Showing 1 changed file with 36 additions and 3 deletions.
39 changes: 36 additions & 3 deletions examples/marketOrderIOC.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,57 @@ async function main() {
side: Side.BUY,
size: 100,
}));
await clobClient.postOrder(await clobClient.createLimitOrder({
tokenID: NO_TOKEN,
price: 0.5,
side: Side.BUY,
size: 100,
}));
await clobClient.postOrder(await clobClient.createLimitOrder({
tokenID: NO_TOKEN,
price: 0.4,
side: Side.BUY,
size: 100,
}));
await clobClient.postOrder(await clobClient.createLimitOrder({
tokenID: NO_TOKEN,
price: 0.4,
side: Side.BUY,
size: 100,
}));

// FOK, error expected
const fok_order = await clobClient.createMarketOrder({
tokenID: NO_TOKEN,
side: Side.SELL,
size: 200,
size: 500,
timeInForce: "FOK"
})
console.log(`FOK market order: `);
console.log(fok_order);

console.log(await clobClient.postOrder(fok_order));

// Create a IOC market sell order for 100 YES tokens
// Create a IOC market sell that will fail because the slippage check
const ioc_slippage_check_order = await clobClient.createMarketOrder({
tokenID: NO_TOKEN,
side: Side.SELL,
size: 500,
worstPrice: 0.5,
timeInForce: "IOC"
});
console.log(`IOC market order: `);
console.log(ioc_slippage_check_order);

console.log(await clobClient.postOrder(ioc_slippage_check_order));


// Create a IOC market sell that will match
const ioc_order = await clobClient.createMarketOrder({
tokenID: NO_TOKEN,
side: Side.SELL,
size: 200,
size: 250,
worstPrice: 0.45,
timeInForce: "IOC"
});
console.log(`IOC market order: `);
Expand Down

0 comments on commit 9381a1b

Please sign in to comment.