A simple strategy, probably somewhat inefficient in the future.

MiiaHash

Junior Member
Joined
Feb 4, 2023
Messages
131
Reaction score
121
I wanted to tell you how I make a simple strategy, to be able to comment it among all of you.
First of all, anyone can do it, I am not going to offer anything or any garbage, everyone can tell me if it seems good or not.


Arbitrage strategy (base-Q1)

look for a pair without commissions, for example FDUSD/USDT, as you will see they are replicas to the USD.
The strategy, apply a grid with a percentage change of 0.01%.

1721199394518.png1721199463148.png

Basically, apply the grid from an example price of 0.9995 to 1.0000 (safety, so avoid buying too high, currencies to replicate USD, “normally” return on average to 1, if you can't lower the grid to increase safety, trade less.


apply this grid constantly, with orders of $1000 USD (or what you can afford) divide it by 0.01% for each N of prices you want to cover example from 0.9995 to 1.0000, you would need 5 (x1000=$5000), now you can use the N1D strategy to make 5 (x15 *x $1000) this means, you will buy when you reach example 0. 9995 15 orders of $1000, which will be sold at 0.9996 this is $1.5 approximate, it may seem little, but the currencies usually have between 500-1000 movements per day, applying 15% of orders executed, will give us approximately 150 orders executed per day $1.5x150=$225 (approximate).

in the image, (a little old, you can see how this system works, it is old because now I use subaccounts controlled by API)
On average with this I managed to earn approximately $1200 USD per month.

infinite grid (base-Q2)

This strategy is probably high risk, however if you trust the currencies you put in, you can take the risk, it is not used for futures as it is unpredictable and high risk, here we will use spot and a simple, but more efficient grid.

for this you will probably need programming, do the following search for a pair based on your likes FDUSD (since there is no commission for creation)

and apply a grid from 0.05% to 0.1% to capture as much movement as possible,

1721200029463.png1721200037040.png

as you can see, maker is commission free, which allows you to put a very small movement, as you know BTC fluctuates hundreds of times a day, if you apply some logic, basic knowledge like resistances and supports, RSI and more or less calculate a range where the price fluctuates for a few months, you can earn quite a lot of money.

I will show you pictures of my account (sub-account) where I do this, earning about $100 USD per day with $10000 USD, using BTC/BNB/SOL and other currencies.

1721200192031.png

Volume sample for the last two months
1721200214667.png
1721200241029.png

chart per day of earnings
1721200261501.png

Daily trading volume
1721200343736.png

I am new to cryptocurrencies, if you have any suggestions or think this is wrong, I would love to talk about it, keep in mind that none of this is serious or reliable, even if we are using spot replicated assets and in USD, it can lose its value drastically.

I have been doing for a while now, even with BTC dropping from 70k to 55k and something, it hasn't been affected that much, as I use multiple currencies, the profits and trades I make in one, I recover the loss of the others.

1721200809021.png
 
Last edited:
Pretty decent strat, is this something you’re doing by using a custom built trading bot? Also, wouldn’t it make more sense using coinbase pro to reduce trading fees even more and increasing your profit per trade?
 
Pretty decent strat, is this something you’re doing by using a custom built trading bot? Also, wouldn’t it make more sense using coinbase pro to reduce trading fees even more and increasing your profit per trade?
I don't know coinbase pro, but binance has 0% fees on certain pairs.
 
Just be careful what stablecoin poirs you're market making. Some are unbacked and once they crash they never recover
 
Impressive results, I wish I had understood something that you said about this strategy, unfortunately I don't know much about it
 
So you're basically swing trading using coins that don't take a commission with every trade?

Yeah, this is definitely profitable, but a bot is probably necessary in order to do all those transactions constantly.
 
Just be careful what stablecoin poirs you're market making. Some are unbacked and once they crash they never recover
This would be the biggest risk of the first strategy, that the dollar based currencies lose their parity, however I have savings in FDUSD, USDT, USDC, if they are still, I better use this strategy.
 
Impressive results, I wish I had understood something that you said about this strategy, unfortunately I don't know much about it
I'll explain it a little better then
 
So, you buy the FUSD for $0.9995 and you sell for $1 multiple times a day
How can we set up something to buy and sell automatically?
I buy with a difference of 0.01% i.e. I buy from 0.9995 to 0.9996, from 0.9999 to 1.0000 I do not buy above $1, for safety, but most coins fluctuate between 0.9985 to 1.0010.

As stable pairs like FDUSD/USDT, TUSD/USDT, USDC/USDT have zero commissions, if you make thousands of trades per day you can make some money with this strategy, binance will also give you rewards for adding liquidity.
 
I buy with a difference of 0.01% i.e. I buy from 0.9995 to 0.9996, from 0.9999 to 1.0000 I do not buy above $1, for safety, but most coins fluctuate between 0.9985 to 1.0010.

As stable pairs like FDUSD/USDT, TUSD/USDT, USDC/USDT have zero commissions, if you make thousands of trades per day you can make some money with this strategy, binance will also give you rewards for adding liquidity.
It makes sense, appreciate your explanation
But do you do that manually?
 
So you're basically swing trading using coins that don't take a commission with every trade?

Yeah, this is definitely profitable, but a bot is probably necessary in order to do all those transactions constantly.
Effectively, it would be an example with BTC, you buy at 70.000 you sell at 70.015, this change is practically nothing, if you did it a couple of times a day, you would still get a few cents, but binance constantly moves between 0.01% to 0.05% each candle (time=1 minute) when you do this hundreds of times a 0.01% can quickly turn into profits of 5% daily.

I made a simple bot using cctx, this simply checks every 5-10 minutes some indicators (Technical indicators) example RSI and Macd, moving averages and some simple things nothing complicated, if the values cross for that candle, then the bot makes a buy trade and then, no sell trade is made with a difference of 0.1%.
 
It makes sense, appreciate your explanation
But do you do that manually?
I do it with a very simple bot, using ccxt I grab the pair every 1 minute and check the price, then I place buy orders, if the price is at 0.9995, I place a buy order at 0.9994 and a sell order at 0.9995, so constantly for the day, and I place 15 orders for each movement, when it falls to 0.9994 I buy x15 times and sell x15.
 
I do it with a very simple bot, using ccxt I grab the pair every 1 minute and check the price, then I place buy orders, if the price is at 0.9995, I place a buy order at 0.9994 and a sell order at 0.9995, so constantly for the day, and I place 15 orders for each movement, when it falls to 0.9994 I buy x15 times and sell x15.
Thank you
But I'm afraid you won't give this bot for us, especially for free
 
Ok, if you can post it for us, it would be amazing, appreciate your time
The system has a website, I will ignore that section.
the only requirement is to have bun installed (https://bun.sh/)

tsconfig.json

JSON:
{
  "compilerOptions": {
    // Enable latest features
    "lib": ["ESNext"],
    "target": "ESNext",
    "module": "ESNext",
    "moduleDetection": "force",
    "jsx": "react-jsx",
    "allowJs": true,

    // Bundler mode
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "verbatimModuleSyntax": true,
    "noEmit": true,

    // Best practices
    "strict": true,
    "skipLibCheck": true,
    "noImplicitAny": false,
    "noFallthroughCasesInSwitch": true,

    // Some stricter flags (disabled by default)
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "noPropertyAccessFromIndexSignature": false,

    "resolvePackageJsonExports": true
  }
}

copy this into tsconfig.json
and install all of the following dependencies:

Bash:
bun add @prisma/client @t3-oss/env-core ccxt cron hashids hono ioredis nanoid prisma technicalindicators zod

some dependencies I will not include, the code is simple to perform the operations, but I have built many things on top of it, so I will pass you an example of the code and you adapt it to your needs.

JavaScript:
import { customAlphabet } from 'nanoid';
import { SMA, WMA } from 'technicalindicators';

import { CronJob } from 'cron';
import { pro } from 'ccxt';

const exchange = new pro.binance({
    apiKey: process.env.BINANCE_EXCHANGE_API,
    secret: process.env.BINANCE_EXCHANGE_SECRET,
    options: {
        adjustForTimeDifference: true
    },
    enableRateLimit: true
})

let running = false;
let data: {
    qty: 100, // 100 USD
    profit: 0.0001 // 0.01%
    symbol: "FDUSD/USDT"
};

/** suscribeOrders */
const suscribeOrders = async () => {
    const symbol = data.symbol;

    while (true) {
        const orders = await exchange.watchOrders(symbol);

        for (const order of orders) {
            const closed = order.status === 'closed';

            if (closed) {
                const [_, clientOrderId] = order.clientOrderId!.split('_');
                // you can use this to save the operations in your database or as you prefer.
            }
        }
    }
}

/** suscribeTrades */
const suscribeTrades = async () => {
    const qty = data.qty;
    const profit = data.profit;
    const symbol = data.symbol;

    while (true) {
        const trades = await exchange.watchMyTrades(symbol);

        for (const trade of trades) {
            const filled = trade.info.X === 'FILLED';

            if (filled) {
                const order = await exchange.fetchOrder(trade.order!, symbol);

                if (trade.side === 'buy') {
                    const price = Number(trade.price) * (1 + profit);
                    // when a transaction is successfully completed, we immediately put it up for sale.
                    await createExchangeOrderLimit(exchange, "custom-id", qty, "sell", price, profit, symbol, order.clientOrderId);
                }
            }
        }
    }
}

/** onTick */
const onTick = async () => {
    const qty = data.qty;
    const profit = data.profit;
    const symbol = data.sumbol;

    const ticker = await exchange.fetchTicker(symbol);
    const orders = await exchange.fetchOpenOrders(symbol);

    const bid = Number(ticker.bid);

    const limitAsk = 1.0000;
    const limitBid = 0.9980;

    const bids = [...Array(3).keys()].map((index) => Number((bid - (bid * profit) * (index - 1)).toFixed(4)));
    const validBids = bids.filter((price) => (price >= limitBid) && (price < limitAsk));

    const items = orders.filter((order) => order.side === 'buy' && !validBids.includes(order.price));
    await Promise.all(items.map((order) => exchange.cancelOrder(order.id, symbol)));

    const nanoid = customAlphabet('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 11);

    const sales = orders.filter((order) => order.side === 'sell');
    const buys = orders.filter((order) => order.side === 'buy');

    const cqt = validBids.length + sales.length + buys.length;
    const mdc = (cqt * qty);
    const mdq = (qty * 100);

    if (mdc >= mdq) {
        return;
    }

   // here we create the purchase order
    for (const validBid of validBids) {
       await createExchangeOrderLimit(exchange, "custom-id", qty, "buy", validBid, profit, symbol, `fdusd_${nanoid()}`);
    }
}

/** job */
let job = new CronJob('*/15 * * * *', onTick, null, false, 'America/Los_Angeles');

/** suscribe */
suscribeOrders();
suscribeTrades();

running = true;
job.start();

export const createExchangeOrderLimit = async (c: Exchange, id: string, qty: number, side: string, price: number, profit: number, symbol: string, newClientOrderId: string) => {
  let attempts = 10;
  let attempt = 0;
  let _price = price;
  let _qty = qty;
  let order: Order | null = null;
  while (attempt < attempts) {
    try {
      order = await c.createOrder(symbol, 'LIMIT_MAKER', side, _qty, _price, {
        newClientOrderId,
      });
      break;
    } catch (error) {
      console.log(id, _qty, side, _price, profit, symbol, newClientOrderId);
      if (error instanceof ccxt.InvalidOrder) {
        if (side === 'sell') {
          const ticker = await c.fetchTicker(symbol);
          const bid = Number(ticker.bid);
          _price = bid * (1 + profit);
        }
        if (side === 'buy') {
          const ticker = await c.fetchTicker(symbol);
          const bid = Number(ticker.bid);
          _price = bid * (1 - profit);
        }
      } else if (error instanceof ccxt.DuplicateOrderId) {
        if (side === 'sell') {
          console.log('Duplicate order id for sell order');
        }
      } else if (error instanceof ccxt.InsufficientFunds) {
        if (side === 'sell') {
          const [base] = symbol.split('/');
          const balance = await c.fetchBalance();
          const available = Number(balance[base].free);
          _qty = Math.min(qty, available);
        }
      } else if (error instanceof ccxt.OrderImmediatelyFillable) {
        if (side === 'sell') {
          const ticker = await c.fetchTicker(symbol);
          const bid = Number(ticker.bid);
          _price = bid * (1 + profit);
        }
        if (side === 'buy') {
          const ticker = await c.fetchTicker(symbol);
          const bid = Number(ticker.bid);
          _price = bid * (1 - profit);
        }
      }
    }
    await sleep(1000 * attempt);
    attempt++;
  }
  return order;
}

I will need to edit it a bit, however it should serve as a base, I have removed quite a few internal things like the database, models, etc. so it may be a bit wrong, but it can help you to get an idea, since the code has a lot of old stuff.

basically, every 15 minutes, we execute onTick, onTick verifies the current price of the symbol, cancels the previous trades and generates new ones with the new values and executes a limit to buy when this is executed, we use watchTrades to watch the completed trades, when binance tells us that it has been completed we execute the same trade but this time we add profit, and put the order to sell.

this generates a buy order at 0.9991 and when it is executed, a sell trade is automatically executed for 0.9992.
I have run the code clean, to make sure it has nothing strange or malicious, the original code is approximately 5,000 lines and can cause people to get lost.

const limitAsk = 1.0000;
const limitBid = 0.9980;

use these indicators to trade within a safe range of your choice.

additionally if you are wondering how to load variables create an .env file and put your data in this format
KEY=VALUE, with the example names BINANCE_EXCHANGE_API, although ccxt has the name “pro”, it is completely free and free of charge, you will not be charged anything for using it.

however these recommendations are useful: when you create your api in binance, set your ip to not allow unauthorized use, set the only currency where you will operate and do not allow transfers with this api
 
I wanted to tell you how I make a simple strategy, to be able to comment it among all of you.
First of all, anyone can do it, I am not going to offer anything or any garbage, everyone can tell me if it seems good or not.


Arbitrage strategy (base-Q1)

look for a pair without commissions, for example FDUSD/USDT, as you will see they are replicas to the USD.
The strategy, apply a grid with a percentage change of 0.01%.

View attachment 360839View attachment 360840

Basically, apply the grid from an example price of 0.9995 to 1.0000 (safety, so avoid buying too high, currencies to replicate USD, “normally” return on average to 1, if you can't lower the grid to increase safety, trade less.


apply this grid constantly, with orders of $1000 USD (or what you can afford) divide it by 0.01% for each N of prices you want to cover example from 0.9995 to 1.0000, you would need 5 (x1000=$5000), now you can use the N1D strategy to make 5 (x15 *x $1000) this means, you will buy when you reach example 0. 9995 15 orders of $1000, which will be sold at 0.9996 this is $1.5 approximate, it may seem little, but the currencies usually have between 500-1000 movements per day, applying 15% of orders executed, will give us approximately 150 orders executed per day $1.5x150=$225 (approximate).

in the image, (a little old, you can see how this system works, it is old because now I use subaccounts controlled by API)
On average with this I managed to earn approximately $1200 USD per month.

infinite grid (base-Q2)

This strategy is probably high risk, however if you trust the currencies you put in, you can take the risk, it is not used for futures as it is unpredictable and high risk, here we will use spot and a simple, but more efficient grid.

for this you will probably need programming, do the following search for a pair based on your likes FDUSD (since there is no commission for creation)

and apply a grid from 0.05% to 0.1% to capture as much movement as possible,

View attachment 360843View attachment 360844

as you can see, maker is commission free, which allows you to put a very small movement, as you know BTC fluctuates hundreds of times a day, if you apply some logic, basic knowledge like resistances and supports, RSI and more or less calculate a range where the price fluctuates for a few months, you can earn quite a lot of money.

I will show you pictures of my account (sub-account) where I do this, earning about $100 USD per day with $10000 USD, using BTC/BNB/SOL and other currencies.

View attachment 360846

Volume sample for the last two months
View attachment 360847
View attachment 360848

chart per day of earnings
View attachment 360850

Daily trading volume
View attachment 360851

I am new to cryptocurrencies, if you have any suggestions or think this is wrong, I would love to talk about it, keep in mind that none of this is serious or reliable, even if we are using spot replicated assets and in USD, it can lose its value drastically.

I have been doing for a while now, even with BTC dropping from 70k to 55k and something, it hasn't been affected that much, as I use multiple currencies, the profits and trades I make in one, I recover the loss of the others.

View attachment 360855
Good strategy. Bookmarked it for later studying.
 
Back
Top