This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const exportData = { | |
"coin": "btcusdc", | |
"lines": [], | |
"extraLines": [{ | |
"name": "RSI", | |
"color": "red", | |
"data": [{"x": 1745390699999, "y": 61.06}, {"x": 1745391599999, "y": 60.73}, { | |
"x": 1745392499999, | |
"y": 57.43 | |
}, {"x": 1745393399999, "y": 57.85}, {"x": 1745394299999, "y": 61.45}, { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Trades Analysis</title> | |
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script> | |
<script src="./data.js"></script> | |
</head> | |
<body> | |
<div id="charts"> | |
<div id="main"></div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Iterable arrays chain, extended for "getLength" and "at" accessor. | |
*/ | |
export interface IArraysChain<T> extends RelativeIndexable<T>, Iterable<T> { | |
/** | |
* Calculates total length of all input arrays combined. | |
*/ | |
getLength(): number; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Retry-status object type, for use with RetryCB. | |
*/ | |
export type RetryStatus<D = unknown> = { | |
/** | |
* Retry index, starting from 0. | |
*/ | |
readonly index: number, | |
/** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Observable, switchMap} from 'rxjs'; | |
/** | |
* Spike detection result. | |
*/ | |
export interface ISpike { | |
/** | |
* Detected spike change, in percent. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type basicType<T> = T extends 'string' ? string : | |
T extends 'number' ? number : | |
T extends 'boolean' ? boolean : | |
T extends 'bigint' ? bigint : | |
never; | |
function removeByType<T, A>(input: T[], t1: keyof A): Exclude<T, basicType<typeof t1>>[]; | |
function removeByType<T, A, B>(input: T[], t1: keyof A, t2: keyof B): Exclude<T, basicType<typeof t1 | typeof t2>>[]; | |
function removeByType<T, A, B, C>(input: T[], t1: keyof A, t2: keyof B, t3: keyof C): Exclude<T, basicType<typeof t1 | typeof t2 | typeof t3>>[]; | |
function removeByType<T, A, B, C, D>(input: T[], t1: keyof A, t2: keyof B, t3: keyof C, t4: keyof D): Exclude<T, basicType<typeof t1 | typeof t2 | typeof t3 | typeof t4>>[]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Pool} from 'pg'; // or from 'pg-pool' | |
import {QueryIterable, QueryIterablePool} from 'pg-iterator'; | |
import {from, finalize, Observable} from 'rxjs'; | |
const pool = new Pool({/* connection details */}); | |
// RxJs helper for completing queries safely: | |
function fromQuery<T>(qi: QueryIterable<T>, text: string, params?: any[]): Observable<T> { | |
return from(qi.query(text, params)).pipe(finalize(() => qi.release())); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {aggregate, reduce, skip, take, distinct, map, Operation, tap} from 'iter-ops'; | |
/////////////////////////////////////////////////////////////////////////////// | |
// Collection of custom operators for "iter-ops", made from existing operators, | |
// as implementation examples + ideas (these are not part of the library). | |
/////////////////////////////////////////////////////////////////////////////// | |
/** | |
* Logs values into the console. | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {pipe, reduce} from 'iter-ops'; | |
const m = new Map<string, number>(); | |
m.set('one', 1); | |
m.set('two', 2); | |
m.set('three', 3); | |
const i = pipe(m.values(), reduce((a, c) => a + c, 5)); | |
console.log(...i); //=> 11 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {pipe, reduce} from 'iter-ops'; | |
const m = new Map<string, number>(); | |
m.set('one', 1); | |
m.set('two', 2); | |
m.set('three', 3); | |
const i = pipe(m.values(), reduce((a, c) => a + c)); | |
console.log(...i); |
NewerOlder