Automated Trading Market Maker Order

marketMaker()

bidAmount, bidStep, bidCount, askAmount, askStep, askCount, spread, autoBalance, autoBalanceEvery, varyAmount, tag

An order that creates a basic market maker bot. This essentially looks like a pair of endless ping pong orders that are a little easier to set up.

It also supports a feature to auto balance the position if price starts to move outside the initial range. You'll need to experiment with this feature, as used correctly it allows you to focus your funds in a tighter range, while still being able to profit from trending markets or significant moves outside your original range.

The market maker orders runs forever, so to stop it you can do one of the following :-

  • Log into the exchange the order is running on, and manually cancel all the orders created by the market maker. The market maker will notice it's orders have been removed and exit.
  • Send a cancel(which=all) to the exchange - it will cancel the market maker and all it's open orders. Note that this won't close any open position created by the market maker. Try market(position=0) to close that with a market order.

Also, note that if you restart your trading bot while a market maker order is running, it will be discarded and any open orders related to it will be left on the order book. Cancel the order before restarting.

Arguments
bidAmount optional number, defaults to 0

The amount of each bid.

bidStep optional number, defaults to 5

The price difference between each bid of the initial bids. Once the order starts running, new orders are always created spread/pongDistance away from the filled order.

bidCount optional number, defaults to 0

The number of initial bid orders to try and place.

askAmount optional number, defaults to 0

The amount of each ask.

askStep optional number, defaults to 5

The price difference between each ask of the initial asks. Once the order starts running, new orders are always created spread/pongDistance away from the filled order.

askCount optional number, defaults to 0

The number of initial ask orders to try and place.

spread optional number, defaults to 30

The gap between bids and asks (well, when a bid/ask is filled, how far away should the opposite order be placed). In pingPong() terms, this is pongDistance.

autoBalance optional string, one of none, shuffle, centre, flow. defaults to none

When autoBalance is enabled the market maker order will attempt to move the bids and asks around under certain conditions to keep the orders in the range of the price. Extreme caution should be used with these options, as they can seriously damage the profitability of the order, if not managed correctly.

Value What it does
none There is no attempt to rebalance the market maker order if price trends in one direction
shuffle If the price moves fully outside the range containing orders, the market maker command will move an order from the back of the exiting orders, and place it just next to the order closest to the price. This has the effect of moving the whole block of orders closer to the price. This step is repeated every autoBalanceEvery seconds.
center Each time an order is filled, the market maker order will re-balance the bids and asks to ensure there are an equal number of orders on each side of the price, even if bidCount and askCount were different. WARNING: This can result in large positions growing. Only use this option if you have measures in place to manage the position size. This step is repeated every autoBalanceEvery seconds.
flow Keeps a fixed number of bids and asks either side of the current price and support continuously tracking the price with different bidStep and askStep size. Unlike the other models, when an order is filled in flow mode, a new order is placed on the same side of the book, just beyond the furthest away order (the step size determines how far away). At the same time, the furthest away order from the other side of the is moved to a position in the gap between bids and asks (if there is room). This gives the appearance of the whole block following the price. autoBalanceEvery is ignored by this mode, as changes are made as soon as possible always. Warning: as there are a constant number of orders on each side of the book, this can result in building very large position if the prices moves a long way in the same direction. You will need other options to manage this order externally if you want to avoid total rekage.
autoBalanceEvery optional time string, defaults to 0

The number of seconds to wait between each attempt to auto balance. You can adjust this to change how quickly the bot tries to re-balance your orders.

Example How long will it wait between adjustments?
autoBalanceEvery=10 10 seconds
autoBalanceEvery=10s Also 10 seconds
autoBalanceEvery=10m 10 minutes
autoBalanceEvery=10h 10 hours
varyAmount optional percentage, defaults to 0

How much, as a percentage, should the amount of individual orders be randomised by.

Can accept numbers, like 0.1, or percentages like 10%. Should be in the range 0 to 1 or 0% to 100%.

tag optional boolean, one of true, false. defaults to false

Tags the order with the value given. This allows you can cancel the order using it's tag. See cancel() for more details.

Example: Start a market maker running?

myApiKeys(XBTUSD) {
 marketMakerOrder(
    bidAmount=50, bidStep=5, bidCount=10,
    askAmount=50, askStep=5, askCount=10,
    spread=30,
    autoBalance=shuffle, autoBalanceEvery=5m);
}

This will start out creating 40 bids and 40 asks. Each order will be for 100 contracts and they will be spaced $5 apart. There will be a $30 gap between the bids and asks. As orders are filled, a new order will be placed $30 away on the other side of the book.

If the prices moves outside the range of orders, the bot will attempt to shuffle the block closer to the price, every 5 minutes.

Some images from Unsplash

About Alertatron.com

Your TradingView alerts, with charts, PM'd to you.

Get all your alerts from TradingView, sent to Telegram, Discord, Slack, Email or webhooks, with a chart snapshot attached.

Capture Charts

See a high quality chart with every alert, captured at the moment the alert was triggered. See exactly what the market was doing and make informed decisions.

Automate Trading

Trigger orders on popular cryptocurrency exchanges and trade 24/7. Access powerful algorithmic orders to maximise your profits.

Integrations

Connect your alerts to Telegram (channels, groups and private chats), Discord, Slack, email or send push notifications to other services with webhooks.

Easy To Setup

Nothing to install and no browser extensions. Captures alerts 24/7, even with your computer switched off. Be up and running in seconds.