Position data & service

Classes used to manage positions

Data.

Package position

PositionCreationResultDTO.

PositionCreationResultDTO is returned after a position is created. It contains either the position id or the error message.

Field

Description

positionId

Position ID (filled if order creation is successful).

orderId

Order ID (filled if order creation is successful).

errorMessage

Error message (filled if position creation failed).

exception

Exception (filled if position creation failed).

successful

Indicates if the position creation was successful or not.

PositionDTO.

PositionDTO is the amount of a security, commodity or currency which is owned by an individual, dealer, institution, or other fiscal entity

Field

Description

id

An identifier that uniquely identifies the position.

status

Position status.

rules

Position rules.

openOrderId

The order id that opened the position.

openTrade

The trade that opened the position.

closeOrderId

The order id that closed the position.

closeTrade

The trade that closed the position.

lastCalculatedGain

Last calculated gain from the last ticker received.

lowestPrice

Lowest price for this position. You can get the corresponding gain with getLowestCalculatedGain()

highestPrice

Highest price for this position. You can get the corresponding gain with getHighestCalculatedGain()

PositionDTO also have a getGain()method that returns the gain you made with this position (if the position is closed of course). If the position is not closed, you can get the lastest potential gain calculated from the last ticker with the getLastestCalculatedGain() method.

PositionRulesDTO.

PositionRulesDTO is used by Cassandre trading bot to know if it should close a position.

Field

Description

stopGainPercentageSet

Stop gain percentage has been set.

stopGainPercentage

Stop gain percentage.

stopLossPercentageSet

Stop loss percentage has been set.

stopLossPercentage

Stop loss percentage.

PositionStatusDTO.

PositionStatusDTO describes the different status of a position.

Value

Description

OPENING

A position has been created, a buy order has been made but not yet completed.

OPENED

The buy order has been accepted.

CLOSING

A sell order has been made but not yet completed.

CLOSED

The sell order has been accepted.

Service.

PositionService.

PositionService and its implementation.

Method

Description

getPositions()

Get positions.

getPositionById()

Get position by id.

createPosition()

Creates a position with its associated rules.

tickerUpdate()

Method called by streams at every ticker update.

tradeUpdate()

Method called by streams on every trade update.

restorePosition()

Used by Cassandre to restore position after restart.

backupPosition()

Used by Cassandre to backup positions to database.