Trade

Models. Trade

The Trade class is used as a container for handing Trade related Operations

Constructor

new Trade(user, type, symbol, price, shares)

Parameters:
Name Type Description
user string

user who did this trade

type TradeType

Type of the trade ('B'|'S')

symbol string

The ticker symol for this trade

price number

The average amount per share for the trade

shares number

The number of shares traded

Source:

Members

amount

Stores amount in the Fixed point representation

Source:

Methods

(async) delete(tradeId)

Delete's a trade given it's concistent, it uses the same script of update and is anologus to updating the trades value to (BUY,0 stocks for 0 price)

Parameters:
Name Type Description
tradeId number
Source:

(async) order()

The order method executes an order for this constructor, it internally uses 2 separate calls depending on wether the trade was a BUY or SELL

Source:

(async) update(tradeId)

Given a TradeId it gives all the fields of trade to the backend, for this method the fields are optional and supports any combination of missing fields, it's strongly consistent and atomic and will raise errors on bad updates.

Parameters:
Name Type Description
tradeId number
Source: