uniVocity / univocity-trader

open-source trading framework for java, supports backtesting and live trading with exchanges
578 stars 140 forks source link

Buy/Sell signal with amount? #21

Closed brkr closed 4 years ago

brkr commented 4 years ago

First of all i love this project. Great work! (and sorry for my English! )

I need to buy/sell signal with amount. For example,

My Strategy : Price 1000$ -> Buy 100 (amount) if Price down 900$ -> Buy 200 (amount)

My target is reduce my avarage cost.

Is there any way achieve this strategy?

jbax commented 4 years ago

You can to provide your own implementation of the OrderManager interface, implement your login on the prepareOrder method to define what is the amount to buy/sell.

To allow for buying multiple times right now, comment out this condition. I'm going to make changes to how trades are processed later on to properly handle multiple buy orders on the same asset, so I'm leaving this issue open until this is ready.

Thanks a lot for using our project.

jbax commented 4 years ago

Ok so I made the bulk of the changes required to submit orders independently and even implemented the MartingaleSimulation which kind of does what you describe (basically doubles the position if lost a given percentage). The bulk of the logic for that to work is in the MartingaleStrategyMonitor.

Use this as a reference only. Don't try with real money as you will probably lose even though the simulation doesn't.

brkr commented 4 years ago

Great work! Thank you!