AutoFarm on Raydium Platform

What is Raydium?

Raydium is an automated market maker (AMM) built on the Solana blockchain. They provide liquidity to the order book of the Serum decentralized exchanges (DEX). Apart from that this innovative feature It is very similar to Pancake Swap on the Binance Smart Chain or Uniswap on Ethereum. They provide swap like in above platform, yield for liquidity provider, tax fees reward for RAY stakers.

Technical Requirement

 

 

Now we will see how to become a Liquidity Provider on Raydium Platform. I suggest you to pass by FTX Platform as they have direct transaction to Solana Blockchain without any fees. It’s way better than make the change on Ethereum blockchain where fees are very expensive right now.

From FTX you can buy Sol that we need for fees transaction and other asset that we will put in Liquidity Pool.

Also you need to add Sollet wallet extension to your browser.  Afterward add tokens, so in our case RAY , USDT, SOL. Transfer your asset from FTX to your Sollet wallet.

To do so, don’t hesitate to follow sollet tutorial on it.

When you have transfer some Sol into your wallet to validate transaction and the assets to provide in Liquidity pool let’s see how to become a farmer on raydium.io/liquidity/ !

Liquidity Provider

Now that you have your asset in Sollet browser extension and are on raydium let’s provide liquidity.

On this platform you can trade like in a decentralized Binance on https://dex.raydium.io/ or swap token instantly on https://raydium.io/swap/.

Let’s jump into farming by providing asset in raydium.io/liquidity/

 

You can add tokens and add the equivalent amount to get Liquidity Provider Token. This Token proves that you are a Liquidity provider.

This LP Token allows you to earn fees from Transaction on these pairs. In this example, you will have a certain amount of all fees of SOL/RAY Exchange.

Indeed, when you make a trade or swap on Raydium there is 0.25% fee transaction.

0.22% is redeposited into the liquidity pool and acts as a reward for liquidity providers.

0.03% is sent to the staking pool and acts as a reward for those staking their RAY tokens.

You can have a look of volume of exchange and Fees/Liquidity ratio on https://raydium.io/pools/

 

Now Let’s put our LP Token in https://raydium.io/farms to lend our LP Token into Farming Pool to have Raydium Rewards at high rates!

Once it is staked, you will have RAY Reward coming at each transaction block. For your information APR is live and can go up or down according to the liquidity and the volume.

Moreover, you can also Stake your RAY into https://raydium.io/staking/. This staking pool can offers you the access to some Initial DEX Offering (IDO). An IDO is a token offering to start and promote a crypto-project in this case on the Solana Blockchain. You can have a look at the condition on this AcceleRaytor following this link

Autofarm RAY Token

In conclusion, on the more technical side, I’ve made a Python Script that you can let run on your device this automatically stake your LP Reward or Staking Reward into more staking. Like this you will have compound interest!

You can find the instruction and the script on my GitHub: https://github.com/zeltraxi/Raydium_autofarm

Now you have optimized all your Farming Processus and autofarm on Raydium Platform. You are one of the actors of Solana ecosystem and it rewards you for it.

This is not a financial advise and be aware of their always is risk when investing.

Moreover be aware of Impermanent Loss when providing Liquidity: https://academy.binance.com/en/articles/impermanent-loss-explained

If you want to go further:

To know more about this Raydium project : https://raydium.gitbook.io/

Raydium French Youtube Tutorial: https://www.youtube.com/watch?v=YIyJNBq02TI

In relation here is my Lending/borrowing OASIS platform review : https://www.guillaumeniay.eu/oasis-defi-platform/

Don’t miss out my review of CeFi, DeFi : https://www.guillaumeniay.eu/cefi-defi-the-renewal-of-savings/

AutoFarm on Raydium Platform made by Guillaume Niay

Binance Trading Bot in Python

In this article we will see how to build a trading bot linked to a cryptomarket. In this example we will make a Binance Trading Bot in Python. It can be reuse your own way on other exchange, for stocks as your convenience. Reminder that it’s not a financial advisement and investing is at your own risks.

Now let’s get into the detail and see what we require to create our little robot.

 

 

Requirements

 

 

Binance API

First you need to have a Binance account, if you don’t create one by clicking here.

Afterward click on your profile and go in API Management. Create your API key and save your public API key and secret API key somewhere safe. If you want more detail on this operation Binance has made a tutorial here.

Verify that trading is enabled and deposit money in the asset you want to trade otherwise it will be difficult for our robot to trade! 

Don’t forget to put some security in your account like 2 FA, login with SMS code etc…

Python

If you don’t have python please install it. Don’t forget to add the python.exe path into your path environment variable if it wasn’t automatically do.

When it’s installed, we need to setup libraries we will use for our script. Please open your cmd and install:

pip3 install python-binance 
pip3 install ta

The first library will allow us to do action in Binance and the second will provide financial technical analysis tool to help our robot make decision.

 

 

Python Script Details

 

 

Access Binance Account

Now that we have everything set we can start coding!

Let’s retrieve our account data by accessing Binance website. Include your own public API KEY and Secret API KEY.

We will look for our wallet quantity amount on interested pair. In this example it will be USDT/ETH. 

Financial Analysis

I’m not a Financial expert but I have some basic knowledges. If you would like to add information on the financial part, fell free to share in the comment section.

In my example I have used the basic yet strong Moving Average Convergence Divergence (MACD) and Related Strength Index (RSI) on 4 Hours time periods.

We will use MACD to check if we are in a Bullish or Bearish market and according to the case we will adjust our action.

RSI is a great indicator to see if on a certain time period the asset is oversold or overbought.

My following Bot action has been setup after analyzing pattern on March period on this asset. Moreover, I have set a stop loss to prevent having massive losses.

 

Bot Actions

 

 

After my analysis on last month market and my knowledge on indicators I went up with following action for our trading bot.

I used MACD Trend, RSI variation to forecast Buy/Sell action. In that case I also cancel or put Stop loss according to the action we are doing (Stop Loss if Buying and cancel them if Selling). Feel Free to adjust your quantity, add your own indicators. Above is just an example from my perspective but you can adjust it to yours. 

You can have a look at the full code here on my Github.

 

 

Script Scheduling

 

 

 

Windows

Now that our script is ready to be use we don’t want to have to run it manually every 4 Hours. So let’s schedule it.

To begin, we need to create a bat file to enable the launching of the script by the scheduler.

To do so open your cmd and type:

where python

Press enter and copy the resulting folder. Now open a bloc-note and insert:

"pathopython.exe" "C:\pathofyourpythonfile.py"

Save this bloc-note as a .bat file.

Now Open task scheduler in windows as administrator.

  • In action select the .bat file you created.
  • In Trigger set start one time and set repeat the task every 4 Hours for an indeterminate period of time.
  • For the rest set option at your convenience according to your system (all rights on, launching even in sleep mode etc…).

Check your Binance account to look at what did your bot. Look at your orders historic and keep recording your trades!

Linux Debian

I did it on my side on Raspbian to let my Raspberry Pi run script automatically. I think a raspberry is the perfect tool for such daily script execution. 

To do so install all packages with pip3 in your cmd if not already done.

Afterward transfer your python file into your raspberry.

Launch your cmd and write:

crontab -e

Go at the end of the script and erase “#” and mark:

0 */4 * * Pythonpath yourfilepath.py >> path/log.txt

Now your program will launch your python file automatically every four hours.

If you want to have a look at the log you will have a log file on your desktop.

 

 

 

 

Let’s Trade

 

 

 

I hope it can help few people to start understanding Finance, Coding and IT in general. On my side the system is set on a Raspberry Pi. Don’t hesitate to write about possible improvement or your feedback in the commentary section.

I will be waiting for long-term results and see if this is a good bot strategy or not!

Bibliography  :

Binance Trading Bot in Python Made by Guillaume Niay