| Overall Statistics |
|
Total Orders 2 Average Win 0% Average Loss 0% Compounding Annual Return 0% Drawdown 0% Expectancy 0 Start Equity 10000000.00 End Equity 9997946.43 Net Profit 0% Sharpe Ratio 0 Sortino Ratio 0 Probabilistic Sharpe Ratio 0% Loss Rate 0% Win Rate 0% Profit-Loss Ratio 0 Alpha 0 Beta 0 Annual Standard Deviation 0 Annual Variance 0 Information Ratio 0 Tracking Error 0 Treynor Ratio 0 Total Fees ₮207.05 Estimated Strategy Capacity ₮8200000.00 Lowest Capacity Asset BTCUSDT 18R Portfolio Turnover 2.07% Drawdown Recovery 0 |
# region imports
from AlgorithmImports import *
# endregion
class UglyFluorescentYellowMosquito(QCAlgorithm):
def initialize(self):
self.RESOLUTION = Resolution.MINUTE
#parameters for grid
self.num_grid = 20
self.upper = 123000
self.lower = 116000
self.set_start_date(2025, 8, 10)
self.set_end_date(2025,8,12)
self.set_account_currency("USDT", 10000000)
self.set_cash("CASH",10000000)
self.set_brokerage_model(BrokerageName.BINANCE)
future = self.add_crypto_future("BTCUSDT", fill_forward = True, market=Market.BINANCE, )
self._future = future.symbol
self.Range = self.upper - self.lower
self.gridchange = self.Range/self.num_grid
self.daily_history = self.history(self._future,1,Resolution.DAILY)
if self.daily_history.empty == False:
current_price = float(self.daily_history['close'].iloc[-1])
self.sell_price = []
self.buy_price = []
for i in range(self.num_grid):
if self.lower + i*self.gridchange < current_price:
self.buy_price.append(self.lower + i*self.gridchange)
elif self.lower + i*self.gridchange > current_price:
self.sell_price.append(self.lower + i*self.gridchange)
def on_data(self, slice: Slice):
if not (self._future in slice.bars):
return
future_price = slice.bars[self._future].price
try:
if future_price < max(self.buy_price):
quantity = self.calculate_order_quantity(self._future, 0.1)
self.market_order(self._future,1)
self.debug(str(future_price) + "bought")
self.buy_price.pop()
elif future_price > min(self.sell_price):
quantity = self.calculate_order_quantity(self._future,0.1)
self.market_order(self._future,1)
self.debug(str(future_price) + "sold")
self.sell_price.pop(0)
except:
pass