Skip to content

Commit

Permalink
Format with semicolons
Browse files Browse the repository at this point in the history
  • Loading branch information
focus1691 committed Nov 21, 2024
1 parent 01886df commit fb66b9a
Show file tree
Hide file tree
Showing 50 changed files with 1,042 additions and 1,033 deletions.
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"singleQuote": true,
"trailingComma": "none",
"printWidth": 160,
"semi": false
"semi": true
}
18 changes: 9 additions & 9 deletions src/constants/fibonacci.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export interface IFibonacciRetracement {
0: number | null
0.236: number | null
0.382: number | null
0.5: number | null
0.618: number | null
0.66: number | null
0.786: number | null
1: number | null
1.618: number | null
0: number | null;
0.236: number | null;
0.382: number | null;
0.5: number | null;
0.618: number | null;
0.66: number | null;
0.786: number | null;
1: number | null;
1.618: number | null;
}

export enum FIBONACCI_NUMBERS {
Expand Down
18 changes: 9 additions & 9 deletions src/constants/harmonics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IXABCDRatio } from '../types/harmonics.types'
import { IXABCDRatio } from '../types/harmonics.types';

export enum HARMONIC_PATTERNS {
BAT = 'bat',
Expand All @@ -15,49 +15,49 @@ export const BAT_RATIOS: IXABCDRatio = Object.freeze({
ABC: [0.382, 0.886] as [number, number],
BCD: [1.618, 2.618] as [number, number],
XAD: [0.886, 0.886] as [number, number]
})
});

export const GARTLEY_RATIOS: IXABCDRatio = Object.freeze({
XAB: [0.618, 0.618] as [number, number],
ABC: [0.382, 0.886] as [number, number],
BCD: [1.13, 1.618] as [number, number],
XAD: [0.786, 0.786] as [number, number]
})
});

export const BUTTERFLY_RATIOS: IXABCDRatio = Object.freeze({
XAB: [0.786, 0.786] as [number, number],
ABC: [0.5, 0.886] as [number, number],
BCD: [1.618, 2.24] as [number, number],
XAD: [1.27, 1.27] as [number, number]
})
});

export const CRAB_RATIOS: IXABCDRatio = Object.freeze({
XAB: [0.382, 0.886] as [number, number],
ABC: [0.382, 0.886] as [number, number],
BCD: [2.618, 3.618] as [number, number],
XAD: [1.618, 1.618] as [number, number]
})
});

export const DEEP_CRAB_RATIOS: IXABCDRatio = Object.freeze({
XAB: [0.886, 0.886] as [number, number],
ABC: [0.382, 0.886] as [number, number],
BCD: [2.0, 3.618] as [number, number],
XAD: [1.618, 1.618] as [number, number]
})
});

export const CYPHER_RATIOS: IXABCDRatio = Object.freeze({
XAB: [0.382, 0.618] as [number, number],
ABC: [1.13, 1.41] as [number, number],
BCD: [1.272, 2.0] as [number, number],
XAD: [1.13, 1.414] as [number, number]
})
});

export const SHARK_RATIOS: IXABCDRatio = Object.freeze({
XAB: [1.13, 1.618] as [number, number],
ABC: [1.13, 1.13] as [number, number],
BCD: [0.5, 0.5] as [number, number],
XAD: [0.886, 1.13] as [number, number]
})
});

export const harmonicRatios = Object.freeze({
[HARMONIC_PATTERNS.BAT]: BAT_RATIOS,
Expand All @@ -67,4 +67,4 @@ export const harmonicRatios = Object.freeze({
[HARMONIC_PATTERNS.DEEP_CRAB]: DEEP_CRAB_RATIOS,
[HARMONIC_PATTERNS.CYPHER]: CYPHER_RATIOS,
[HARMONIC_PATTERNS.SHARK]: SHARK_RATIOS
})
});
12 changes: 6 additions & 6 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export * from './harmonics'
export * from './marketProfile'
export * from './orderflow'
export * from './fibonacci'
export * from './signals'
export * from './time'
export * from './harmonics';
export * from './marketProfile';
export * from './orderflow';
export * from './fibonacci';
export * from './signals';
export * from './time';
8 changes: 4 additions & 4 deletions src/constants/marketProfile.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const SINGLE_PRINTS_KLINE_LENGTH_SIGNIFICANCE = 5
export const EXCESS_TAIL_LENGTH_SIGNIFICANCE = 15
export const POOR_HIGH_LOW_KLINE_LENGTH_SIGNIFICANCE = 15
export const SINGLE_PRINTS_KLINE_LENGTH_SIGNIFICANCE = 5;
export const EXCESS_TAIL_LENGTH_SIGNIFICANCE = 15;
export const POOR_HIGH_LOW_KLINE_LENGTH_SIGNIFICANCE = 15;

export const TPO_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789'
export const TPO_LETTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789';

export enum MARKET_PROFILE_PERIODS {
DAILY = 'daily',
Expand Down
2 changes: 1 addition & 1 deletion src/constants/orderflow/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './stackedImbalances.ts'
export * from './stackedImbalances.ts';
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './lib'
export * as constants from './constants'
export * as types from './types'
export * as utils from './utils'
export * from './lib';
export * as constants from './constants';
export * as types from './types';
export * as utils from './utils';
38 changes: 19 additions & 19 deletions src/lib/candlePatterns/engulfing.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SIGNAL_DIRECTION } from '../../constants/signals'
import { ICandle } from '../../types'
import { IEngulfingCandleConfig } from '../../types/candlestickPatterns/engulfingCandle.types'
import { SIGNAL_DIRECTION } from '../../constants/signals';
import { ICandle } from '../../types';
import { IEngulfingCandleConfig } from '../../types/candlestickPatterns/engulfingCandle.types';

/**
* Finds engulfing candle patterns in a given set of candles.
Expand All @@ -17,27 +17,27 @@ import { IEngulfingCandleConfig } from '../../types/candlestickPatterns/engulfin
* ```
*/
export const findEngulfingCandle = (config: IEngulfingCandleConfig): SIGNAL_DIRECTION | null => {
const candles: ICandle[] = config.candles
const candles: ICandle[] = config.candles;
if (candles.length < 2) {
return null
return null;
}

const index = config.index ?? candles.length - 1
if (!candles[index] || !candles[index - 1]) return null // Ensures there's a previous candle
const index = config.index ?? candles.length - 1;
if (!candles[index] || !candles[index - 1]) return null; // Ensures there's a previous candle

const prevCandle: ICandle = candles[index - 1]
const currCandle: ICandle = candles[index]
const prevCandle: ICandle = candles[index - 1];
const currCandle: ICandle = candles[index];

const isPreviousBullish: boolean = prevCandle.close > prevCandle.open
const isPreviousBearish: boolean = prevCandle.close < prevCandle.open
const isCurrentBullish: boolean = currCandle.close > currCandle.open
const isCurrentBearish: boolean = currCandle.close < currCandle.open
const isPreviousBullish: boolean = prevCandle.close > prevCandle.open;
const isPreviousBearish: boolean = prevCandle.close < prevCandle.open;
const isCurrentBullish: boolean = currCandle.close > currCandle.open;
const isCurrentBearish: boolean = currCandle.close < currCandle.open;

const isBullishEngulfing: boolean = isPreviousBearish && isCurrentBullish && currCandle.open <= prevCandle.close && currCandle.close >= prevCandle.open
const isBearishEngulfing: boolean = isPreviousBullish && isCurrentBearish && currCandle.open >= prevCandle.close && currCandle.close <= prevCandle.open
const isBullishEngulfing: boolean = isPreviousBearish && isCurrentBullish && currCandle.open <= prevCandle.close && currCandle.close >= prevCandle.open;
const isBearishEngulfing: boolean = isPreviousBullish && isCurrentBearish && currCandle.open >= prevCandle.close && currCandle.close <= prevCandle.open;

if (isBullishEngulfing) return SIGNAL_DIRECTION.BULLISH
if (isBearishEngulfing) return SIGNAL_DIRECTION.BEARISH
if (isBullishEngulfing) return SIGNAL_DIRECTION.BULLISH;
if (isBearishEngulfing) return SIGNAL_DIRECTION.BEARISH;

return null
}
return null;
};
32 changes: 16 additions & 16 deletions src/lib/candlePatterns/excess.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import { EXCESS_TAIL_LENGTH_SIGNIFICANCE } from '../../constants/marketProfile'
import { ICandle } from '../../types/candle.types'
import { EXCESS_TAIL_LENGTH_SIGNIFICANCE } from '../../constants/marketProfile';
import { ICandle } from '../../types/candle.types';

/**
* Determines whether a candle is an excess candle.
* An excess candle is identified by the length of its tails relative to its body.
*
*
* @param candle - The candle to check for excess.
* @returns True if the candle is an excess candle, otherwise false.
*
*
* @example
* ```typescript
* import { CandlestickPatterns } from '@focus1691/chart-patterns';
*
*
* // Assuming 'candle' is an ICandle object
* const isExcessCandle: boolean = CandlestickPatterns.isExcess(candle);
* ```
*/
export const isExcess = (candle: ICandle): boolean => {
const open: number = candle.open
const high: number = candle.high
const low: number = candle.low
const close: number = candle.close
const klineLength: number = Math.abs(close - open)
const klineUpperTail: number = Math.abs(close - high)
const klineLowerTail: number = Math.abs(close - low)
const open: number = candle.open;
const high: number = candle.high;
const low: number = candle.low;
const close: number = candle.close;
const klineLength: number = Math.abs(close - open);
const klineUpperTail: number = Math.abs(close - high);
const klineLowerTail: number = Math.abs(close - low);

const isUpperTailExcess: boolean = klineUpperTail / klineLength > EXCESS_TAIL_LENGTH_SIGNIFICANCE
const isLowerTailExcess: boolean = klineLowerTail / klineLength > EXCESS_TAIL_LENGTH_SIGNIFICANCE
const isUpperTailExcess: boolean = klineUpperTail / klineLength > EXCESS_TAIL_LENGTH_SIGNIFICANCE;
const isLowerTailExcess: boolean = klineLowerTail / klineLength > EXCESS_TAIL_LENGTH_SIGNIFICANCE;

return isUpperTailExcess || isLowerTailExcess
}
return isUpperTailExcess || isLowerTailExcess;
};
4 changes: 2 additions & 2 deletions src/lib/candlePatterns/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './engulfing'
export * from './excess'
export * from './engulfing';
export * from './excess';
Loading

0 comments on commit fb66b9a

Please sign in to comment.