sthewissen / Mynt

An Azure Functions-based crypto currency trading bot; featuring 10 exchanges, 25 indicators, custom strategy support, backtester and more
BSD 3-Clause "New" or "Revised" License
237 stars 129 forks source link

PaperTrade dont fill #59

Closed LORDofDOOM closed 6 years ago

LORDofDOOM commented 6 years ago

I don't know if PaperTrade is a WIP, but should a "PaperTrade" order not always be filled (buy) to get results for proper testing ?

Currently it will get cleaned/canceled with "CancelUnboughtOrders()" because there is no fill.

sthewissen commented 6 years ago

The idea behind the PaperTradeManager is that it mimics the LiveTradeManager as close as possible to get an idea of what is bought and what isn't. Since no actual orders are placed on an exchange this is obviously not entirely possible. However, just like on an actual exchange your orders may not always be filled. Since you have a few different options when placing a buy order (to buy it for a lower price than the current price) it checks if the price you put the order on got hit after it was placed.

LORDofDOOM commented 6 years ago

Thank you for your fast answer.

I know that there is no "real" fill made, but on other bots a "PaperTrade" is just filled with current value to test e.g. weekly performance or stop loss triggers.

In our current case I see that the bot want to buy on a strategy but because the order is not filled I cant check exit strategies or triggers.

sthewissen commented 6 years ago

Hmm ok, I get your point. The behavior you're describing seems to be somewhere between what the Backtester does and what the current paper trader does. We could probably introduce a boolean in the paper trader constructor that toggles either insta buying or checking the market for an actual order being hit?

twixwix commented 6 years ago

I saw this behavior too wouöd be a good solution to fill or check the market

LORDofDOOM commented 6 years ago

To make things less complicated I think the fastest solution is to set the fill to last candle price. Thats not exactly accurate but we can test strategy triggers for sell and trailing stop loss.

Thank you for look into this :-)

sthewissen commented 6 years ago

Just pushed a commit to develop that should include this behavior. You can give a new enum value called OrderBehavior.AlwaysFill to the PaperTradeManager constructor. This ensures that your order will be filled within the next SellTimer check :)

LORDofDOOM commented 6 years ago

Great - Thank you

I'll give this a try ASAP :-)

sthewissen commented 6 years ago

@LORDofDOOM Did you manage to get around to testing this?

twixwix commented 6 years ago

It works fine I tested it.

sthewissen commented 6 years ago

I'll close this for now, if there's something wrong we can create a new issue.