- ago
I have been unable to set transaction size for a Buy programmatically. For example:
CODE:
int Qty = 15; Transaction t = PlaceTrade (bars, TransactionType.Buy, OrderType.Market); . . . t.Quantity = Qty;


I think the reason may be because I am creating the transaction in the Execute() method and attempting to set the Quantity in the BacktestComplete() method. Is this reason it's not working?

I am trying to build a strategy that uses the performance of historical trades to determine allocation across symbols. I am running an algorithm on positions for each symbol to determine their performance. I am attempting to do all the calculations and allocations in BacktestComplete(). If this is not going to work, I'd appreciate any suggestions about how to reorganize the code into different methods. I'm thinking I may have to try moving stuff forward. But I need the positions list to do any calculations for allocations.

Assuming I assign "Transaction t" as a private global variable, would I be able to execute t.Quantity = n in another method that is not the same as the one where the transaction was placed, or must it be in the same method as PlaceTrade?
0
394
Solved
3 Replies

Reply

Bookmark

Sort
Glitch8
 ( 8.38% )
- ago
#1
Yes that's why it's not working. The BacktestComplete happens when ... wait for it ... the backtest has already completed!
0
Cone8
 ( 26.65% )
- ago
#2
QUOTE:
"Transaction t" as a private global variable, would I be able to execute t.Quantity = n in another method
Yes, but the PlaceTrade context needs to occur during PreExecute(), Execute(), or PostExecute().

If you feel like you're getting stuck on the project, consider the Concierge Support service to help move it along.
1
Best Answer
- ago
#3
Haha and thanks! Happy New Year to all!
0

Reply

Bookmark

Sort