util_plot2df: Line plot of portfolio metric (for a dataframe)

Description Usage Arguments Value Author(s) Examples

Description

Draws a new line plot using a a dataframe with one or many metric values.

Usage

1
2
3
4
5
6
7
8
9
util_plot2df(formula,
data,
title=NULL,
subtitle=NULL,
font_size=10,
line_size=1.2,
bw=FALSE,
axis.text.size=1.5,
title.size=2)

Arguments

formula

Formula that describes data titles to be plotted.

data

Dataframe with metric data. Dataframe must have a variable 'legend'. If you want to correctly display the time in POSIX format, name the variable as 'time'.

title

Plot title.

subtitle

Plot subtitle.

font_size

Baseline font size.

line_size

Line thickness.

bw

Black and white color scheme flag.

axis.text.size

Axis font size.

title.size

Title font size.

Value

plot

Author(s)

Kostin Andrey <andrey.kostin@portfolioeffect.com>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 
portfolio=portfolio_create(fromTime="2014-10-02 09:30:00", toTime="2014-10-02 16:00:00")
portfolio_settings(portfolio,resultsSamplingInterval='60s')
positionSPY=position_add(portfolio,'SPY',500)
positionC=position_add(portfolio,'C',600)
metricSPY=compute(log_return(positionSPY))[[1]]
metricSPY=data.frame(metricSPY,legend="SPY return")
util_plot2df(value~time,metricSPY,title="Return, SPY")

metricC=compute(log_return(positionC))[[1]]
metricC=data.frame(metricC,legend="C return")
metric=rbind(metricSPY,metricC)
util_plot2df(value~time,metric,title="Return")

data(aapl.data) 
data(goog.data) 
data(spy.data) 
AAPLprice=data.frame(Price=aapl.data[,'Value'],time=aapl.data[,'Time'],legend='AAPL price')
GOOGprice=data.frame(Price=goog.data[,'Value'],time=goog.data[,'Time'],legend='GOOG price')
SPYprice=data.frame(Price=spy.data[,'Value'],time=spy.data[,'Time'],legend='SPY price')
price=rbind(AAPLprice,GOOGprice,SPYprice)
util_plot2df(Price~time,price,title="Stock prices")

## End(Not run)

PortfolioEffectHFT documentation built on May 2, 2019, 11:52 a.m.