public class Trade extends Object implements Serializable
orders
.
The exit order has the complement type of the entry order.Constructor and Description |
---|
Trade()
Constructor.
|
Trade(Order.OrderType startingType)
Constructor.
|
Trade(Order.OrderType startingType,
CostModel transactionCostModel,
CostModel holdingCostModel)
Constructor.
|
Trade(Order entry,
Order exit)
Constructor.
|
Trade(Order entry,
Order exit,
CostModel transactionCostModel,
CostModel holdingCostModel)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
Order |
getEntry() |
Order |
getExit() |
Num |
getHoldingCost()
Calculates the holding cost of the closed trade
|
Num |
getHoldingCost(int finalIndex)
Calculates the holding cost of the trade
|
Num |
getProfit()
Calculate the profit of the trade if it is closed
|
Num |
getProfit(int finalIndex,
Num finalPrice)
Calculate the profit of the trade.
|
Num |
getTradeCost()
Calculates the total cost of the closed trade
|
Num |
getTradeCost(int finalIndex)
Calculates the total cost of the trade
|
int |
hashCode() |
boolean |
isClosed() |
boolean |
isNew() |
boolean |
isOpened() |
Order |
operate(int index)
Operates the trade at the index-th position
|
Order |
operate(int index,
Num price,
Num amount)
Operates the trade at the index-th position
|
String |
toString() |
public Trade()
public Trade(Order.OrderType startingType)
startingType
- the starting order type
of the trade
(i.e. type of the entry order)public Trade(Order.OrderType startingType, CostModel transactionCostModel, CostModel holdingCostModel)
startingType
- the starting order type
of the
trade (i.e. type of the entry order)transactionCostModel
- the cost model for transactions of the assetholdingCostModel
- the cost model for holding asset (e.g. borrowing)public Order operate(int index)
index
- the bar indexpublic Order operate(int index, Num price, Num amount)
index
- the bar indexprice
- the priceamount
- the amountpublic boolean isClosed()
public boolean isOpened()
public boolean isNew()
public Num getProfit()
public Num getProfit(int finalIndex, Num finalPrice)
finalIndex
- the index of the final bar to be considered (if trade is
open)finalPrice
- the price of the final bar to be considered (if trade is
open)public Num getTradeCost(int finalIndex)
finalIndex
- the index of the final bar to be considered (if trade is
open)public Num getTradeCost()
public Num getHoldingCost()
public Num getHoldingCost(int finalIndex)
finalIndex
- the index of the final bar to be considered (if trade is
open)Copyright © 2014–2019. All rights reserved.