Skip to content

Commit

Permalink
fixing bad calculation in spread factor
Browse files Browse the repository at this point in the history
  • Loading branch information
zavelevsky committed Dec 3, 2023
1 parent 27d8e30 commit f1f34e3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@bancor/carbon-sdk",
"type": "module",
"source": "src/index.ts",
"version": "0.0.87-DEV",
"version": "0.0.88-DEV",
"description": "The SDK is a READ-ONLY tool, intended to facilitate working with Carbon contracts. It's a convenient wrapper around our matching algorithm, allowing programs and users get a ready to use transaction data that will allow them to manage strategies and fulfill trades",
"main": "dist/index.js",
"module": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/strategy-management/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ export function calculateOverlappingPriceRanges(
sellPriceLow: Decimal;
sellPriceMarginal: Decimal;
} {
const spreadFactor = spreadPercentage.plus(1);
const spreadFactor = spreadPercentage.div(100).plus(1);
const buyPriceHigh = sellPriceHigh.div(spreadFactor);
const sellPriceLow = buyPriceLow.mul(spreadFactor);

Expand Down
6 changes: 3 additions & 3 deletions tests/toolkit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('Toolkit', () => {
'1500',
'2000',
'1845',
'0.01'
'1'
);
expect(result).to.deep.equal({
buyPriceHigh: '1980.198019801980198019',
Expand All @@ -122,7 +122,7 @@ describe('Toolkit', () => {
'1500',
'2000',
'1845',
'0.01',
'1',
'100'
);
expect(result).to.equal('0.024939801923642185');
Expand All @@ -134,7 +134,7 @@ describe('Toolkit', () => {
'1500',
'2000',
'1845',
'0.01',
'1',
'0.024939801923642185'
);
expect(result).to.equal('100.999999');
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('utils', () => {
buyPriceLow: new Decimal('1500'),
sellPriceHigh: new Decimal('2000'),
marketPrice: new Decimal('1845'),
spreadPercentage: new Decimal('0.01'),
spreadPercentage: new Decimal('1'),
buyBudget: new Decimal('100'),
buyPriceHigh: new Decimal(
'1980.19801980198019801980198019801980198019801980198019801980198019801980198019801980198019801980198'
Expand Down

0 comments on commit f1f34e3

Please sign in to comment.