ctubio / Krypto-trading-bot

Self-hosted crypto trading bot (automated high frequency market making) written in C++
https://127.0.0.1:3000
Other
3.31k stars 817 forks source link

Inventory Management for Market Making #595

Open ezgigurkan opened 6 years ago

ezgigurkan commented 6 years ago

Hello everyone,

I used to work for an HFT firm as a market maker and I have been using this bot in the last few weeks to see what it can do.

I have a suggestion regarding inventory management. I do have programming experience but not in C++ so didn't want to fiddle with it myself. I'm happy to pay a bounty for this addition.

As it's not possible to hedge positions or do triangular arbitrage, clearing inventory as fast as possible would be a valuable strategy for this bot as far as market making is concerned. It is already possible to specify a profitability target using "width"/"pingWidth" with bids and correlate it somewhat with the spread using "sop", "sopWidth" and "sopSize". But there is no good way of configuring the bot to get out of the position as soon as possible, no matter what the profit or loss. With safety off it simply tries to sell at the "width". Could set that to the minimum but then can't specify a profitability target. With safety on, it tries to "pong" when it finds matching "pings" and, it seems, only when the price is better than the "ping" price. When the price drops below the "ping" price, the bot won't sell at a loss and is exposed to directional (inventory) risk. It also doesn't seem to sell if the inventory is less than the "askSize". Correct me if I'm wrong.

The ideal situation would be for the bot to constantly try to sell the maximum amount of inventory (upper limit being "askSize") at the best price possible (assuming a "mode" of "Top"), no matter what happened in the past. It should simply try to lock in any profit or loss immediately and bring the inventory to 0 (or maybe "tbp" is more appropriate?) as fast as it can. You could also classify this as safety if you like, but it's safety from inventory risk, not profit loss. Basically you want to minimize the time you hold the base currency.

What are your thoughts?

ctubio commented 6 years ago

many thanks for your suggestions'¡''

all this still using limit trades right? im not very fan of strategies that relay on market trades :S (maybe cos of fees)

thanks for confirm'''

ezgigurkan commented 6 years ago

Hi Carles,

Yes, certainly. The bot would simply be constantly quoting to sell all the base currency (limited by the "askSize"?) at the best price if the "mode" is "Top". If you wanted to give the option to be really aggressive with this, it could beat the best ask price by more than a tick. But no need to cross and hit the bid.