In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
How to use PHP and raspberry pie to develop a bitcoin or ethernet trading robot, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.
I recently got Raspberry Pi Zero Wifi, and I'm telling you this thing changes the rules of the game. I have used RasPis before, but because of its much smaller footprint, less power consumption, low price and wireless Internet access, it is very suitable for low-end or Internet of things projects.
Note: at present, I have expanded the robot so that I can trade Ethernet Square!
I hope it can do things without paying too much attention, and the first thing that comes to mind is:
Why not create a simple trading robot that can automatically do bitcoin and ethernet?
The idea is simple: Raspberry Pi Zero uses Coinbase API to regularly check prices and buy and sell bitcoins when it makes sense. You should be able to give it a budget and see what you can do with it.
The robot is a lurker for weeks or months, waiting for a great bitcoin price to buy and sell. It depends on how you use it!
What robots should be able to do:
I want you to buy 50 euros of bitcoin and sell it when 50 euros becomes 52 euros.
When the price of Bitcoin reaches 1000 euros / Bitcoin, I want you to buy it and sell it when it is worth 150 euros.
Buy low, sell high.
Automatically buy bitcoin when the next bubble bursts.
What robots don't do:
Conduct market analysis and detect bubbles and collapses.
To make you rich.
Make a lot of deals. The robot is a slow latent investor.
For control reasons, I hope to be notified whenever I sell or buy BTC/ETH. To do this, I use a simple webhook for my favorite (and autonomous) chat platform rocket.chat. But it also applies to Slack's webhook!
This is a PHPTrader robot.
What do we need to make it work:
A Raspberry Pi or just a Linux box.
Coinbase account, containing an euro / dollar wallet with some funds.
PHP 5 or later.
PHP Composer installation library.
If you want to be notified, you need a rocket.chat or Slack webhook.
Step 1: install the robot
It's simple:
Use the command git clone https://github.com/chrisiaut/phptrader.git to download repo or download as a ZIP file.
Enter the php traders directory cd phptrader.
Install the required composer file composer install.
Rename example.config.inc.php to config.inc.php.
Step 2: enter the Coinbase API key and key
It's also easy to get your keys:
1. Enter https://www.coinbase.com/settings/api.
two。 Click + New API Key.
3. Then you will see the API key creation dialog box. Select Bitcoin / ethernet and euro / dollar wallets.
4. Select all permissions.
5. Submit.
When you see API key and API secret, enter them in PHPTrader bot under COINBASE_KEY and COINBASE_SECRET in the config.inc.php file.
Warning: keep API key and API secret secret. When an attacker gains access, it's like handing over your house key.
Step 3 (optional): set up rocket.chat or Slack webhook
For Slack, use this tutorial to get webhook. And fill it in the ROCKETCHAT_WEBHOOK field in config.inc.php:
Note: you need to be an administrator to set up webhook for rocket.chat. Host your instance (it's easy to use Docker) or ask a trusted administrator to do this for you.
1. On the chat instance, go to Administration-> Integrations
two。 Click New Integration, then click Incoming WebHook
3. Set it to enabled and select the publish channel or user.
4. Click Save Changes
Now you will see a Webhook URL, copy it and put it in the ROCKETCHAT_WEBHOOK field in config.inc.php and ok.
Final step: tell the robot when to buy and sell
Using the following command, the robot will create a transacitons.json file that will save the euro, BTC, starting price and selling price so that we can track them on restart.
Php trader.php buy [amount in EUR] [sell when price increases by EUR]
Php trader.php sell [amount in EUR] [sell when this BTC/ETH price is reached]
Php trader.php order [amount in EUR] [sell when price increases by EUR] [buy at BTC/ETH price]
Example:
Buy 10 euros at BTC/ETH and sell them when they are worth 12 euros: php trader.php buy 102.
Add a sales order. When the price of BTC/ETH reaches 2000, it sells for 100euro / USD: php trader.php sell 1002000.
Add a purchase order of 1000 euros when 1BTC/ETH is worth 1000 euros, and sell when 100 euros is worth 110 euros: php trader.php order 10010 1000.
After the setup is complete, you can start the watchdog: the core of the robot is an infinite loop, checking for price changes regularly (every 10 seconds). You can use the command php trader.php watchdog to start it yourself, or you can use the start.sh script to put the process in the background and log in to / var/log/phptrader.log.
. / start.sh
Or
Nohup php trader.php watchdog > > / var/log/phptrader.log 2 > / var/log/phptrader.err &
You can view the log file to see what the robot is currently doing:
This is the answer to the question about how to use PHP and raspberry pie to develop a bitcoin or ethernet trading robot. I hope the above content can be of some help to you. If you still have a lot of questions to solve, you can follow the industry information channel for more related knowledge.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.