Describe a process mathematically

45 Views Asked by At

I am simply wondering how to explain this process mathematically:

Lets say that we have a set $A_j$ of sets $B_i$ such that $A_j$ is the set off all $B_i$ where $i\leq j$

Now lets say that set $B_i$ is a set looking like this: {Date i,Position,Price, Volume}.

I want to have a function that maps this set A to another set U.

Now this mapping is a bit strange because what I want to happen is that if b is a element of $B_i$, then the function should provide $B_i$, ($f(B_i)=B_i$), However if s is a element of $B_i$, then I want to get $B_i$={Date I, Sell, Volumeweighted price of all previous output of this function,-Volume}

It almost becomes a piecewise function f(x) where input becomes output for all buys but as soon as you get f(s),for sell we assign a volume weighted price of our previous buys and or sells.

Hence the function should map this

Buy 5 @ 10 -> Buy 5 @ 10

Buy 5 @ 20 -> Buy 5 @ 20

Sell 5@ 20 -> Sell 5 @ (10*5+20*5)/10

Buy 5@ 10 -> Buy 5@ 10

Sell 5@ Any Value Given market value -> Sell 5@ 12.5