mjj38
- ago
Is there a way to approach the following:

I have a strategy that generates 10 signals a day with 10% equity position in each. I manually exit those positions (market rallies a lot and I take the decision to close out those positions early intraday).

When I run the strategy to generate the next day signals I want the strategy to recognize that I no longer have those positions that were sold manually and generate 10 new signals.

Is there a way to accomplish this?
0
357
Solved
11 Replies

Reply

Bookmark

Sort
Glitch8
 ( 9.00% )
- ago
#1
You'd have to somehow let the Strategy know. One way would be a text file that you would use to notate the manual sells in some format that the Strategy could then read and act upon.
0
Best Answer
Cone8
 ( 26.80% )
- ago
#2
Wouldn't it be easier (like automatic) if you enable Preferences > Trading > Live Positions?
You must use the Strategy Monitor to generate the signals for this to work on a Portfolio.
1
Glitch8
 ( 9.00% )
- ago
#3
This doesn’t handle multiple positions for the same symbol well, Not sure if the positions in question are for the same or multiple symbols.
0
- ago
#4
Considering you're manually closing positions, then If you're not concerned about the actual prices of closing the trades for purposes of back tests, etc. in WL8, then you could use time of day in your strategy, or end of day. I guess it matters if you're scale is daily or intraday. If intraday, then sell at market if time of day is greater than say 15:00, to close them out. Then you have a clean slate for the next day. Only pitfall is if you really do want to hold a position overnight.
1
mjj38
- ago
#5
Thanks for the suggestions.

This led me to another question:
I know you retrieve account positions from the brokers, but does WL download or save trade history from the broker? That would allow me to query from the strategy and override the signal exits / positions.
0
Cone8
 ( 26.80% )
- ago
#6
QUOTE:
WL download or save trade history from the broker?
Some broker providers may have to download Trade History to find positions (I think TDA does that), but it's not saved to disk or otherwise accessible.

Your broker probably has a downloadable trade history you can more easily access.
0
Glitch8
 ( 9.00% )
- ago
#7
From what we’ve seen brokers don’t offer trade history via their apis.
0
mjj38
- ago
#8
Thanks guys. Are there public methods to query the current positions? It would be very easy to just look for the last bar, compare expected to actual positions and generate the correct number of signals.

I'll just track the performance of these discretionary decisions in a spreadsheet. See if I'm actually adding any value.

I tried coding up these exits but I hit a wall as it isn't based on any single trade but rather how the portfolio of positions are doing at a point in time.
0
Glitch8
 ( 9.00% )
- ago
#9
Yes, you can use SignalManager.FindBroker("Broker Name") to get an instance of the BrokerBase class.

BrokerBase b = SignalManager.FindBroker("Dummy Broker");

Then use that to get a BrokerAccount instance:

BrokerAccount ba = b.FindAccount"(AccountNumber");

Then use that to get positions (Positions property).
2
Cone8
 ( 26.80% )
- ago
#10
Check this post for more code -
https://www.wealth-lab.com/Discussion/Access-Accounts-data-from-broker-programmatically-7914

Scroll down to Post #18.
3
mjj38
- ago
#11
Thanks Guys. That was super helpful.
1

Reply

Bookmark

Sort