> If I understand the flow correctly - you decide on a trade in your > onBookSnapshot() function inside your Strategy class.
Correct. > in that point you set the position member with a desired number. > a little after that trade() function of PositionManager take the > position member and decide of the quantity to trade (buy or sell) > int quantity = newPosition - position; > Yes. > 1. position means how many lots you'd like to buy? or is it the exact > amount in $ of the position (I haven't seen in the code any reference > to actual amount..) > Yes, you set the number of of contracts/shares that you want to be long or short. > 2. If I want to do nothing in a snapshot cycle (not to trade) - just > don't use setPosition() function ? (to get quantity=0 ?) - I saw that > if I do setPosition(0) - it opens me more positions (quantity = 0 - > position != 0 ....) - so I guess the right way is don't use the > setPosition() function? > The setPosition(int quantity) method sets the size of the long and short position. It's NOT the indication of how many contracts/shares to buy/sell on every 1-second cycle. The decision to buy/sell is made elsewhere in the framework, which you don't need to think about. The bottom line is, your code in onBookSnapshot() should describe when to be long, short, and flat. If your strategy is long, and the conditions to switch to either "short" or "flat" position have not been met, your strategy would continue to hold the same long position. Does that answer the question? -- You received this message because you are subscribed to the Google Groups "JBookTrader" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jbooktrader?hl=en.
