Selling at the Best Price Considering Historical Data
Grid 2: Selling at the Best Price Considering Historical Data
Selling at the best price, not lower than min_ask_price
and the midpoint between the average closing price and the average highs of daily candles over the past month.
The grid places sell orders at the best price. An additional parameter, gap
, is used to calculate the order prices. In this example, it is set to 1%.
1+gap*(
order_pos
-1)
As additional parameters, daily candles for the last 30 days are retrieved.
candles
('d1', '
base
-
counter
',count=30)
Based on these, additional parameters are calculated: the average closing price and the average daily high price over the last 30 days.
mean
([price.
close
for price in candles_1d])
mean
([price.
high
for price in candles_1d])
Next, the order price is calculated as the maximum of the current best price, the minimum ask price set in the min_ask_price
parameter, and the midpoint between the average closing price and the average high price over the last 30 days.
In this example, min_ask_price
is set to the maximum of the average closing price and the current best bid price, plus 2 price_precision.
Orders will be placed until the balance of the Counter token exceeds 5000. If needed, this can be replaced with a combined balance across multiple exchanges.
group_balance
('
counter
').current.total
5 if
group_balance
('
counter
').current.total < 5000 else 0
Last updated