Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.

Commit d52dcc1

Browse files
committed
feat: filter active symbols function
1 parent 6da7c1b commit d52dcc1

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

src/assetindex/assetIndex.es6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const initTable = () => {
8282

8383
function populateTable(result) {
8484
const active_symbols_data = local_storage.get('active_symbols');
85-
const filtered_active_symbols = active_symbols_data.filter(item => !isRestrictedSymbol(item.symbol))
85+
const filtered_active_symbols = filterRestrictedSymbols(active_symbols_data);
8686
const asset_index_data = [...result[0].asset_index];
8787

8888
if($.isEmptyObject(filtered_active_symbols) && $.isEmptyObject(asset_index_data)) return;

src/common/util.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
function isRestrictedSymbol(symbol) {
2-
return /^(BOOM|CRASH|STEP).+/i.test(symbol)
1+
function filterRestrictedSymbols(active_symbols) {
2+
return active_symbols.filter(function(item) { return !/^(BOOM|CRASH|STP).+/i.test(item.symbol)});
33
}
44

55
function isTick(ohlc) {

src/instruments/instruments.es6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function refresh_active_symbols() {
1515
const active_symbols = [];
1616
const active_markets = _(data.active_symbols).groupBy('market').map(function(symbols) {
1717

18-
const filtered_symbols = symbols.filter(item => !isRestrictedSymbol(item.symbol))
18+
const filtered_symbols = filterRestrictedSymbols(symbols)
1919

2020
const sym = _.head(filtered_symbols);
2121

src/navigation/menu.es6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const extractFilteredMarkets = (trading_times_data, options) => {
4545

4646
export const extractChartableMarkets = (trading_times_data) => {
4747
return extractFilteredMarkets(trading_times_data, {
48-
filter: (sym) => (sym.feed_license !== 'chartonly') && !isRestrictedSymbol(sym.symbol)
48+
filter: (sym) => (sym.feed_license !== 'chartonly')
4949
}) || [];
5050
};
5151

src/trade/tradeMenu.es6

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const refresh_active_symbols = () => {
1515
.then((data) => {
1616
/* clean up the data! */
1717
let markets = _(data.active_symbols).groupBy('market').map((symbols) => {
18-
const filtered_symbols = symbols.filter(item => !isRestrictedSymbol(item.symbol))
18+
const filtered_symbols = filterRestrictedSymbols(symbols);
1919
const sym = _.head(filtered_symbols);
2020
const market = { name: sym.market, display_name: sym.market_display_name };
2121
market.submarkets = _(filtered_symbols).groupBy('submarket').map((symbols) => {

src/tradingtimes/tradingTimes.es6

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,7 @@ const processData = (markets) => {
5050
submarket_names[market.display_name] = [];
5151
market.submarkets.forEach(
5252
(submarket) => {
53-
if (!isRestrictedSymbol(submarket.name)) {
54-
5553
submarket_names[market.display_name].push(submarket.display_name)
56-
}
5754
}
5855
)
5956
});
@@ -152,18 +149,21 @@ const initTradingWin = ($html) => {
152149
const refresh = (data) => {
153150
const result = processData(menu.extractFilteredMarkets(data[0]));
154151
const active_symbols = local_storage.get('active_symbols');
155-
let header = getObjectMarketSubmarkets(active_symbols);
156-
const markets_sorted_list = getSortedMarkets(active_symbols);
152+
const filtered_symbols = filterRestrictedSymbols(active_symbols)
153+
let header = getObjectMarketSubmarkets(filtered_symbols);
154+
const markets_sorted_list = getSortedMarkets(filtered_symbols);
157155

158156
if($.isEmptyObject(header)) return;
159157

160158
function changed() {
161159
const val = $(this).val();
162-
header = getObjectMarketSubmarkets(local_storage.get('active_symbols'));
160+
const new_active_symbols = local_storage.get('active_symbols');
161+
const new_filtered_symbols = filterRestrictedSymbols(new_active_symbols)
162+
header = getObjectMarketSubmarkets(new_filtered_symbols);
163163

164164

165165
if (header[val]) {
166-
const cumulative_submarkets = Object.keys(header[val]).filter(item => !isRestrictedSymbol(item))
166+
const cumulative_submarkets = Object.keys(header[val])
167167
submarket_names.update_list(getSortedSubmarkets(cumulative_submarkets))
168168
};
169169

0 commit comments

Comments
 (0)