3.12.4Framework.FormatVolume()

FormatVolume() formats a trading volume. By default, it reads the user's preferences in the MyTrader settings about whether volumes should be displayed as cash/units or lots. For example, volume of 20000 may be formatted as either "0.20 lots" or "20K".

Because lot-size conversion is market-specific, the FormatVolume() function requires an FXB.Instrument. For example:

var market = Framework.Instruments.get(instrumentId);

var text = Framework.FormatVolume(20000, market, {append_lots:true});

// For example, text = "0.20 lots"

FormatVolume() has three parameters:

Parameter

Description

volume

Volume to format - always, as standard in the framework, an amount in cash/units, not lots

instrument

FXB.Instrument object to use for the price formatting, or the instrumentId of an instrument. Only used in "lots" mode, and optional if you use the options to force "cash" mode.

options

See below

FormatVolume() is again a wrapper around FormatNumber(). You can use the full features of FormatNumber(), but typically you will only want to use the following properties in the options:

Option property

Description

mode

Defaults to the user's preference in the MyTrader settings. Can be overridden to either "lots" or "volume".

append_lots

Ignored in "volume" mode. In "lots" mode, returns the text as "X lots" rather than just "X".

show_plus

Same as for FormatNumber(): adds a + at the beginning of positive numbers. Typically used for values such as position net-volume where the value can be either positive or negative