Learn R Programming

TickExec (version 1.1)

LimitSell: Execute Limit Sell Order

Description

(Try) to sell a given instrument at given date and time slot, by limit order. If limit price was not given, then use the last trading price as limit price. If both 'orderTo' and 'orderLast' was given, then the smaller one will be adopted.

Usage

LimitSell(dir = dir, date, dfLog, limitPrice = NA, orderFrom, orderTo = 150000, orderLast = 7 * 3600, costOut = 0.001, market = 'SHSZ')

Arguments

dir
The directory containing the Tick data.
date
the date for placing the order.
dfLog
The dataframe generated by buy-orders.
limitPrice
the limit price to sell.
orderFrom
time of the order being placed.
orderTo
time of the order being withdrawed.
orderLast
duration of the order, in seconds.
costOut
transaction cost for selling.
market
specifying the sub-function to call depending on the market.

Value

The same dataframe dfLog, with corresponding entries updated.

Examples

Run this code
## locate tick data directory ##
dir <- system.file("extdata", '', package = "TickExec")

## establish a posiyion to sell ##
dfLog = LimitBuy(dir = dir, date = 20141013, ticker = 000001, capital = 1e6, 
                 limitPrice = NA, orderFrom = 94545, orderLast = 600, 
                 costIn = 0.001, , market = 'SHSZ')

## sell ##
dfLogSold = LimitSell(dir = dir, date = 20141013, dfLog = dfLog, limitPrice = 10.1, 
                      orderFrom = 142020, orderTo = 150000, costOut = 0.001, 
                      market = 'SHSZ') 
                       
## see result ##
dfLogSold

Run the code above in your browser using DataLab