-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodels.ts
272 lines (246 loc) · 7.71 KB
/
models.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
export var Prefixes = {
SNAPSHOT: '=',
MESSAGE: '-'
}
export var Topics = {
FairValue: 'a',
Quote: 'b',
ActiveSubscription: 'c',
Connectivity: 'd',
MarketData: 'e',
QuotingParametersChange: 'f',
SafetySettings: 'g',
Product: 'h',
OrderStatusReports: 'i',
ProductAdvertisement: 'j',
ApplicationState: 'k',
EWMAStats: 'l',
STDEVStats: 'm',
Position: 'n',
Profit: 'o',
SubmitNewOrder: 'p',
CancelOrder: 'q',
MarketTrade: 'r',
Trades: 's',
ExternalValuation: 't',
QuoteStatus: 'u',
TargetBasePosition: 'v',
TradeSafetyValue: 'w',
CancelAllOrders: 'x',
CleanAllClosedTrades: 'y',
CleanAllTrades: 'z',
CleanTrade: 'A',
WalletChart: 'C',
MarketChart: 'D',
Notepad: 'E',
MarketDataLongTerm: 'H'
}
export class MarketSide {
constructor(public price: number,
public size: number,
public cssMod: number) { }
}
export class Market {
constructor(public bids: MarketSide[],
public asks: MarketSide[]) { }
}
export class MarketStats {
constructor(public fv: number,
public bid: number,
public ask: number,
public time: number) { }
}
export class MarketTrade {
constructor(public price: number,
public quantity: number,
public time: number,
public side: Side) {}
}
export enum Connectivity { Disconnected, Connected }
export enum Side { Bid, Ask, Unknown }
export enum OrderType { Limit, Market }
export enum TimeInForce { IOC, FOK, GTC }
export enum OrderStatus { Waiting, Working, Terminated }
export enum Liquidity { Make, Take }
export interface ProductState {
advert: ProductAdvertisement;
fixed: number
}
export interface IStdev {
fv: number;
fvMean: number;
tops: number;
topsMean: number;
bid: number;
bidMean: number;
ask: number;
askMean: number;
}
export interface IEwma {
ewmaVeryLong: number;
ewmaLong: number;
ewmaMedium: number;
ewmaShort: number;
ewmaQuote: number;
ewmaWidth: number;
ewmaTrendDiff: number;
}
export class MarketChart {
constructor(public stdevWidth: IStdev,
public ewma: IEwma,
public fairValue: number,
public tradesBuySize: number,
public tradesSellSize: number) {}
}
export class TradeChart {
constructor(public price: number,
public side: Side,
public quantity: number,
public value: number,
public pong: boolean) {}
}
export class Trade {
constructor(public tradeId: string,
public time: number,
public price: number,
public quantity: number,
public side: Side,
public value: number,
public Ktime: number,
public Kqty: number,
public Kprice: number,
public Kvalue: number,
public Kdiff: number,
public feeCharged: number,
public isPong: boolean,
public loadedFromDB: boolean) {}
}
export class Wallet {
constructor(public amount: number,
public held: number,
public value: number,
public profit: number) {}
}
export class PositionReport {
constructor(public base: Wallet,
public quote: Wallet) {}
}
export class OrderRequestFromUI {
constructor(public side: string,
public price: number,
public quantity: number,
public timeInForce: string,
public type: string) {}
}
export class FairValue {
constructor(public price: number) {}
}
export class Quote {
constructor(public price: number,
public size: number,
public isPong: boolean) {}
}
export class TwoSidedQuote {
constructor(public bid: Quote, public ask: Quote) {}
}
export enum QuoteStatus { Disconnected, Live, DisabledQuotes, MissingData, UnknownHeld, WidthMustBeSmaller, TBPHeld, MaxTradesSeconds, WaitingPing, DepletedFunds, Crossed, UpTrendHeld, DownTrendHeld }
export class TwoSidedQuoteStatus {
constructor(public bidStatus: QuoteStatus,
public askStatus: QuoteStatus,
public sideAPR: string,
public quotesInMemoryWaiting: number,
public quotesInMemoryWorking: number,
public quotesInMemoryZombies: number) {}
}
export enum QuotingMode { Top, Mid, Join, InverseJoin, InverseTop, HamelinRat, Depth }
export enum QuotingSafety { Off, PingPong, Boomerang, AK47 }
export enum FairValueModel { BBO, wBBO, rwBBO }
export enum AutoPositionMode { Manual, EWMA_LS, EWMA_LMS, EWMA_4 }
export enum DynamicPDivMode { Manual, Linear, Sine, SQRT, Switch }
export enum PingAt { BothSides, BidSide, AskSide, DepletedSide, DepletedBidSide, DepletedAskSide, StopPings }
export enum PongAt { ShortPingFair, AveragePingFair, LongPingFair, ShortPingAggressive, AveragePingAggressive, LongPingAggressive }
export enum APR { Off, Size, SizeWidth }
export enum SOP { Off, Trades, Size, TradesSize }
export enum STDEV { Off, OnFV, OnFVAPROff, OnTops, OnTopsAPROff, OnTop, OnTopAPROff }
export interface QuotingParameters {
widthPing?: any;
widthPingPercentage?: number;
widthPong?: any;
widthPongPercentage?: number;
widthPercentage?: boolean;
bestWidth?: boolean;
buySize?: any;
buySizePercentage?: number;
buySizeMax?: boolean;
sellSize?: any;
sellSizePercentage?: number;
sellSizeMax?: boolean;
pingAt?: PingAt;
pongAt?: PongAt;
mode?: QuotingMode;
safety?: QuotingSafety
fvModel?: FairValueModel;
targetBasePosition?: number;
targetBasePositionPercentage?: number;
positionDivergence?: number;
positionDivergencePercentage?: number;
positionDivergenceMin?: number;
positionDivergencePercentageMin?: number;
positionDivergenceMode?: number;
percentageValues?: boolean;
autoPositionMode?: AutoPositionMode;
aggressivePositionRebalancing?: APR;
superTrades?: SOP;
tradesPerMinute?: number;
tradeRateSeconds?: number;
protectionEwmaWidthPing?: boolean;
protectionEwmaQuotePrice?: boolean;
quotingEwmaTrendProtection?: boolean;
quotingEwmaTrendThreshold?: number;
quotingStdevProtection?: STDEV;
quotingStdevBollingerBands?: boolean;
audio?: boolean;
bullets?: number;
range?: number;
rangePercentage?: number;
ewmaSensiblityPercentage?: number;
veryLongEwmaPeriods?: number;
longEwmaPeriods?: number;
mediumEwmaPeriods?: number;
shortEwmaPeriods?: number;
extraShortEwmaPeriods?: number;
ultraShortEwmaPeriods?: number;
protectionEwmaPeriods?: number;
quotingStdevProtectionFactor?: number;
quotingStdevProtectionPeriods?: number;
aprMultiplier?: number;
sopWidthMultiplier?: number;
sopSizeMultiplier?: number;
sopTradesMultiplier?: number;
cancelOrdersAuto?: boolean;
cleanPongsAuto?: number;
stepOverSize?: number;
profitHourInterval?: number;
delayUI?: number;
}
export class ProductAdvertisement {
constructor(public exchange: string, public base: string, public quote: string, public environment: string, public matryoshka: string, public homepage: string, public minTick: number) { }
}
export class ApplicationState {
constructor(public memory: number, public inet: string, public freq: number, public theme: number, public dbsize: number) { }
}
export class TradeSafety {
constructor(
public buy: number,
public sell: number,
public combined: number,
public buyPing: number,
public sellPing: number
) {}
}
export class TargetBasePositionValue {
constructor(
public tbp: number,
public pDiv: number
) {}
}