Skip to content

Commit

Permalink
Dependabot (#34)
Browse files Browse the repository at this point in the history
* Bump @hastobegood/crypto-clients-binance from 0.7.0 to 0.8.0

* Bump @types/lodash from 4.14.181 to 4.14.182

* Bump @types/node from 14.x to 14

* Bump @typescript-eslint from 5.18.0 to 5.20.0

* Update linter configuration

* Add husky configuration

* Switch dependabot interval from weekly to monthly
  • Loading branch information
fbn-roussel authored Apr 20, 2022
1 parent 67de55c commit c27a725
Show file tree
Hide file tree
Showing 40 changed files with 650 additions and 132 deletions.
42 changes: 32 additions & 10 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,24 +1,46 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2021
},
"plugins": [
"@typescript-eslint",
"prettier"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:promise/recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"plugin:@typescript-eslint/recommended",
"prettier"
// must be the last extension
"plugin:prettier/recommended"
],
"settings": {
"import/resolver": {
"typescript": {
"alwaysTryTypes": true
}
}
},
"overrides": [
{
"files": [
".ts"
],
"parserOptions": {
"project": "./tsconfig.json"
}
}
],
"rules": {
"no-console": "error",
"prettier/prettier": "error",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/no-empty-interface": "off",
"import/order": [
"error",
{
"newlines-between": "always",
"alphabetize": {
"order": "asc",
"caseInsensitive": true
}
}
],
"@typescript-eslint/explicit-function-return-type": [
"error",
{
Expand Down
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ updates:
directory: /
target-branch: dependabot
schedule:
interval: weekly
interval: monthly
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

yarn lint
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/hastobegood/crypto-bot-artillery.git"
},
"engines": {
"node": "^14"
"node": "14"
},
"type": "module",
"main": "lib/cjs/src/index.js",
Expand Down Expand Up @@ -62,6 +62,7 @@
}
},
"scripts": {
"prepare": "yarn husky install",
"clean": "rm -rf out lib reports",
"build": "yarn build:esm && yarn build:cjs",
"build:esm": "yarn tsc",
Expand All @@ -73,21 +74,25 @@
"lint:report": "yarn eslint . --ext .ts --format json -o reports/eslint-report.json "
},
"dependencies": {
"@hastobegood/crypto-clients-binance": "^0.7.0",
"@hastobegood/crypto-clients-binance": "^0.8.0",
"joi": "^17.6.0",
"pino": "^7.10.0"
},
"devDependencies": {
"@types/jest": "^27.4.1",
"@types/lodash": "^4.14.181",
"@types/node": "14.x",
"@types/lodash": "^4.14.182",
"@types/node": "14",
"@types/pino": "^7.0.5",
"@types/randomstring": "^1.1.8",
"@typescript-eslint/eslint-plugin": "^5.18.0",
"@typescript-eslint/parser": "^5.18.0",
"@typescript-eslint/eslint-plugin": "^5.20.0",
"@typescript-eslint/parser": "^5.20.0",
"eslint": "^8.13.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-typescript": "^2.7.1",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-promise": "^6.0.0",
"husky": "^7.0.4",
"jest": "^27.5.1",
"jest-sonar-reporter": "^2.0.0",
"lodash": "^4.17.21",
Expand Down
3 changes: 2 additions & 1 deletion src/artillery.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { logger } from './common/log/logger.js';
import { ApiInfoProvider, Client } from '@hastobegood/crypto-clients-binance';

import { ExchangesClients } from './common/exchanges/clients.js';
import { logger } from './common/log/logger.js';

export interface ArtilleryOptions {
binanceApiInfoProvider?: ApiInfoProvider;
Expand Down
5 changes: 3 additions & 2 deletions src/candlestick/artillery.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ExchangesClients } from '../common/exchanges/clients.js';

import { CandlestickClient } from './domain/candlestick-client.js';
import { FetchCandlestickClient } from './domain/fetch-candlestick-client.js';
import { BinanceCandlestickClient } from './infrastructure/exchanges/binance/binance-candlestick-client.js';
import { ExchangeCandlestickClient } from './infrastructure/exchanges/exchange-candlestick-client.js';
import { HttpCandlestickClient } from './infrastructure/http-candlestick-client.js';
import { CandlestickClient } from './domain/candlestick-client.js';
import { FetchCandlestickClient } from './domain/fetch-candlestick-client.js';

let candlestickClient: CandlestickClient;

Expand Down
2 changes: 1 addition & 1 deletion src/candlestick/domain/fetch-candlestick-client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Candlesticks, FetchAllCandlesticks } from './model/candlestick.js';
import { CandlestickClient } from './candlestick-client.js';
import { Candlesticks, FetchAllCandlesticks } from './model/candlestick.js';

export class FetchCandlestickClient {
constructor(private candlestickClient: CandlestickClient) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { toBinanceSymbol } from '../../../../common/exchanges/binance/binance-converter.js';
import { ExchangeCandlestickClient } from '../exchange-candlestick-client.js';
import { Client, GetCandlestickDataCommand, GetCandlestickDataInput } from '@hastobegood/crypto-clients-binance';

import { CandlestickExchange, Candlesticks, FetchAllCandlesticks } from '../../../../candlestick/domain/model/candlestick.js';
import { toBinanceSymbol } from '../../../../common/exchanges/binance/binance-converter.js';
import { ExchangeCandlestickClient } from '../exchange-candlestick-client.js';

export class BinanceCandlestickClient implements ExchangeCandlestickClient {
constructor(private client: Client) {}
Expand Down
3 changes: 2 additions & 1 deletion src/candlestick/infrastructure/http-candlestick-client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { CandlestickClient } from '../domain/candlestick-client.js';
import { ExchangeCandlestickClient } from './exchanges/exchange-candlestick-client.js';
import { CandlestickExchange, Candlesticks, FetchAllCandlesticks } from '../domain/model/candlestick.js';

import { ExchangeCandlestickClient } from './exchanges/exchange-candlestick-client.js';

export class HttpCandlestickClient implements CandlestickClient {
constructor(private exchangeCandlestickClients: ExchangeCandlestickClient[]) {}

Expand Down
3 changes: 2 additions & 1 deletion src/common/exchanges/binance/binance-converter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { extractAssets } from '../../util/symbol.js';
import { OrderSide as BinanceOrderSide, OrderStatus as BinanceOrderStatus, OrderType as BinanceOrderType } from '@hastobegood/crypto-clients-binance';

import { OrderSide, OrderStatus, OrderType } from '../../../order/domain/model/order.js';
import { extractAssets } from '../../util/symbol.js';

export const toBinanceSymbol = (symbol: string): string => {
const assets = extractAssets(symbol);
Expand Down
4 changes: 2 additions & 2 deletions src/common/log/logger.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pino from 'pino';
import { pino, stdTimeFunctions } from 'pino';

const defaultLogger = pino({
level: process.env.LOG_LEVEL,
timestamp: pino.stdTimeFunctions.isoTime,
timestamp: stdTimeFunctions.isoTime,
messageKey: 'message',
nestedKey: 'data',
base: null,
Expand Down
7 changes: 4 additions & 3 deletions src/order/artillery.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { ExchangesClients } from '../common/exchanges/clients.js';
import { FetchTickerClient } from '../ticker/domain/fetch-ticker-client.js';

import { CheckOrderClient } from './domain/check-order-client.js';
import { OrderClient } from './domain/order-client.js';
import { SendOrderClient } from './domain/send-order-client.js';
import { BinanceOrderClient } from './infrastructure/exchanges/binance/binance-order-client.js';
import { ExchangeOrderClient } from './infrastructure/exchanges/exchange-order-client.js';
import { HttpOrderClient } from './infrastructure/http-order-client.js';
import { OrderClient } from './domain/order-client.js';
import { SendOrderClient } from './domain/send-order-client.js';
import { CheckOrderClient } from './domain/check-order-client.js';

let orderClient: OrderClient;

Expand Down
2 changes: 2 additions & 0 deletions src/order/domain/send-order-client.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { randomUUID } from 'crypto';

import { truncateNumber } from '../../common/util/math.js';
import { FetchTickerClient } from '../../ticker/domain/fetch-ticker-client.js';
import { Ticker } from '../../ticker/domain/model/ticker.js';

import { Order, SendOrder, TransientOrder } from './model/order.js';
import { OrderClient } from './order-client.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Client, GetAccountTradesListCommand, GetAccountTradesListInput, GetOrderCommand, GetOrderInput, GetOrderOutput, SendOrderCommand, SendOrderInput, SendOrderOutput } from '@hastobegood/crypto-clients-binance';

import { fromBinanceOrderStatus, toBinanceOrderSide, toBinanceOrderType, toBinanceSymbol } from '../../../../common/exchanges/binance/binance-converter.js';
import { roundNumber } from '../../../../common/util/math.js';
import { extractAssets } from '../../../../common/util/symbol.js';
import { fromBinanceOrderStatus, toBinanceOrderSide, toBinanceOrderType, toBinanceSymbol } from '../../../../common/exchanges/binance/binance-converter.js';
import { ExchangeOrderClient } from '../exchange-order-client.js';
import { Client, GetAccountTradesListCommand, GetAccountTradesListInput, GetOrderCommand, GetOrderInput, GetOrderOutput, SendOrderCommand, SendOrderInput, SendOrderOutput } from '@hastobegood/crypto-clients-binance';
import { CheckOrder, Order, OrderCheckup, OrderExchange, TransientOrder } from '../../../../order/domain/model/order.js';
import { ExchangeOrderClient } from '../exchange-order-client.js';

export class BinanceOrderClient implements ExchangeOrderClient {
constructor(private client: Client) {}
Expand Down
3 changes: 2 additions & 1 deletion src/order/infrastructure/http-order-client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CheckOrder, Order, OrderCheckup, OrderExchange, TransientOrder } from '../domain/model/order.js';
import { OrderClient } from '../domain/order-client.js';

import { ExchangeOrderClient } from './exchanges/exchange-order-client.js';
import { CheckOrder, Order, OrderCheckup, OrderExchange, TransientOrder } from '../domain/model/order.js';

export class HttpOrderClient implements OrderClient {
constructor(private exchangeOrderClients: ExchangeOrderClient[]) {}
Expand Down
5 changes: 3 additions & 2 deletions src/ticker/artillery.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { ExchangesClients } from '../common/exchanges/clients.js';

import { FetchTickerClient } from './domain/fetch-ticker-client.js';
import { TickerClient } from './domain/ticker-client.js';
import { BinanceTickerClient } from './infrastructure/exchanges/binance/binance-ticker-client.js';
import { ExchangeTickerClient } from './infrastructure/exchanges/exchange-ticker-client.js';
import { HttpTickerClient } from './infrastructure/http-ticker-client.js';
import { TickerClient } from './domain/ticker-client.js';
import { FetchTickerClient } from './domain/fetch-ticker-client.js';

let tickerClient: TickerClient;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { toBinanceSymbol } from '../../../../common/exchanges/binance/binance-converter.js';
import { ExchangeTickerClient } from '../exchange-ticker-client.js';
import { Client, GetExchangeInfoCommand, GetExchangeInfoInput, GetExchangeInfoOutputSymbol, GetExchangeInfoOutputSymbolFilter } from '@hastobegood/crypto-clients-binance';

import { toBinanceSymbol } from '../../../../common/exchanges/binance/binance-converter.js';
import { FetchTicker, Ticker, TickerExchange } from '../../../../ticker/domain/model/ticker.js';
import { ExchangeTickerClient } from '../exchange-ticker-client.js';

export class BinanceTickerClient implements ExchangeTickerClient {
constructor(private client: Client) {}
Expand Down
3 changes: 2 additions & 1 deletion src/ticker/infrastructure/http-ticker-client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FetchTicker, Ticker, TickerExchange } from '../domain/model/ticker.js';
import { TickerClient } from '../domain/ticker-client.js';

import { ExchangeTickerClient } from './exchanges/exchange-ticker-client.js';
import { FetchTicker, Ticker, TickerExchange } from '../domain/model/ticker.js';

export class HttpTickerClient implements TickerClient {
constructor(private exchangeTickerClients: ExchangeTickerClient[]) {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { randomFromList, randomNumber, randomSymbol } from '../../random-test-builder.js';
import { Candlestick, Candlesticks, FetchAllCandlesticks } from '../../../../src/candlestick/domain/model/candlestick.js';
import { randomFromList, randomNumber, randomSymbol } from '../../random-test-builder.js';

export const buildDefaultFetchAllCandlesticks = (): FetchAllCandlesticks => {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { randomNumber } from '../../../../random-test-builder.js';
import { GetCandlestickDataOutput } from '@hastobegood/crypto-clients-binance';

import { randomNumber } from '../../../../random-test-builder.js';

export const buildDefaultBinanceGetCandlestickDataOutput = (): GetCandlestickDataOutput => {
return [1, 2, 3, 4, 5].map(() => [
new Date().valueOf(),
Expand Down
2 changes: 1 addition & 1 deletion test/builders/order/domain/order-test-builder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { randomBoolean, randomFromList, randomNumber, randomString, randomSymbol } from '../../random-test-builder.js';
import { CheckOrder, Order, OrderCheckup, SendOrder, TransientOrder } from '../../../../src/order/domain/model/order.js';
import { randomBoolean, randomFromList, randomNumber, randomString, randomSymbol } from '../../random-test-builder.js';

export const buildDefaultTransientOrder = (): TransientOrder => {
return buildDefaultTransientMarketOrder();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { randomAsset, randomBoolean, randomFromList, randomNumber, randomString, randomSymbol } from '../../../../random-test-builder.js';
import { GetAccountTradesListOutput, GetAccountTradesListOutputSymbol, GetOrderOutput, SendOrderOutput, SendOrderOutputFill } from '@hastobegood/crypto-clients-binance';

import { randomAsset, randomBoolean, randomFromList, randomNumber, randomString, randomSymbol } from '../../../../random-test-builder.js';

export const buildDefaultBinanceSendOrderOutput = (): SendOrderOutput => {
return {
symbol: randomSymbol(),
Expand Down
2 changes: 1 addition & 1 deletion test/builders/random-test-builder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { generate } from 'randomstring';
import { sample } from 'lodash';
import { generate } from 'randomstring';

export const randomString = (): string => {
return generate({ length: 10, charset: 'alphanumeric' });
Expand Down
2 changes: 1 addition & 1 deletion test/builders/ticker/domain/ticker-test-builder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { randomFromList, randomNumber, randomSymbol } from '../../random-test-builder.js';
import { FetchTicker, Ticker } from '../../../../src/ticker/domain/model/ticker.js';
import { randomFromList, randomNumber, randomSymbol } from '../../random-test-builder.js';

export const buildDefaultFetchTicker = (): FetchTicker => {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { randomAsset, randomBoolean, randomFromList, randomNumber, randomString, randomSymbol } from '../../../../random-test-builder.js';
import { GetExchangeInfoOutput, GetExchangeInfoOutputRateLimit, GetExchangeInfoOutputSymbol, GetExchangeInfoOutputSymbolFilter } from '@hastobegood/crypto-clients-binance';

import { randomAsset, randomBoolean, randomFromList, randomNumber, randomString, randomSymbol } from '../../../../random-test-builder.js';

export const buildDefaultBinanceGetExchangeInfoOutput = (): GetExchangeInfoOutput => {
return {
timezone: 'UTC',
Expand Down
1 change: 1 addition & 0 deletions test/unit/artillery.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ApiInfoProvider, Client } from '@hastobegood/crypto-clients-binance';

import { ArtilleryOptions, loadExchangesClients } from '../../src/artillery.js';

describe('Artillery', () => {
Expand Down
5 changes: 3 additions & 2 deletions test/unit/candlestick/artillery.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Client } from '@hastobegood/crypto-clients-binance';
import { ExchangesClients } from '../../../src/common/exchanges/clients.js';
import { FetchCandlestickClient } from '../../../src/candlestick/domain/fetch-candlestick-client.js';

import { loadFetchCandlestickClient } from '../../../src/candlestick/artillery.js';
import { FetchCandlestickClient } from '../../../src/candlestick/domain/fetch-candlestick-client.js';
import { ExchangesClients } from '../../../src/common/exchanges/clients.js';

describe('Artillery', () => {
describe('Given exchanges clients', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { toBinanceSymbol } from '../../../../../../src/common/exchanges/binance/binance-converter.js';
import { FetchAllCandlesticks } from '../../../../../../src/candlestick/domain/model/candlestick.js';
import { buildDefaultFetchAllCandlesticks } from '../../../../../builders/candlestick/domain/candlestick-test-builder.js';
import { Client, GetCandlestickDataOutput } from '@hastobegood/crypto-clients-binance';

import { FetchAllCandlesticks } from '../../../../../../src/candlestick/domain/model/candlestick.js';
import { BinanceCandlestickClient } from '../../../../../../src/candlestick/infrastructure/exchanges/binance/binance-candlestick-client.js';
import { toBinanceSymbol } from '../../../../../../src/common/exchanges/binance/binance-converter.js';
import { buildDefaultFetchAllCandlesticks } from '../../../../../builders/candlestick/domain/candlestick-test-builder.js';
import { buildDefaultBinanceGetCandlestickDataOutput } from '../../../../../builders/candlestick/infrastructure/exchanges/binance/binance-candlestick-test-builder.js';

const clientMock = jest.mocked(jest.genMockFromModule<Client>('@hastobegood/crypto-clients-binance'), true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CandlestickExchange, Candlesticks, FetchAllCandlesticks } from '../../../../src/candlestick/domain/model/candlestick.js';
import { BinanceCandlestickClient } from '../../../../src/candlestick/infrastructure/exchanges/binance/binance-candlestick-client.js';
import { HttpCandlestickClient } from '../../../../src/candlestick/infrastructure/http-candlestick-client.js';
import { CandlestickExchange, Candlesticks, FetchAllCandlesticks } from '../../../../src/candlestick/domain/model/candlestick.js';
import { buildDefaultCandlesticks, buildDefaultFetchAllCandlesticks } from '../../../builders/candlestick/domain/candlestick-test-builder.js';

const binanceCandlestickClientMock = jest.mocked(jest.genMockFromModule<BinanceCandlestickClient>('../../../../src/candlestick/infrastructure/exchanges/binance/binance-candlestick-client.js'), true);
Expand Down
3 changes: 2 additions & 1 deletion test/unit/common/exchanges/binance/binance-converter.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { OrderStatus as BinanceOrderStatus } from '@hastobegood/crypto-clients-binance';

import { fromBinanceOrderStatus, toBinanceOrderSide, toBinanceOrderType, toBinanceSymbol } from '../../../../../src/common/exchanges/binance/binance-converter.js';
import { OrderStatus as BinanceOrderStatus } from '@hastobegood/crypto-clients-binance/order';
import { OrderSide, OrderType } from '../../../../../src/order/domain/model/order.js';

describe('BinanceConverter', () => {
Expand Down
9 changes: 5 additions & 4 deletions test/unit/order/artillery.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Client } from '@hastobegood/crypto-clients-binance';

import { ExchangesClients } from '../../../src/common/exchanges/clients.js';
import { HttpTickerClient } from '../../../src/ticker/infrastructure/http-ticker-client.js';
import { FetchTickerClient } from '../../../src/ticker/domain/fetch-ticker-client.js';
import { SendOrderClient } from '../../../src/order/domain/send-order-client.js';
import { CheckOrderClient } from '../../../src/order/domain/check-order-client.js';
import { loadCheckOrderClient, loadSendOrderClient } from '../../../src/order/artillery.js';
import { CheckOrderClient } from '../../../src/order/domain/check-order-client.js';
import { SendOrderClient } from '../../../src/order/domain/send-order-client.js';
import { FetchTickerClient } from '../../../src/ticker/domain/fetch-ticker-client.js';
import { HttpTickerClient } from '../../../src/ticker/infrastructure/http-ticker-client.js';

describe('Artillery', () => {
describe('Given exchanges clients', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/order/domain/check-order-client.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OrderClient } from '../../../../src/order/domain/order-client.js';
import { CheckOrderClient } from '../../../../src/order/domain/check-order-client.js';
import { CheckOrder, OrderCheckup } from '../../../../src/order/domain/model/order.js';
import { OrderClient } from '../../../../src/order/domain/order-client.js';
import { buildDefaultCheckOrder, buildDefaultOrderCheckup } from '../../../builders/order/domain/order-test-builder.js';

const orderClientMock = jest.mocked(jest.genMockFromModule<OrderClient>('../../../../src/order/domain/order-client.js'), true);
Expand Down
Loading

0 comments on commit c27a725

Please sign in to comment.