Skip to content

Cumulative amount of events will trigger fraud detection #396

@jaballe

Description

@jaballe

Hello,

How do I create a rule that can detect that sums up the amount of x number of events and if it hits a certain number threshold, it will be detected for example:
like so
with ruleset('accumulated_fraud_detection'):
@when_all(accumulate(amount_sum=lambda ev: ev.amount) > 1000)
def fraud_detected(c):
print('Fraud detected! Total amount: {0}'.format(c.events[-1].amount))

post('evnt_amount', { 'amount': 100 })
 post('evnt_amount', { 'amount': 200 })

post('evnt_amount', { 'amount': 500 })
post('evnt_amount', { 'amount': 100 })
post('evnt_amount', { 'amount': 101})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions