Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
performanceArtist committed Oct 25, 2021
0 parents commit 952a2b1
Show file tree
Hide file tree
Showing 22 changed files with 2,908 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
3 changes: 3 additions & 0 deletions dist/binance/apiTypes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as t from 'io-ts';
export declare const BinanceKlineIO: t.TupleType<[t.NumberC, t.StringC, t.StringC, t.StringC, t.StringC, t.StringC, t.NumberC, t.StringC, t.NumberC, t.StringC, t.StringC, t.StringC], readonly [number, string, string, string, string, string, number, string, number, string, string, string], readonly [number, string, string, string, string, string, number, string, number, string, string, string], unknown>;
export declare type BinanceKline = t.TypeOf<typeof BinanceKlineIO>;
38 changes: 38 additions & 0 deletions dist/binance/apiTypes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BinanceKlineIO = void 0;
const t = __importStar(require("io-ts"));
const tuple = t.tuple;
exports.BinanceKlineIO = tuple([
t.number,
t.string,
t.string,
t.string,
t.string,
t.string,
t.number,
t.string,
t.number,
t.string,
t.string,
t.string,
]);
25 changes: 25 additions & 0 deletions dist/binance/client.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { HKT, Kind, Kind2, URIS, URIS2 } from 'fp-ts/lib/HKT';
import { MonadThrow, MonadThrow1, MonadThrow2 } from 'fp-ts/lib/MonadThrow';
import { Errors } from 'io-ts';
export interface Request {
readonly method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
readonly url: string;
readonly responseType: 'json' | 'blob' | 'text';
readonly query?: string;
readonly body?: unknown;
readonly headers?: Record<string, unknown>;
}
export interface HTTPClient<F> extends MonadThrow<F> {
readonly request: (request: Request) => HKT<F, unknown>;
}
export interface HTTPClient1<F extends URIS> extends MonadThrow1<F> {
readonly request: (request: Request) => Kind<F, unknown>;
}
export interface HTTPClient2<F extends URIS2> extends MonadThrow2<F> {
readonly request: (request: Request) => Kind2<F, unknown, unknown>;
}
export declare class ResponseValidationError extends Error {
readonly errors: Errors;
static create(errors: Errors): ResponseValidationError;
constructor(errors: Errors);
}
17 changes: 17 additions & 0 deletions dist/binance/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ResponseValidationError = void 0;
const PathReporter_1 = require("io-ts/lib/PathReporter");
const Either_1 = require("fp-ts/lib/Either");
class ResponseValidationError extends Error {
constructor(errors) {
super(PathReporter_1.PathReporter.report((0, Either_1.left)(errors)).join('\n\n'));
this.errors = errors;
this.name = 'ResponseValidationError';
Object.setPrototypeOf(this, ResponseValidationError.prototype);
}
static create(errors) {
return new ResponseValidationError(errors);
}
}
exports.ResponseValidationError = ResponseValidationError;
267 changes: 267 additions & 0 deletions dist/binance/core.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
import { either } from 'fp-ts';
import * as t from 'io-ts';
import { Either } from 'fp-ts/lib/Either';
import { Observable } from 'rxjs';
import { Json } from 'fp-ts/lib/Json';
import { BinanceInterval } from './socketTypes';
import { observableEither } from 'fp-ts-rxjs';
export declare const buildQueryString: (o: {}) => string;
export declare const makeSignQuery: (apiSecret: string) => <T extends Record<string, unknown>>(query: T) => T & {
signature: string;
timestamp: t.Int;
};
export declare const fromPromiseToStream: <A>(promise: () => Promise<A>) => Observable<either.Either<unknown, A>>;
export declare type BinanceConfig = {
apiKey: string;
apiSecret: string;
};
interface Request {
readonly method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
readonly url: string;
readonly responseType: 'json' | 'blob' | 'text';
readonly query?: string;
readonly body?: unknown;
readonly headers?: Record<string, unknown>;
}
export declare const makeBinanceHttpClient: (baseURL: string, config: BinanceConfig) => {
signQuery: <T extends Record<string, unknown>>(query: T) => T & {
signature: string;
timestamp: t.Int;
};
httpClient: {
request: (request: Request) => Observable<either.Either<Error, any>>;
ap: <E, A, B>(fab: observableEither.ObservableEither<E, (a: A) => B>, fa: observableEither.ObservableEither<E, A>) => observableEither.ObservableEither<E, B>;
URI: "ObservableEither";
map: <E_1, A_1, B_1>(fa: observableEither.ObservableEither<E_1, A_1>, f: (a: A_1) => B_1) => observableEither.ObservableEither<E_1, B_1>;
of: <E_2, A_2>(a: A_2) => observableEither.ObservableEither<E_2, A_2>;
chain: <E_3, A_3, B_2>(fa: observableEither.ObservableEither<E_3, A_3>, f: (a: A_3) => observableEither.ObservableEither<E_3, B_2>) => observableEither.ObservableEither<E_3, B_2>;
bimap: <E_4, A_4, G, B_3>(fea: observableEither.ObservableEither<E_4, A_4>, f: (e: E_4) => G, g: (a: A_4) => B_3) => observableEither.ObservableEither<G, B_3>;
mapLeft: <E_5, A_5, G_1>(fea: observableEither.ObservableEither<E_5, A_5>, f: (e: E_5) => G_1) => observableEither.ObservableEither<G_1, A_5>;
alt: <E_6, A_6>(fa: observableEither.ObservableEither<E_6, A_6>, that: import("fp-ts/lib/function").Lazy<observableEither.ObservableEither<E_6, A_6>>) => observableEither.ObservableEither<E_6, A_6>;
fromObservable: <E_7, A_7>(fa: Observable<A_7>) => observableEither.ObservableEither<E_7, A_7>;
fromIO: import("fp-ts/lib/NaturalTransformation").NaturalTransformation12<"IO", "ObservableEither">;
fromTask: import("fp-ts/lib/NaturalTransformation").NaturalTransformation12<"Task", "ObservableEither">;
throwError: <E_8, A_8>(e: E_8) => observableEither.ObservableEither<E_8, A_8>;
};
};
export declare const makeWebsocketStream: (url: string, websocketImplementation?: any) => Observable<Either<Error, Json>>;
export declare const makeBinanceWebsocketClient: (baseURL: string, websocketImplementation?: any) => {
aggregatedTrade: (symbol: string) => Observable<either.Either<Error, {
e: "aggTrade";
E: t.Branded<number, t.IntBrand>;
s: string;
a: t.Branded<number, t.IntBrand>;
p: string;
q: string;
f: t.Branded<number, t.IntBrand>;
l: t.Branded<number, t.IntBrand>;
T: t.Branded<number, t.IntBrand>;
m: boolean;
M: boolean;
}>>;
trade: (symbol: string) => Observable<either.Either<Error, {
e: "trade";
E: t.Branded<number, t.IntBrand>;
s: string;
t: t.Branded<number, t.IntBrand>;
p: string;
q: string;
b: t.Branded<number, t.IntBrand>;
a: t.Branded<number, t.IntBrand>;
T: t.Branded<number, t.IntBrand>;
m: boolean;
M: boolean;
}>>;
kline: (symbol: string, interval: BinanceInterval) => Observable<either.Either<Error, {
e: "kline";
E: number;
s: string;
k: {
t: number;
T: number;
s: string;
i: "1m" | "3m" | "5m" | "15m" | "30m" | "1h" | "2h" | "4h" | "6h" | "8h" | "12h" | "1d" | "3d" | "1w" | "1M";
f: number;
L: number;
o: string;
c: string;
h: string;
l: string;
v: string;
n: number;
x: boolean;
q: string;
V: string;
Q: string;
B: string;
};
}>>;
miniTicker: (symbol: string) => Observable<either.Either<Error, {
e: "24hrMiniTicker";
E: t.Branded<number, t.IntBrand>;
s: string;
c: string;
o: string;
h: string;
l: string;
v: string;
q: string;
}>>;
miniTickers: () => Observable<either.Either<Error, {
e: "24hrMiniTicker";
E: t.Branded<number, t.IntBrand>;
s: string;
c: string;
o: string;
h: string;
l: string;
v: string;
q: string;
}[]>>;
ticker: (symbol: string) => Observable<either.Either<Error, {
e: "24hrTicker";
E: t.Branded<number, t.IntBrand>;
s: string;
p: string;
P: string;
w: string;
x: string;
c: string;
Q: string;
b: string;
B: string;
a: string;
A: string;
o: string;
h: string;
l: string;
v: string;
q: string;
O: t.Branded<number, t.IntBrand>;
C: t.Branded<number, t.IntBrand>;
F: t.Branded<number, t.IntBrand>;
L: t.Branded<number, t.IntBrand>;
n: t.Branded<number, t.IntBrand>;
}>>;
tickers: () => Observable<either.Either<Error, {
e: "24hrTicker";
E: t.Branded<number, t.IntBrand>;
s: string;
p: string;
P: string;
w: string;
x: string;
c: string;
Q: string;
b: string;
B: string;
a: string;
A: string;
o: string;
h: string;
l: string;
v: string;
q: string;
O: t.Branded<number, t.IntBrand>;
C: t.Branded<number, t.IntBrand>;
F: t.Branded<number, t.IntBrand>;
L: t.Branded<number, t.IntBrand>;
n: t.Branded<number, t.IntBrand>;
}[]>>;
bookTicker: (symbol: string) => Observable<either.Either<Error, {
u: t.Branded<number, t.IntBrand>;
s: string;
b: string;
B: string;
a: string;
A: string;
}>>;
bookTickers: () => Observable<either.Either<Error, {
u: t.Branded<number, t.IntBrand>;
s: string;
b: string;
B: string;
a: string;
A: string;
}>>;
partialBookDepth: (symbol: string, levels: 5 | 10 | 20, speed: 100 | 1000) => Observable<either.Either<Error, {
lastUpdateId: t.Branded<number, t.IntBrand>;
bids: [string, string][];
asks: [string, string][];
}>>;
diffBookDepth: (symbol: string, speed: 100 | 1000) => Observable<either.Either<Error, {
e: "depthUpdate";
E: t.Branded<number, t.IntBrand>;
s: string;
U: t.Branded<number, t.IntBrand>;
u: t.Branded<number, t.IntBrand>;
b: [string, string][];
a: [string, string][];
}>>;
userData: (listenKey: string) => Observable<either.Either<Error, {
e: "outboundAccountPosition";
E: t.Branded<number, t.IntBrand>;
u: t.Branded<number, t.IntBrand>;
B: {
a: string;
f: string;
l: string;
}[];
} | {
e: "balanceUpdate";
E: t.Branded<number, t.IntBrand>;
a: string;
d: string;
T: t.Branded<number, t.IntBrand>;
} | {
e: "executionReport";
E: t.Branded<number, t.IntBrand>;
s: string;
c: string;
S: "SELL" | "BUY";
o: "LIMIT" | "MARKET" | "STOP_LOSS" | "STOP_LOSS_LIMIT" | "TAKE_PROFIT" | "TAKE_PROFIT_LIMIT" | "LIMIT_MAKER";
f: "GTC" | "IOC" | "FOK";
q: string;
p: string;
P: string;
F: string;
g: t.Branded<number, t.IntBrand>;
C: string;
x: "NEW" | "CANCELED" | "REPLACED" | "TRADE" | "EXPIRED";
X: "NEW" | "EXPIRED" | "PARTIALLY_FILLED" | "FILLED" | "CANCELLED" | "PENDING_CANCEL" | "REJECTED";
r: string;
i: t.Branded<number, t.IntBrand>;
l: string;
z: string;
L: string;
n: string;
N: null;
T: t.Branded<number, t.IntBrand>;
t: t.Branded<number, t.IntBrand>;
I: t.Branded<number, t.IntBrand>;
w: boolean;
m: boolean;
M: boolean;
O: t.Branded<number, t.IntBrand>;
Z: string;
Y: string;
Q: string;
} | {
e: "listStatus";
E: t.Branded<number, t.IntBrand>;
s: string;
g: t.Branded<number, t.IntBrand>;
c: "OCO";
l: "RESPONSE" | "EXEC_STARTED" | "ALL_DONE";
L: "ALL_DONE" | "EXECUTING" | "REJECT";
r: string;
C: string;
T: t.Branded<number, t.IntBrand>;
O: {
s: string;
i: t.Branded<number, t.IntBrand>;
c: string;
}[];
}>>;
};
export {};
Loading

0 comments on commit 952a2b1

Please sign in to comment.