position: position create an empty position Object

Description Usage Arguments Details Value Author(s)

View source: R/position.R

Description

A position object will store the details of trade opening, price, qty, closing etc. Once a position is opened, till close the same object can be carried forward for further operations.

checks if given object is position type/class

check if position is open/closed

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
position(instr = "default")

is.position(pos)

isopen(x)

## S3 method for class 'position'
isopen(pos)

isclosed(x)

## S3 method for class 'position'
isclosed(pos)

islong(x)

## S3 method for class 'position'
islong(pos)

isshort(x)

## S3 method for class 'position'
isshort(pos)

qty(x)

## S3 method for class 'position'
qty(pos)

## S3 method for class 'position'
posA + posB

## S3 method for class 'position'
posA - posB

get.positions.table(pf = "default")

get.positions.id(pf = "default")

incr.positions.id(pf = "default")

Arguments

instr

- instrument to be carried with position

pf

- default "default"

pf

- default "default"

pf

- default "default"

Details

position - Creates an empty position object

isclosed - gives TRUE if qty is zero and position is opened

islong - checks if position is long/short

isshort - checks if position is long/short

qty - Gives the quantity of a position, according to the direction of the position. Returns +ve qty if long, -ve otherwise

"+" - Quantities are added & openprice is averaged

"-" - only quantities are substracted

get.positions.table

get.positions.id

incr.positions.id

Value

returns position object

returns TRUE if position is opened, FALSE otherwise

returns the positions for each and every execution

returns the position id that is created currently. This is a global variable at portfolio level.

returns the position id that is created currently. Increments the old id by 1

Author(s)

Siva Sunku


sivasunku/rulesNtrades documentation built on May 29, 2019, 11 p.m.