@quantform/core 0.3.239 → 0.3.241

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,9 +10,9 @@ describe('instrument tests', () => {
10
10
  );
11
11
 
12
12
  expect(sut.base.name).toEqual('abc');
13
- expect(sut.base.exchange).toEqual('xyz');
13
+ expect(sut.base.adapter).toEqual('xyz');
14
14
  expect(sut.quote.name).toEqual('def');
15
- expect(sut.quote.exchange).toEqual('xyz');
15
+ expect(sut.quote.adapter).toEqual('xyz');
16
16
  expect(sut.toString()).toEqual('xyz:abc-def');
17
17
  });
18
18
  });
@@ -22,9 +22,9 @@ describe('instrument selector tests', () => {
22
22
  const sut = instrumentOf('xyz:abc-def');
23
23
 
24
24
  expect(sut.base.name).toEqual('abc');
25
- expect(sut.base.exchange).toEqual('xyz');
25
+ expect(sut.base.adapter).toEqual('xyz');
26
26
  expect(sut.quote.name).toEqual('def');
27
- expect(sut.quote.exchange).toEqual('xyz');
27
+ expect(sut.quote.adapter).toEqual('xyz');
28
28
  expect(sut.toString()).toEqual('xyz:abc-def');
29
29
  });
30
30
 
@@ -32,9 +32,9 @@ describe('instrument selector tests', () => {
32
32
  const sut = instrumentOf('XYZ:ABC-DEF');
33
33
 
34
34
  expect(sut.base.name).toEqual('abc');
35
- expect(sut.base.exchange).toEqual('xyz');
35
+ expect(sut.base.adapter).toEqual('xyz');
36
36
  expect(sut.quote.name).toEqual('def');
37
- expect(sut.quote.exchange).toEqual('xyz');
37
+ expect(sut.quote.adapter).toEqual('xyz');
38
38
  expect(sut.toString()).toEqual('xyz:abc-def');
39
39
  });
40
40
 
@@ -62,7 +62,7 @@ describe('instrument selector tests', () => {
62
62
  expect(fn).toThrow(Error);
63
63
  });
64
64
 
65
- test('should throw invalid format message for missing exchange name', () => {
65
+ test('should throw invalid format message for missing adapter name', () => {
66
66
  const fn = () => {
67
67
  assetOf(':abc-def');
68
68
  };
@@ -9,9 +9,9 @@ export class InstrumentSelector {
9
9
  readonly base: AssetSelector;
10
10
  readonly quote: AssetSelector;
11
11
 
12
- constructor(base: string, quote: string, exchange: string) {
13
- this.base = new AssetSelector(base.toLowerCase(), exchange.toLowerCase());
14
- this.quote = new AssetSelector(quote.toLowerCase(), exchange.toLowerCase());
12
+ constructor(base: string, quote: string, adapter: string) {
13
+ this.base = new AssetSelector(base.toLowerCase(), adapter.toLowerCase());
14
+ this.quote = new AssetSelector(quote.toLowerCase(), adapter.toLowerCase());
15
15
 
16
16
  this.id = `${this.base.toString()}-${this.quote.name}`;
17
17
  }
@@ -31,10 +31,10 @@ export class Instrument extends InstrumentSelector implements Component {
31
31
  leverage?: number = null;
32
32
 
33
33
  constructor(readonly base: Asset, readonly quote: Asset, readonly raw: string) {
34
- super(base.name, quote.name, base.exchange);
34
+ super(base.name, quote.name, base.adapter);
35
35
 
36
- if (base.exchange != quote.exchange) {
37
- throw new Error('Exchange mismatch!');
36
+ if (base.adapter != quote.adapter) {
37
+ throw new Error('Adapter mismatch!');
38
38
  }
39
39
  }
40
40
  }
@@ -11,7 +11,7 @@ export class Orderbook implements Component {
11
11
  bestAskQuantity: number;
12
12
  bestBidRate: number;
13
13
  bestBidQuantity: number;
14
- az;
14
+
15
15
  get midRate(): number {
16
16
  return this.instrument.quote.fixed((this.bestAskRate + this.bestBidRate) / 2);
17
17
  }
package/src/ipc.ts CHANGED
@@ -79,7 +79,7 @@ export class IpcBacktestCommand implements IpcCommand {
79
79
  @event
80
80
  export class IpcUniverseQuery implements IpcCommand {
81
81
  type = 'universe';
82
- exchange: string;
82
+ adapter: string;
83
83
  }
84
84
 
85
85
  /**
@@ -233,7 +233,7 @@ class IpcHandler extends Topic<{ type: string }, IpcSessionAccessor> {
233
233
  this.notify({ type: 'feed:started' });
234
234
 
235
235
  await accessor.session.aggregate.dispatch(
236
- instrument.base.exchange,
236
+ instrument.base.adapter,
237
237
  new AdapterFeedCommand(
238
238
  instrument,
239
239
  command.from,
@@ -151,12 +151,12 @@ export class Session {
151
151
  const grouped = instrument
152
152
  .filter(it => it != null)
153
153
  .reduce((aggregate, it) => {
154
- const exchange = it.base.exchange;
154
+ const adapter = it.base.adapter;
155
155
 
156
- if (aggregate[exchange]) {
157
- aggregate[exchange].push(it);
156
+ if (aggregate[adapter]) {
157
+ aggregate[adapter].push(it);
158
158
  } else {
159
- aggregate[exchange] = [it];
159
+ aggregate[adapter] = [it];
160
160
  }
161
161
 
162
162
  return aggregate;
@@ -176,7 +176,7 @@ export class Session {
176
176
  await Promise.all(
177
177
  orders.map(it =>
178
178
  this.aggregate.dispatch<AdapterOrderOpenCommand, void>(
179
- it.instrument.base.exchange,
179
+ it.instrument.base.adapter,
180
180
  new AdapterOrderOpenCommand(it)
181
181
  )
182
182
  )
@@ -188,7 +188,7 @@ export class Session {
188
188
  */
189
189
  cancel(order: Order): Promise<void> {
190
190
  return this.aggregate.dispatch(
191
- order.instrument.base.exchange,
191
+ order.instrument.base.adapter,
192
192
  new AdapterOrderCancelCommand(order)
193
193
  );
194
194
  }
@@ -375,7 +375,7 @@ export class Session {
375
375
  switchMap(() =>
376
376
  from(
377
377
  this.aggregate.dispatch<AdapterHistoryQuery, Candle[]>(
378
- selector.base.exchange,
378
+ selector.base.adapter,
379
379
  new AdapterHistoryQuery(selector, timeframe, length)
380
380
  )
381
381
  )
@@ -23,7 +23,7 @@ export function InstrumentPatchEventHandler(event: InstrumentPatchEvent, state:
23
23
  const selector = new InstrumentSelector(
24
24
  event.base.name,
25
25
  event.quote.name,
26
- event.base.exchange
26
+ event.base.adapter
27
27
  );
28
28
 
29
29
  let instrument = state.universe.instrument[selector.toString()];