Skip to content

Commit

Permalink
add janky no-log tick calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
JairusSW committed Jan 20, 2024
1 parent 4f21c79 commit a70d785
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion assembly/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ let configObj: Config = new Config();

export function initialize(config: string): void {
configObj = JSON.parse<Config>(config);

if (!configObj.isValid()) throw new Error("Invalid configuration");
}

Expand All @@ -46,6 +45,18 @@ function getTickFromPrice(price: f64): i32 {
return i32(tick);
}

function getTickFromPriceNoLog(price: u64): i32 {
let tick = 1.0001;
let result = -1;

while (u64(tick) < price) {
tick /= 1.0001;
result++;
}

return result;
}

export function execute(_prices: string): string {
const prices = parseCandles(_prices);
if (prices.length == 0) throw new Error("Expected to find candles, but found none!");
Expand Down
Empty file added test.ts
Empty file.

0 comments on commit a70d785

Please sign in to comment.