position-tracer
position-tracer is a tool for dumping Ember positions in CSV format. Given a projection path, it reads the Ember journal and shows how a position changes after each trade or position reset/snapshot message.
Like most Ember tools, position-tracer relies on the EMBER_HOME environment variable (and optionally EMBER_WORK) to locate Ember configuration and journal files.
Ember uses the average cost method for position calculation.
The first output line contains the CSV header with the following fields:
- Action — either
TRADEorRESET(position snapshot) - TradeSize — fill size of the trade reported on this line
- TradePrice — fill price of the trade reported on this line
- PositionQty — resulting position size after this trade
- PositionAvgCost — resulting average position cost after this trade
- PositionPnL — resulting profit or loss after this trade
In case of a position reset, TradeSize and TradePrice are omitted.
The tool takes instrument multipliers into account.
The current version does not handle inverse contracts.
Usage
The example below shows how the position of the BOT42 algorithm on COINBASE derivatives changed for the BTCZ25-M instrument:
/opt/deltix/ember/bin/position-tracer Source[BOT42]/Destination[COINBASED]/Symbol[BTCZ25-M]
Action,TradeSize,TradePrice,PositionQty,PositionAvgCost,PositionPnL
TRADE,0.025,25380.76,27939,5.47745915329203,0.0
TRADE,0.05,25380.76,27939,5.432047450066966,0.0
TRADE,0.00089472,27185.3,27939,5.341223556001341,0.0
TRADE,0.00089472,27185.3,27939,5.339482733798805,0.0
TRADE,0.00711206,27185.3,27939,5.337741911373276,0.0
TRADE,0.0089015,27185.3,27939,5.323904240776979,0.0
TRADE,0.0001,27185.3,27939,5.306584903480555,0.0
TRADE,0.017903,27185.3,27939,5.306390336851824,0.0
TRADE,0.014194,27185.3,27938,5.271557028419265,0.0
TRADE,0.05,27185.3,27938,5.243940142092587,0.0
TRADE,0.025,25385.56,27938,5.14665603178127,0.0
TRADE,0.025,25385.56,27938,5.14665603178127,0.0
TRADE,0.05,25385.56,27938,5.14665603178127,0.0
...
You can redirect output to CSV file.