Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exchange.market_order requires a price ? #52

Open
asmodehn opened this issue Jul 10, 2019 · 4 comments
Open

exchange.market_order requires a price ? #52

asmodehn opened this issue Jul 10, 2019 · 4 comments

Comments

@asmodehn
Copy link
Contributor

I was wondering what was the logic behind requiring a price for a market order here :
https://github.com/garethdmm/gryphon/blob/master/gryphon/execution/harness/exchange_coordinator.pyx#L247

As far as I understand, market orders take the current market price, so requiring one in the API is useless/confusing...

@garethdmm
Copy link
Owner

garethdmm commented Jul 10, 2019

This is likely because market_order(mode, volume) doesn't have a reasonable default implementation in ExchangeAPIWrapper yet. Individual integrations can override it if their exchange does have a market order order type, but we just haven't coded the default such that it'll work on any exchange.

Such an implementation would be as simple as: get current orderbook, get price quote for desired volume, place limit order at that price. Here's where it would go:

def market_order(self, mode, volume):
"""
Place a market order on the exchange.
"""
return self.place_order(mode, volume, order_type=order_types.MARKET_ORDER)

@asmodehn
Copy link
Contributor Author

Thanks I ll have a look at that eventually, I'm in need of more order types and need to understand this part better...

@asmodehn
Copy link
Contributor Author

Hmmm, I might be wrong but it looks like even if the exchange integration has different order methods following the api_wrapper design, it will not be called by the coordinator ?

Looks like both market_order() and limit_order() from the exchange are calling the place_order() from the exchange api integration :
https://github.com/garethdmm/gryphon/blob/master/gryphon/execution/harness/exchange_coordinator.pyx#L355

Maybe this needs some careful api changes if one is to implement more order types (market without price, stop loss are the ones I'm missing currently...)

@asmodehn
Copy link
Contributor Author

This might also be an opportunity to check and get closer to what ccxt does : https://github.com/ccxt/ccxt/blob/master/python/ccxt/base/exchange.py#L1608

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants