buyAmount

Generates a new buy order

(buy {asset} amount options?)

Returns

The buy function returns an order object containing information about the buy action. If the order is not generated due to existing open positions, it may return null

Parameters

{asset} (asset) - asset to be bought

amount (number) - amount to be bought

options (optional, object) - round: only hole shares - target: checks openPositions and generates order to balance portfolio

Examples

(buyAmount {AAPL} 200)            ;; buys 1.29 shares of AAPL if price is 155
;;=> order {symbol: "AAPL", action: "buy", units: 1.29, ....}

(buyAmount {AAPL} 200 {round: true})    ;; buys 1 shares of AAPL if price is 155
;;=> order {symbol: "AAPL", action: "buy", units: 1, ....}

Was this helpful?