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

Commit

Permalink
Merge pull request #1539 from mustofa-binary/amam/remove_crash_boom
Browse files Browse the repository at this point in the history
amam/remove_crash_boom
  • Loading branch information
negar-binary authored Jan 20, 2021
2 parents c1d4bce + c1e128d commit 6fa4dbf
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 13 deletions.
8 changes: 5 additions & 3 deletions src/assetindex/assetIndex.es6
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import rv from 'common/rivetsExtra';
import 'jquery-growl';
import 'css!./assetIndex.css';
import { getObjectMarketSubmarkets, getSortedMarkets, getSortedSubmarkets } from '../common/marketUtils';
import 'common/util'

let table_el = null;
let asset_win_el = null;
Expand Down Expand Up @@ -81,12 +82,13 @@ const initTable = () => {

function populateTable(result) {
const active_symbols_data = local_storage.get('active_symbols');
const filtered_active_symbols = filterRestrictedSymbols(active_symbols_data);
const asset_index_data = [...result[0].asset_index];

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

state.dropdown.market_submarkets = getObjectMarketSubmarkets(active_symbols_data);
state.dropdown.sorted_markets = getSortedMarkets(active_symbols_data);
state.dropdown.market_submarkets = getObjectMarketSubmarkets(filtered_active_symbols);
state.dropdown.sorted_markets = getSortedMarkets(filtered_active_symbols);
state.table.asset_data = asset_index_data;

header_el = asset_win_el.parent().find('.ui-dialog-title').addClass('with-content');
Expand Down
4 changes: 4 additions & 0 deletions src/common/util.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
function filterRestrictedSymbols(active_symbols) {
return active_symbols.filter(function(item) { return !/^(BOOM|CRASH|STP).+/i.test(item.symbol)});
}

function isTick(ohlc) {
return ohlc.indexOf("t") !== -1;
}
Expand Down
8 changes: 6 additions & 2 deletions src/instruments/instruments.es6
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ function refresh_active_symbols() {
local_storage.set('active_symbols', data.active_symbols);
const active_symbols = [];
const active_markets = _(data.active_symbols).groupBy('market').map(function(symbols) {
const sym = _.head(symbols);

const filtered_symbols = filterRestrictedSymbols(symbols)

const sym = _.head(filtered_symbols);

const market = { name: sym.market, display_name: sym.market_display_name };
market.submarkets = _(symbols).groupBy('submarket').map(function(symbols) {
market.submarkets = _(filtered_symbols).groupBy('submarket').map(function(symbols) {
const sym = _.head(symbols);
const submarket = { name: sym.submarket, display_name: sym.submarket_display_name };
submarket.instruments = _.map(symbols, function(sym) {
Expand Down
5 changes: 3 additions & 2 deletions src/trade/tradeMenu.es6
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ const refresh_active_symbols = () => {
.then((data) => {
/* clean up the data! */
let markets = _(data.active_symbols).groupBy('market').map((symbols) => {
const sym = _.head(symbols);
const filtered_symbols = filterRestrictedSymbols(symbols);
const sym = _.head(filtered_symbols);
const market = { name: sym.market, display_name: sym.market_display_name };
market.submarkets = _(symbols).groupBy('submarket').map((symbols) => {
market.submarkets = _(filtered_symbols).groupBy('submarket').map((symbols) => {
const sym = _.head(symbols);
const submarket = { name: sym.submarket, display_name: sym.submarket_display_name };
submarket.instruments = _.map(symbols,(sym) => ({
Expand Down
22 changes: 16 additions & 6 deletions src/tradingtimes/tradingTimes.es6
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'jquery-growl';
import _ from 'lodash';
import moment from 'moment';
import { getObjectMarketSubmarkets, getSortedMarkets, getSortedSubmarkets } from '../common/marketUtils';
import 'common/util'

let table = null;
let tradingWin = null;
Expand Down Expand Up @@ -48,7 +49,9 @@ const processData = (markets) => {
market_names.push(market.display_name);
submarket_names[market.display_name] = [];
market.submarkets.forEach(
(submarket) => submarket_names[market.display_name].push(submarket.display_name)
(submarket) => {
submarket_names[market.display_name].push(submarket.display_name)
}
)
});

Expand All @@ -60,6 +63,7 @@ const processData = (markets) => {
// TODO: comeback and use lodash once 'trade module' changes got merged.
const market = markets.filter((m) => (m.display_name == marketname))[0];
const symbols = market && market.submarkets.filter((s) => (s.display_name == submarket_name))[0].instruments;

const rows = (symbols || []).map((sym) => {
return [
sym.display_name,
Expand Down Expand Up @@ -145,16 +149,22 @@ const initTradingWin = ($html) => {
const refresh = (data) => {
const result = processData(menu.extractFilteredMarkets(data[0]));
const active_symbols = local_storage.get('active_symbols');
let header = getObjectMarketSubmarkets(active_symbols);
const markets_sorted_list = getSortedMarkets(active_symbols);
const filtered_symbols = filterRestrictedSymbols(active_symbols)
let header = getObjectMarketSubmarkets(filtered_symbols);
const markets_sorted_list = getSortedMarkets(filtered_symbols);

if($.isEmptyObject(header)) return;

function changed() {
const val = $(this).val();
header = getObjectMarketSubmarkets(local_storage.get('active_symbols'));

if (header[val]) submarket_names.update_list(getSortedSubmarkets(Object.keys(header[val])));
const new_active_symbols = local_storage.get('active_symbols');
const new_filtered_symbols = filterRestrictedSymbols(new_active_symbols);
header = getObjectMarketSubmarkets(new_filtered_symbols);

if (header[val]) {
const cumulative_submarkets = Object.keys(header[val]);
submarket_names.update_list(getSortedSubmarkets(cumulative_submarkets));
};

updateTable(result, market_names.val(), submarket_names.val());
};
Expand Down

0 comments on commit 6fa4dbf

Please sign in to comment.