Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tags data/column to TradeService and ColumnFilteringPanel grid #712

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion client-app/src/core/columns/Trades.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {ExcelFormat, localDateCol} from '@xh/hoist/cmp/grid';
import {ExcelFormat, localDateCol, tags} from '@xh/hoist/cmp/grid';
import {dateRenderer, millionsRenderer, numberRenderer, fmtNumberTooltip} from '@xh/hoist/format';
import {ColumnSpec} from '@xh/hoist/cmp/grid';

Expand Down Expand Up @@ -56,6 +56,17 @@ export const tradeDateCol: ColumnSpec = {
chooserDescription: 'Date of last trade (including related derivatives)'
};

export const tagsCol: ColumnSpec = {
...tags,
field: {
name: 'tags',
type: 'tags',
displayName: 'Tags'
},
width: 210,
chooserDescription: 'Tags associated with this trade'
};

export const dayOfWeekCol: ColumnSpec = {
field: {
name: 'trade_date',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
cityCol,
companyCol,
profitLossCol,
tagsCol,
tradeDateCol,
tradeVolumeCol
} from '../../../core/columns';
Expand Down Expand Up @@ -54,7 +55,8 @@ export class ColumnFilteringPanelModel extends HoistModel {
cityCol,
tradeVolumeCol,
profitLossCol,
tradeDateCol
tradeDateCol,
tagsCol
]
});
}
Expand All @@ -72,7 +74,8 @@ export class ColumnFilteringPanelModel extends HoistModel {
{
field: 'trade_volume',
valueRenderer: millionsRenderer({precision: 1, label: true})
}
},
'tags'
]
});
}
Expand Down
4 changes: 3 additions & 1 deletion grails-app/services/io/xh/toolbox/data/TradeService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ class TradeService extends BaseService {
try {
def mockData = applicationContext.getResource('classpath:MockTradesData.json'),
trades = JSONParser.parseArray(mockData.inputStream),
dateRange = 30
dateRange = 30,
tagRange = 5

trades.each {it ->
it.profit_loss = Math.round(it.profit_loss * Math.random())
it.trade_volume = it.trade_volume * 1000000
it.active = it.trade_volume.toBigInteger() % 6 == 0
it.trade_date = LocalDate.now().minusDays(Math.round(dateRange * Math.random()))
it.tags = (0..Math.floor(tagRange * Math.random())).findAll { it > 0 }.collect { 'tag' + it}
}

ret = [
Expand Down
Loading