-
Notifications
You must be signed in to change notification settings - Fork 7
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
add create_bracket_order() #14
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, couple of minor things
"extended_hours" => extended_hours, | ||
"order_class" => order_class, | ||
"take_profit" => Dict("limit_price" => tp_limit_price), | ||
"stop_loss" => Dict("stop_price" => sl_stop_price, "limit_price" => sl_limit_price)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error is thrown as these aren't passed into the function.
They don't need to be passed into the function, the tp/sl params are used in the bracket function.
Also duplication of code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will check - intention was if order_class=nothing
it was the normal orders up to this point and if it was specified then would revert to the ifelse statement in the function. order_class="bracket"
along with an assertion in utils : @assert order_class in ["simple", "bracket", "oco ", "oto"] "valid order class :: simple, bracket, oco, oto"
. i did this so that we could do a dict within dict for the tp,sl of these order types. i will verify what happened here. ok i realized where the error was solved see below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_order_params()
repaired and now should be able to extend to "bracket", "oco ", "oto"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_bracket_order(symbol="AAPL", side = "buy", qty = 1, time_in_force = "day", type = "limit", limit_price = 196.00, tp_limit_price=196.10, sl_stop_price=194.00, sl_limit_price = 193.60)
for brackets tested a few ways of executing the 'parent' order - market, limit and stop limit.
enter with limit order using bracket.
and if wish to enter on a stop limit bracket order::
create_bracket_order(symbol="AAPL", side = "buy", qty = 1, time_in_force = "day", type = "stop_limit", limit_price = 196.00, stop_price = 196.10, tp_limit_price=196.50, sl_stop_price=194.00, sl_limit_price = 193.60)
"qty" => 1
"extended_hours" => false
"limit_price" => 196.0
"symbol" => "AAPL"
"stop_loss" => Dict("limit_price"=>193.6, "stop_price"=>194.0)
"take_profit" => Dict("limit_price"=>196.5)
"order_class" => "bracket"
"stop_price" => 196.1
"side" => "buy"
"time_in_force" => "day"
"type" => "stop_limit"
src/positions.jl
Outdated
@@ -36,7 +36,7 @@ function get_positions(symbol::String)::DataFrame | |||
return resdf | |||
end | |||
|
|||
function get_positions()::DataFrame | |||
function get_all_positions()::DataFrame |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need two function names to do the same thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
k intent was to cater to ALL positions as well as a singular symbol.
https://alpaca.markets/docs/api-references/trading-api/positions/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I can see they do different things but we can overload one function to do both things, get_positions() and get_positions("BTCUSD") both work as intended
Codecov Report
❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more. @@ Coverage Diff @@
## main #14 +/- ##
==========================================
- Coverage 44.37% 37.03% -7.34%
==========================================
Files 13 13
Lines 311 324 +13
==========================================
- Hits 138 120 -18
- Misses 173 204 +31
... and 5 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
extend existing
create_order_params()
to includesimple, bracket, oco or oto
orders. note embeddedDict()
withinDict()
within JSON body for the extra price fields.