@ex-master/core
Advanced tools
Comparing version 0.3.29 to 0.3.30
@@ -13,2 +13,3 @@ import { Dashboard } from './dashboard'; | ||
private moneyKeyWeightDict; | ||
private markets; | ||
private symbolSet; | ||
@@ -19,2 +20,3 @@ private symbolToMarketPriceMap; | ||
initialize(): Promise<void>; | ||
getTradingMarkets(currency: string): Market[]; | ||
getQuoteCurrencyWeight(quoteCurrency: string): number; | ||
@@ -21,0 +23,0 @@ getPrice(market: Market): number | undefined; |
@@ -7,2 +7,3 @@ "use strict"; | ||
const decimal_js_1 = tslib_1.__importDefault(require("decimal.js")); | ||
const lodash_1 = tslib_1.__importDefault(require("lodash")); | ||
const memorize_decorator_1 = tslib_1.__importDefault(require("memorize-decorator")); | ||
@@ -20,2 +21,3 @@ const v = tslib_1.__importStar(require("villa")); | ||
this.moneyKeyWeightDict = {}; | ||
this.markets = []; | ||
this.symbolSet = new Set(); | ||
@@ -49,2 +51,11 @@ this.symbolToMarketPriceMap = new Map(); | ||
} | ||
getTradingMarkets(currency) { | ||
let markets = []; | ||
for (let market of this.markets) { | ||
if (market.stock === currency || market.money === currency) { | ||
markets.push(market); | ||
} | ||
} | ||
return markets; | ||
} | ||
getQuoteCurrencyWeight(quoteCurrency) { | ||
@@ -70,2 +81,3 @@ return this.moneyKeyWeightDict[quoteCurrency] || 0; | ||
return tslib_1.__awaiter(this, void 0, void 0, function* () { | ||
let markets = []; | ||
let moneyKeySet = new Set(); | ||
@@ -84,2 +96,3 @@ let symbolSet = new Set(); | ||
symbolSet.add(symbol); | ||
markets.push(market); | ||
} | ||
@@ -106,2 +119,3 @@ } | ||
}, this.moneyKeyWeightDict); | ||
this.markets = lodash_1.default.uniqWith(markets, lodash_1.default.isEqual); | ||
this.moneyKeys.length = 0; | ||
@@ -212,3 +226,3 @@ this.moneyKeys.push(...moneyKeys); | ||
function getMarketSymbol({ stock, money }) { | ||
return `${stock}${money}`; | ||
return `${stock}-${money}`; | ||
} | ||
@@ -215,0 +229,0 @@ function startOfMinute(timestamp) { |
{ | ||
"name": "@ex-master/core", | ||
"version": "0.3.29", | ||
"version": "0.3.30", | ||
"main": "bld/library/index.js", | ||
@@ -27,3 +27,3 @@ "types": "bld/library/index.d.ts", | ||
}, | ||
"gitHead": "337ef43c642b9948a1f5f2d936b5e7b1d040704f" | ||
"gitHead": "aba2f9e65b6644a7cda711d5a278db986cb2cc3f" | ||
} |
import {Cache} from '@ex-master/utilities/cache'; | ||
import Decimal from 'decimal.js'; | ||
import _ from 'lodash'; | ||
import memorize from 'memorize-decorator'; | ||
@@ -25,2 +26,3 @@ import {Dict} from 'tslang'; | ||
private markets: Market[] = []; | ||
private symbolSet = new Set<string>(); | ||
@@ -68,2 +70,14 @@ private symbolToMarketPriceMap = new Map<string, number>(); | ||
getTradingMarkets(currency: string): Market[] { | ||
let markets: Market[] = []; | ||
for (let market of this.markets) { | ||
if (market.stock === currency || market.money === currency) { | ||
markets.push(market); | ||
} | ||
} | ||
return markets; | ||
} | ||
getQuoteCurrencyWeight(quoteCurrency: string): number { | ||
@@ -104,2 +118,3 @@ return this.moneyKeyWeightDict[quoteCurrency] || 0; | ||
private async tick(): Promise<void> { | ||
let markets: Market[] = []; | ||
let moneyKeySet = new Set<string>(); | ||
@@ -122,2 +137,4 @@ let symbolSet = new Set<string>(); | ||
symbolSet.add(symbol); | ||
markets.push(market); | ||
} | ||
@@ -147,2 +164,3 @@ } | ||
this.markets = _.uniqWith(markets, _.isEqual); | ||
this.moneyKeys.length = 0; | ||
@@ -320,3 +338,3 @@ this.moneyKeys.push(...moneyKeys); | ||
function getMarketSymbol({stock, money}: Market): string { | ||
return `${stock}${money}`; | ||
return `${stock}-${money}`; | ||
} | ||
@@ -323,0 +341,0 @@ |
Sorry, the diff of this file is not supported yet
67493
1480