Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fCondition #10

Open
Camilo-Mora opened this issue Jul 4, 2021 · 2 comments
Open

fCondition #10

Camilo-Mora opened this issue Jul 4, 2021 · 2 comments

Comments

@Camilo-Mora
Copy link

great work with this package.

May I ask if it is possible to include more than one condition in your fCondition function?

For instance, in a trailing stop order, could it be possible to use a different trailing offset for say two or more given prices?...

say, I go long at $10 and, place a trailing stop 1% below. can one set a conditional second trailing stop at 0.5%, when price is above $11?

this could make your function very useful to adjusts offset values, when there is a strong trending, like explained here

@lbilli
Copy link
Owner

lbilli commented Jul 4, 2021

Thanks for the feedback.
The function fCondition() is just a simple helper that creates a template condition that can be customized and attached to an order.

The supported condition types are the ones made available by IB and are listed here.
The way conditions can be attached to orders in TWS is demonstrated in this video.

Similar tasks can be accomplished with this package: here's an example of how to attach two conditions (Price AND Time) to an order:

# Condition 1: price of AAPL > 200
cond1 <- fCondition("Price")
cond1$conId    <- 265598L
cond1$exchange <- "SMART"
cond1$is_more  <- TRUE
cond1$value    <- 200
cond1$conjunction <- "a"         # AND

# Condition 2: time > Jul 6 15:00
cond2 <- fCondition("Time")
cond2$is_more <- TRUE
cond2$value   <- "20210706 15:00:00 EDT"

# Attach to order
order$conditions <- list(cond1, cond2)

@Camilo-Mora
Copy link
Author

wow, this is really something....i can see this function being automatized to ride the waves up and down a price trend... excellent function...thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants