<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by c9s on Medium]]></title>
        <description><![CDATA[Stories by c9s on Medium]]></description>
        <link>https://medium.com/@c9s?source=rss-c82974340894------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NQD-2NEizZcpQomQylcX1Q.jpeg</url>
            <title>Stories by c9s on Medium</title>
            <link>https://medium.com/@c9s?source=rss-c82974340894------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 05:57:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@c9s/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[BBGO — What’s New in v1.40.x]]></title>
            <link>https://medium.com/bbgo/bbgo-whats-new-in-v1-40-x-bb80d447d5b1?source=rss-c82974340894------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb80d447d5b1</guid>
            <category><![CDATA[trading-bot]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[trading]]></category>
            <dc:creator><![CDATA[c9s]]></dc:creator>
            <pubDate>Wed, 14 Sep 2022 13:59:59 GMT</pubDate>
            <atom:updated>2022-09-14T14:01:57.985Z</atom:updated>
            <content:encoded><![CDATA[<h3>BBGO — What’s New in v1.40.x</h3><h3>What’s BBGO?</h3><p><a href="https://github.com/c9s/bbgo">BBGO</a> is an open source crypto trading framework designed for trading bots, written in Go programming language.</p><h3>What You Can Do With BBGO?</h3><p>For Trading Bot Users 💁‍♀️ 💁‍♂️ — You can use <a href="https://github.com/c9s/bbgo">BBGO</a> to run the built-in strategies.</p><p>For Strategy Developers 🥷 — You can use <a href="https://github.com/c9s/bbgo">BBGO</a>’s trading unit and back-test unit to implement your own strategies.</p><p>For Trading Unit Developers 🧑‍💻 — You can use BBGO’s underlying common exchange API, currently it supports 4+ major exchanges, so you don’t have to repeat the implementation. (BBGO supports Binance, FTX, OKEx and Kucoin)</p><p>#1 Added New Telegram Commands</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*RRogQ99I6fUOL8l54pH0iA.png" /></figure><p>/resetposition</p><p>For people who wants to reset the position, you can use the telegram bot command /resetposition to reset the position directly. Without the need to open the redis-cli and flushall the settings</p><p>/modifyposition</p><p>For people who manually placed orders to buy/sell some inventory, you can modify the strategy position by yourself. Three fields are modifiable:</p><ol><li>Cost — the average cost of your position. This should be a positive number, that is, your average executed price.</li><li>Base — this is the base quantity of your position. for example, the quantity of BTC. Positive number means you hold a Long position, negative means you hold a Short position.</li><li>Quote — this is quote quantity (or amount) you spent to buy your BTC. for example, -3200 USDT. For long position, the quote is usually a negative number, it means you spend X USDT to buy Y BTC.</li></ol><p>#2 New Order Executor API</p><p>You can now call the OpenPosition method to open a long/short position in a spot account or a leveraged account. For example, to open a 3x leveraged long position, you can simply call:</p><pre>orderExecutor.OpenPosition(bbgo.OpenPositionOptions{<br>   Leverage: 3.0,<br>   Long: true,<br>})</pre><p>The account value calculator will fetch the asset price and calculate your account value in USD, and automatically convert the value into the quantity of your order.</p><p>#3 New Built-in Strategy — <a href="https://github.com/c9s/bbgo/blob/main/config/elliottwave.yaml">elliotwave</a></p><p>This strategy is a rewrite of ewoDgtrd strategy. If you’re interested in it, you can check out the default config to see how to use it.</p><p>#4 New Built-in Strategy — <a href="https://github.com/c9s/bbgo/blob/main/config/pivotshort.yaml">pivotshort</a></p><p>This strategy focuses on opening short, which can be applied to spot, margin account or futures account. You can also setup multiple exit methods to close your position. For example: trailingStop, roiStopLoss, roiTakeProfit, accumulatedVolumeTakeProfit .. and so on..</p><p>#5 New Built-in Strategy — <a href="https://github.com/c9s/bbgo/blob/main/config/supertrend.yaml">supertrend</a></p><p>This built-in strategy is based on the supertrend indicator. It works for both direction, Long and Short.</p><p>#6 Built-in Exit Method API</p><p>For strategies support built-in exit methods, you can describe your exit conditions in a descriptive YAML, for example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y_OrvmCx3DvBojwEuqXydA.png" /></figure><p>#7 New bollmaker protection mech</p><p>The bollmaker strategy now supports different dynamic spread methods, sigmoid and amplify.</p><p>the newly introduced trendEMA indicator also improves the net profit and unrealized profit during the bear market.</p><p>bollmaker PnL without trendEMA:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/816/0*CFgKmJ4LR91kULat" /></figure><p>bollmaker PnL with trendEMA:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/924/0*OSJqwy5Pgxa-bFoa" /></figure><p>And this is the date range we used for testing trendEMA:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y5t7TPyp92xSYSc6" /></figure><p>If you like BBGO and would like to support our project, you can use the following referral link to get a 5% commission kickback:</p><p><a href="https://accounts.binance.com/en/register?ref=VGDGLT80">Bitcoin Exchange | Cryptocurrency Exchange | Binance</a></p><p>If you need any help with BBGO, you can create an issue in the <a href="https://github.com/c9s/bbgo">GitHub project</a>, or join our telegram group:</p><p><a href="https://t.me/bbgo_intl">BBGO International</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb80d447d5b1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bbgo/bbgo-whats-new-in-v1-40-x-bb80d447d5b1">BBGO — What’s New in v1.40.x</a> was originally published in <a href="https://medium.com/bbgo">BBGO</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BBGO — BollMaker Trading Bot]]></title>
            <link>https://medium.com/bbgo/bbgo-bollmaker-trading-strategy-3a4e80b482e3?source=rss-c82974340894------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a4e80b482e3</guid>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[trading-bot]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[c9s]]></dc:creator>
            <pubDate>Wed, 04 May 2022 18:21:50 GMT</pubDate>
            <atom:updated>2022-05-13T11:14:27.964Z</atom:updated>
            <content:encoded><![CDATA[<h3>BBGO — BollMaker Trading Bot</h3><h4>Are you still using the traditional grid trading bot for cryptocurrency?? Try BollMaker Trading Bot</h4><p>Since the rapid development of the cryptocurrency market, grid trading has become widely known as automated trading strategy.</p><p>However, there are many problems with the grid trading strategy. For example, you may sell off in a fast-rising market, or get stuck in a fast-falling market, and you need to adjust the price band very frequently.</p><p>Grid Orders placed at higher prices and lower prices are not efficiently used, you just hang these orders there and lock your balance and it does not generate any profit if the market price range is small.</p><p>At the end, you will find out, Grid Trading is really an inefficient trading strategy!</p><p>So, I decided to start developing a new trading bot, a brand new trading strategy that would overcome the shortcomings of the grid strategy.</p><p>And strategy bollmaker came into being.</p><h3>What’s BollMaker?</h3><p>BollMaker is an acronym for a Bollinger band based market-making strategy.</p><p>This strategy uses dual Bollinger bands for trading, but it does not use the bands traditionally.</p><p>It uses a band with a short time period to detect fast-moving price.</p><p>In addition, a band with a long period of time is used to dynamically adjust the limit of the maximum holding position.</p><p>And BollMaker is one of the trading strategies in BBGO — A crypto trading bot framework!</p><h3>What’s BBGO?</h3><p><a href="https://github.com/c9s/bbgo">BBGO</a> is an open source crypto trading framework designed for trading bots, written in Go programming language.</p><h3>What You Can Do With BBGO?</h3><p>For Trading Bot Users 💁‍♀️ 💁‍♂️ — You can use <a href="https://github.com/c9s/bbgo">BBGO</a> to run the built-in strategies.</p><p>For Strategy Developers 🥷 — You can use <a href="https://github.com/c9s/bbgo">BBGO</a>’s trading unit and back-test unit to implement your own strategies.</p><p>For Trading Unit Developers 🧑‍💻 — You can use BBGO’s underlying common exchange API, currently it supports 4+ major exchanges, so you don’t have to repeat the implementation. (BBGO supports Binance, FTX, OKEx and Kucoin)</p><h3>And, What’s a market maker strategy?</h3><p>A market maker is a firm, individual or trading strategy that always or often quotes both a buy and a sell price for a financial instrument or commodity, hoping to make a profit by exploiting the difference between the two prices, known as the spread.</p><p>As soon as an order is received from a buyer, the Market Maker sells the shares from its own inventory and completes the order. And, this process increases the liquidity in the market. Hence, it is known as Market Making Strategy.</p><p>Generally, Market Maker profit by charging higher ask prices (selling) than bid prices (buying). The difference is called the ‘spread’.</p><p>The spread compensates the market makers for the risk inherited in such trades which can be the price movement against the market makers’ trading position.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/0*w5TWekCpO05BO5Om.png" /></figure><p>And Market Maker Strategy is the strategy designed for market maker, to provide liquidity. (Grid strategy is also a maker strategy that provides liquidity)</p><h3>How does BollMaker perform?</h3><p>Let’s see the back-testing result first:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*ZJ2XZtE4u4Of8_yotjSD3g.jpeg" /></figure><p>We used the back-testing data from 2021–08–01 to 2021–09–01. As you can see, the initial capital $20,000, and it realized profit by $7,326.69. The estimated APY is ~= 8293%.</p><p>But wait! the APY is just an estimation, APY may vary depending on market fluctuations.</p><p>Let me show you the real order history of the BollMaker strategy before we explain these details, here are some screenshots:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/0*GZFdnl60JXIfe3sj" /><figcaption>BBGO Trading Bot — BollMaker @ DOTUSDT</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/0*qOU-TSncUqrkIKOl" /><figcaption>BBGO Trading Bot — BollMaker @ DOTUSDT</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/0*KBhIjvsiiAe_d5M1" /><figcaption>BBGO Trading Bot — BollMaker @ BNBUSDT</figcaption></figure><h3>How Does It Work?</h3><p>The BollMaker Strategy uses the long-term period Bollinger Band to control the holding position.</p><p>The basic concept is, we assume the price will bounce between the long-term Bollinger band boundary. So, when the price goes up to the upper band, we reduce the position limit, and try to place sell orders as maker. If someone places a taker order to buy from your sell order, then you will sell your inventory.</p><p>On the other hand, when the price goes down to the lower band, we increase the position limit, and try to place buy orders as maker. If someone places a taker order to sell his inventory to you, then you will buy your inventory.</p><p>For example, when the price is close to the top of the Bollinger Band, we can set “the maximum amount of ETH to buy” is 0.1, and when the price is close to the bottom of the Bollinger Band, we can set “the maximum amount to buy” ETH to 10.</p><p>Therefore, through such price movements and dynamic control positions, we can use the spread in the market to buy low and sell high to make a profit.</p><p>The strategy locates the price in the band, and uses the exponential scale to calculate the inventory position limit — The lower the price, the higher the holding position.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KPeTcTn5_InEsjpb.png" /></figure><p>In this way, the cost of holding positions can be reduced by expanding the position.</p><p>By using the concept of average down the cost of position in a downtrend, and when the rebound pulls back to the upper band of the Bollinger Band, the position can be reduced. So as long as you have enough capital, you can make money in the market cycle.</p><p>Hence, it’s best to prepare the capital around ~$20,000 when you set the order amount at $20. (Above the minimal order size requirement of the crypto exchange). You will have $20,000/$20 = 1,000 times to average down your inventory cost.</p><h3>Appropriate Markets and Scenarios</h3><p>Basically, the main purpose of running the BollMaker strategy is to stock up. Stocking and escaping are two extremes. It is difficult to use the same set of settings to have both. Therefore, you need to choose an asset that you are willing to invest in the long-term, not to choose speculative coins to trade.</p><p>When you feel that the market is ready to start stockpiling, it is very suitable to run the BollMaker strategy.</p><p>It is recommended to run the currency with relatively high market cap, the trading volume is high, and the volatility is also high. Sometimes when large cap coins fall by 8%, some small cap coins can fall by 20% in one day.</p><h3>How to setup?</h3><p>🧑‍💻 Before you get started, if you like my automatic trading strategy, please give me some support and encouragement, and you can use the author’s referral code to register for Binance 🙏</p><p>Binance <a href="https://accounts.binance.com/en/register?ref=38192708">https://accounts.binance.com/en/register?ref=38192708</a></p><p>First, you need to prepare an API Key and an API Secret. If you don’t know API Keys, you can <a href="https://www.binance.com/en/support/faq/360002502072">check Binance’s FAQ page first.</a></p><p>Then, you need a Linux/MacOS environment, and a redis server for data persistency. (It will be used to store your profit stats and position information):</p><p>For Linux:</p><pre>sudo apt install redis</pre><p>If the redis package is not found, use redis-server instead:</p><pre>sudo apt install redis-server</pre><p>For Mac OS, you can use <a href="https://redis.io/docs/getting-started/installation/install-redis-on-mac-os/">brew</a>:</p><pre>brew install redis</pre><p>Now, you can use the automation script to set up your BBGO:</p><pre>bash &lt;(curl -s <a href="https://raw.githubusercontent.com/c9s/bbgo/main/scripts/setup-bollmaker.sh">https://raw.githubusercontent.com/c9s/bbgo/main/scripts/setup-bollmaker.sh</a>)</pre><p>This script downloads the latest BBGO release binary and set up your API key for BBGO.</p><p>And it should show you the following screen:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m8RlbkrED0Wc9Bbsq0iB9g.png" /><figcaption>BBGO — BollMaker Installer</figcaption></figure><p>What’s most important though, is that it gives you the bbgo binary also (the bbgo file), a bbgo.yaml config file and a .env.local file for storing your API secret.</p><p>If you don’t want to use the script, you can also download the bbgo.yaml file by yourself:</p><pre>wget <a href="https://gist.github.com/c9s/9a69dc6e17e418411c860ac8350bb939/raw/488d8972bb3e3077667758982fa82264db7eed82/bbgo.yaml">https://gist.github.com/c9s/9a69dc6e17e418411c860ac8350bb939/raw/488d8972bb3e3077667758982fa82264db7eed82/bbgo.yaml</a></pre><p>By default, the bollmaker configuration file looks like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d3ceb80b7845d7a8d09ea6009f93ce8/href">https://medium.com/media/4d3ceb80b7845d7a8d09ea6009f93ce8/href</a></iframe><p>Now, let me explain these parameters:</p><ul><li>symbol is the market symbol you want to trade. you can use BTCUSDT , BNBUSDT, or ETHUSDT something like that.</li><li>interval is the period that you want to replace your maker orders. 1m means it will cancel all open orders and re-place the maker order per minute. valid values are 1m, 5m, 15m , 30m</li><li>amount is the quote amount of your order. 30 for ETHUSDT market means you want to place a 30 USDT equivalent order to buy/sell ETH. You should have amount set at least above 20</li><li>quantity is the base amount of your order. 0.1 for ETHUSDT market means you want to buy/sell 0.1 ETH for each order. quantity can not be used with amount, you can only use either amount or quantity.</li><li>askSpread and bidSpread are the spread you want to place the order. BollMaker uses the mid price to place your maker order. For example, if mid price is 3000, with bidSpread=0.1% and askSpread=0.1%, we will place the buy order at price 2997 and sell order at price 3003. You can use candle chart to find out the amplification of each interval and use them.<br>In the best case, you should be able to have buy/sell orders trade per interval. Please note that the rate of transaction fees must be taken into account. On Binance, the maker fee rate is about 0.075%, so make sure your bidSpread + askSpread &gt; (0.075% * 2).</li><li>minProfitSpread is the spread from the average cost of your inventory. when Price ≥ AVERAGE_COST * (1.0 + minProfitSpread), then the sell order be will placed. You can set this number to a higher value like 1% or even 3% to prevent you sell the inventory too early.</li></ul><p>And then, the following section is the most important section:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*m31qpAbW6ksKLzbDjVzJlg.png" /></figure><p>domain -1 means the lower band of the long-term Bollinger band.</p><p>doamin 1 means the upper band of the long-term Bollinger band.</p><p>For example, if you would like to trade in ETHUSDT,</p><p>10.0 means, when the price goes down to the boundary of the lower band, you will have the maximum position limit at 10 ETH.</p><p>And 1.0 means, when the prices goes up to the boundary of the upper band, you will have the maximum position limit at 1.0 ETH. If your inventory is higher than the maximum position limit, it will not stop placing buy orders, until the sell orders are executed and filled.</p><ul><li>long means you don’t want to hold a short position. If short mode is enabled, it will sell the inventory that you already have in the spot wallet. You can turn on long when you think the price is low enough. And turn on short when you think the price is high enough.</li><li>buyBelowNeutralSMA is an option to limit the buy order — only place buy orders below the SMA of the neutral Bollinger band (the short-term Bollinger band)</li><li>tradeInBand — If this is set, when the price is out of the neutral Bollinger band (the short-term Bollinger band), it will stop placing buy order and sell order.</li><li>defaultBollinger — This is the Bollinger Band used for controlling the position limit. You can use TradingView or Binance’s KLines Chart to see which interval is preferred and works best for you.</li><li>neutralBollinger — This is the Bollinger Band used for detecting short-term trend.</li></ul><p>The default configuration is the best parameters as far as I know. so you should be able to run it directly.</p><p>It’s pretty straight-forward to run BBGO, simply type:</p><pre>./bbgo run</pre><p>You should then see the console logs from BBGO:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nSOJSW5H1FF7AzbJ07NiNQ.png" /></figure><p>As you can see, it calculates the max position limit per interval:</p><pre>calculated max exposure position: 2.02801869 strategy=bollmaker</pre><p>And following band is used for calculating the exposition position limit:</p><pre>bollinger band: up 2884.638519 sma 2824.866667 down 2765.094815 strategy=bollmaker</pre><p>And that’s it!</p><p>If you need any help with BBGO, you can create an issue in the <a href="https://github.com/c9s/bbgo">GitHub project</a>, or join our telegram group:</p><p><a href="https://t.me/bbgo_intl">BBGO International</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a4e80b482e3" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bbgo/bbgo-bollmaker-trading-strategy-3a4e80b482e3">BBGO — BollMaker Trading Bot</a> was originally published in <a href="https://medium.com/bbgo">BBGO</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Discovering BBGO]]></title>
            <link>https://medium.com/bbgo/discovering-bbgo-6f8c01d50532?source=rss-c82974340894------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f8c01d50532</guid>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[trading-bot]]></category>
            <dc:creator><![CDATA[c9s]]></dc:creator>
            <pubDate>Wed, 04 May 2022 15:57:03 GMT</pubDate>
            <atom:updated>2022-05-04T16:06:59.626Z</atom:updated>
            <content:encoded><![CDATA[<p>(This article was written by Arthur Wolf and has been authorized by the author)</p><p><a href="https://smoothieware.org/">I</a> discovered crypto a while ago, I was one of the users who lost Bitcoins in the 2013 hack of the MtGox exchange, and only a year after that I spent 300 BTC to buy a second-hand hard-drive.</p><p>Imagining where I would be if I had just hodl those coins in a cold wallet really stings.</p><p>Recently, looking back at those two bad decisions recently got me itching to get back into it, and around the beginning of the Corona Virus crisis, I started investing a bit of money into crypto again.</p><p>I also love programming, so I started looking into crypto bots.</p><p>At first, I used Kucoin’s <a href="https://kucoin.notion.site/kucoin/KuCoin-Trading-Bot-FAQ-a83bab1123094dea957851811a1a2fb7">Spot Grid</a> trading bot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cFHewJJz8XqU9HHF" /></figure><p>It works pretty well, and doing everything inside a web interface is nice, but it didn’t allow for much customization, and there were some features I wanted, and I had no way to add them.</p><p>So, I started to look into <a href="https://github.com/DeviaVir/zenbot">Zenbot</a>. It’s JavaScript (which I like), but it didn’t have Grid trading (the strategy I like most).</p><p>So I spent two months implementing grid trading into it. As I went, the quality of the code was so bad, and the performance so slow, that I spent much more time fixing/improving things than actually doing anything helpful.</p><p>I was about to give up, when just to make sure I didn’t miss anything, I searched once more for trading bot projects on GitHub, and found this new project named <a href="https://github.com/c9s/bbgo">BBGO</a>.</p><p>It was perfect. It natively did Grid trading (no need to add it myself), and it was BLAZZING fast (and the code was the cleanest of any such project I had seen).</p><p>The reason it’s important that the project be fast, in my use case, is that I use genetic (and other) optimization algorithms to find the best strategies (using back testing) to trade hundreds of coins at once. This results in running thousands of bots in parallel on a server. When I switched to BBGO, simulations that took weeks before with Zenbot, now took only hours with BBGO.</p><h3>Using BBGO</h3><p>Getting started with BBGO is pretty straightforward.</p><p>You can follow <a href="https://github.com/c9s/bbgo">the instructions</a> yourself, but here’s what I do:</p><p>1, I run the automated setup script:</p><pre>bash &lt;(curl -s https://raw.githubusercontent.com/c9s/bbgo/main/scripts/setup-grid.sh) binance</pre><p>Running it will give an output like this:</p><pre>╰─○ bash &lt;(curl -s https://raw.githubusercontent.com/c9s/bbgo/main/scripts/setup-grid.sh) binance<br>downloading...<br>% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current<br>								Dload  Upload   Total   Spent    Left  Speed<br>0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0<br>100 17.9M  100 17.9M    0     0  14.6M      0  0:00:01  0:00:01 --:--:-- 35.1M<br>downloaded successfully<br>Enter your BINANCE API key: test<br>Enter your BINANCE API secret: test<br>generating your .env.local file...<br>dotenv is configured successfully<br>config file is generated successfully<br>================================================================<br>now you can edit your strategy config file bbgo.yaml to run bbgo<br>you look like a pro user, you can edit the config by:</pre><pre>vim bbgo.yaml</pre><pre>To run bbgo just type: </pre><pre>./bbgo run</pre><pre>To stop bbgo, just hit CTRL-C</pre><p>This one is for the Binance exchange, and the grid strategy (this matters only in that it gives you “default” config files that reflect this).</p><p>What’s most important though, is that it gives you the bbgo binary also (the bbgo file), and a bbgo.yaml config file.</p><p>By default, the bbgo.yaml file looks like this:</p><pre>---<br>exchangeStrategies:<br>- on: binance<br>  grid:<br>    symbol: BTCUSDT<br>    quantity: 0.001<br>    gridNumber: 100<br>    profitSpread: 100.0<br>    upperPrice: 50_000.0<br>    lowerPrice: 10_000.0<br>    long: true</pre><p>This configures the strategy (here we&#39;re using Grid to trade BTC versus USDT).</p><p>Another important file is the ENV file (it&#39;s hidden, it&#39;s named .env.local ), it looks like this by default:</p><pre>BINANCE_API_KEY=test<br>BINANCE_API_SECRET=test</pre><p>(Of course, here you input your Binance API keys, instead of test).</p><p>Now that all of this is setup properly, you are ready to run BBGO yourself, simply do:</p><pre>./bbgo run</pre><p>And your adventure begins!</p><p>In other articles, we&#39;ll cover back testing, the database, optimizations, but for now this should do as an introduction.</p><p>If you need any help with BBGO, you can create an issue in the <a href="https://github.com/c9s/bbgo">GitHub project</a>, or email me at <a href="mailto:wolf.arthur@gmail.com">wolf.arthur@gmail.com</a></p><p>This article was written as part of our “ArticleForNewFeature” initiative, Arthur is the first participant. If you like BBGO and want to share your knowledge about it, you can write an article on any BBGO-related topic, and in exchange I will implement a new feature of your choice, and of a size matching your article.</p><p>DM <a href="https://t.me/c123456789s">me</a> if you’re interested in.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f8c01d50532" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bbgo/discovering-bbgo-6f8c01d50532">Discovering BBGO</a> was originally published in <a href="https://medium.com/bbgo">BBGO</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BBGO — 如何使用幣安現貨槓桿 Margin Trading]]></title>
            <link>https://c9s.medium.com/bbgo-%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8%E5%B9%A3%E5%AE%89%E7%8F%BE%E8%B2%A8%E6%A7%93%E6%A1%BF-margin-trading-1450261bbdc1?source=rss-c82974340894------2</link>
            <guid isPermaLink="false">https://medium.com/p/1450261bbdc1</guid>
            <category><![CDATA[槓桿交易]]></category>
            <category><![CDATA[加密貨幣]]></category>
            <category><![CDATA[幣安]]></category>
            <category><![CDATA[現貨交易]]></category>
            <dc:creator><![CDATA[c9s]]></dc:creator>
            <pubDate>Wed, 27 Apr 2022 09:29:03 GMT</pubDate>
            <atom:updated>2022-04-27T17:57:02.949Z</atom:updated>
            <content:encoded><![CDATA[<h3>BBGO — 如何使用幣安現貨槓桿 Margin Trading</h3><p>有很多朋友問 BBGO 能不能用現貨槓桿下單交易？可以的，但是<strong>請各位朋友一定要注意風險</strong>。</p><p>使用 2x 槓桿， 50% 的跌幅可能會造成你的清算。</p><p>使用 3x 槓桿，34% 的跌幅可能會造成你的清算。</p><p>現貨槓桿主要目的是為了提高資金利用率，因此在使用槓桿前，一定要先做好自己的 Plan B，你可以想成你有另外一份資金不方便挪移出來使用，所以先用現貨槓桿 (借款) 暫時頂替，到時候再償還債務 (Repay debt)。</p><p>在我們繼續下去之前，如果你喜歡筆者開發的自動交易策略，歡迎給筆者一點支持和鼓勵，可使用筆者的推薦碼註冊幣安, MAX 🙏</p><ul><li>幣安 <a href="https://accounts.binance.com/en/register?ref=38192708">https://accounts.binance.com/en/register?ref=38192708</a></li><li>MAX <a href="https://max.maicoin.com/signup?r=c7982718">https://max.maicoin.com/signup?r=c7982718</a></li></ul><h4>現貨槓桿 (Margin Trading) 如何使用?</h4><p>幣安的現貨槓桿 (Margin Trading) 怎麼使用呢？首先登入幣安的 App ，在 現貨交易 (Spot Trading) 的頁面，上面選擇 “Margin” (現貨槓桿)，如下圖:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H8Purx0gBI_MhZFxUczIsQ.jpeg" /></figure><p>這邊簡單解釋一下，幣安的 Margin Wallet 和 Spot Wallet 是不同的錢包，所以要使用現貨槓桿，你必須先把錢從 Spot Wallet 轉進 Margin Wallet 才可以做操作。</p><p>轉進 Margin Wallet 的資產，可以當成保證金，因此依照這個轉入資產的價值，你就可以借到不同倍率的資產。</p><p>幣安的 Margin Wallet 分成兩種， Isolated Margin 與 Cross Margin。</p><ul><li>Isolated Margin 顧名思義就是每個市場的部位是分開的，保證金也是分開的，舉例來說，每個用戶的 BTCUSDT 有獨立的 Isolated Margin Wallet, ETHUSDT 也有獨立的 Isolated Margin Wallet。 通常 Isolated Margin 可以使用的槓桿比 Cross Margin 大，不過看市場，交易量較大的市場通常可以到 10 倍槓桿。</li><li>Cross Margin 的話，就是所有的市場的現貨槓桿共用保證金、共用部位。 使用 Cross Margin 的話，最多可以做到三倍槓桿，好處在於保證金是共用的很彈性。</li></ul><h4>風險指標 Risk Ratio</h4><p>這個部分蠻重要的，請一定要看一下。 Risk Ratio 是指你現在這個 Margin Wallet 的風險指數，這個指數從 1.0 (危險) 到 999 (安全)。</p><p>他的算式其實是:</p><p>Margin Level (Risk Ratio) = Total Asset Value / (<strong>Total Borrowed + Total Accrued Interest</strong>)</p><p>中文的話:</p><p>風險指標 = 帳戶總淨值 / (債務 + 利息)</p><p>舉例來說:</p><ol><li>如果你先轉入了 2000 U 進 Margin Wallet，此時還沒有借款， Debt 為 0，那麼你的 Margin Level 就是 999。</li><li>如果你借了 1000 U ，還沒有利息，那麼你的 Margin Level 為 (1000U + 2000U) / 1000U = 3.0</li><li>接下來你用 LTC 300U 買了 10 顆 LTC，花了 3000U，此時 LTC 價格還沒變動，所以你的 Margin Level 還是 ~= 3.0 (扣掉手續費會有一些偏移)</li><li>但是接下來 LTC 從 300 跌到 290 了。 也就是你的總淨值從 10 LTC* 300 變成 10 LTC * 290 = 2900U。 此時 Margin Level 變成 2900U / (1000U + 0 Interest) = 2.9</li><li>這個時候你覺得可能要停損，控制好風險，所以你就還款了 200U，此時債務為 800U。 所以 Margin Level 就上升了一些 2700U / 800U = 3.375。</li></ol><p>這邊要注意，根據幣安的文件，如果你的 Margin Level 低於 1.3，幣安的系統會發出保證金請求 (Margin Call) 的通知:</p><blockquote>If your margin level drops to <strong>1.3</strong>, you will receive a <strong>Margin Call</strong>, which is a reminder that you should either increase your collateral (by depositing more funds) or reduce your loan (by repaying what you’ve borrowed).</blockquote><p>如果你的 Margin Level 低於 1.1，你的資產會自動被清算（因為你的帳戶總淨值快要無法償還過你的貸款了)</p><blockquote>If your margin level drops to <strong>1.1</strong>, <strong>your assets will be automatically liquidated</strong>, meaning that Binance will sell your funds at market price to repay the loan.</blockquote><h4>借款利息</h4><p>由於是借款，所以一定要注意利息的部分，特別是當你用滿 10x 槓桿的時候，利息有時還不少。</p><p>幣安的 Margin Interest 是每小時計費的，由於利率是浮動的，所以可以隨時查看這張<a href="https://www.binance.com/en/margin-fee">利率表</a>:</p><p><a href="https://www.binance.com/en/margin-fee">Binance - Margin Data</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_9oMDo7c2FjnmeLM2RUA0A.png" /><figcaption>Binance Margin Interest Rate Table</figcaption></figure><p>基本上大部分的幣種每日利率是 0.01% 到 0.02% 左右，所以假設每日利率為 0.02% 每小時利率為 0.02% / 24。</p><p>幣安官方文件提供的利率公式為:</p><p>I (interest) = P (borrowed money) * R (daily interest 0.02%/24) * T (in hours)</p><p>因此，假設我借款 1000 USDT, 12 小時，並且有 0.02% 的每日利率，那麼我的利息就是:</p><p>12 小時利息 = 1000 USDT * (0.02% / 24) * 12 = 0.1 USDT</p><p>此外，要注意，當你 Repay 的時候，一律先償還利息，之後剩下的金額才會拿來償還債務。 借不滿一小時的時候，則以一小時利息計。</p><h4>現貨槓桿下單行為 (MarginOrderSideEffect)</h4><p>下單介面的上方有一個 AutoBorrow 下拉選單，這個部分是選擇你的保證金下單行為 (Margin Order Side Effect)，主要分成幾種:</p><ul><li>Auto Borrow — 如果是做多，當你下買單的時候，USDT 不夠，自動幫你借到足夠的 USDT。 如果是做空，就是反過來，借的是 BTC。</li><li>Auto Repay — 如果是做多，當你下賣單的時候，自動幫你償還 USDT 的負債。如果是做空，就是反過來，還的是 BTC。</li><li>Normal — 不借也不還</li></ul><p>那麼如何在 BBGO 裡面使用這個 MarginOrderSideEffect 呢？就是下單的時候，在 SubmitOrder 結構裡面給設定 MarginOrderSideEffect:</p><ul><li>types.SideEffectTypeMarginBuy == auto borrow (幣安的 API 內部稱為 Margin Buy)</li><li>types.SideEffectTypeAutoRepay == auto repay</li><li>SideEffectTypeNoSideEffect == Normal</li></ul><p>其他現貨策略也可以直接在 Binance Margin 跑，只是它不會自動幫你借跟還，所以你需要先手動在 Margin Wallet 裡面點借 “Borrow” 或還 “Repay”。</p><p>其實手動借還相對來說是比較安全的，因為 Borrow 的時候在控制槓桿倍率方面來說會比較方便，如果是做兩倍，那就是最多借一倍的資金，如果是做兩倍，那就是最多借兩倍的資金。</p><h4>BBGO 的 Margin 設定</h4><p>由於 BBGO 支援多交易所連線，所以你可以在同一隻 BBGO 程式裡面連線多組幣安的連線，同時連線幣安的 Cross Margin 或多組 Isolated Margin 是可以的。</p><p>可參考以下設定 (當 isolatedMargin 沒有設定的時候就是 cross margin):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc38edcf73ecedc0f45f19ee112ecdb9/href">https://medium.com/media/bc38edcf73ecedc0f45f19ee112ecdb9/href</a></iframe><p>用法的部分呢，就是把掛策略設定的 on: sessionName 換成你的 margin session 名稱，例如:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2b3e92a9ff451aab059f1ac4574f9150/href">https://medium.com/media/2b3e92a9ff451aab059f1ac4574f9150/href</a></iframe><p>這樣一來，BBGO 所有的策略都可以使用現貨槓桿跑了~</p><p>最後~</p><p>如果你喜歡筆者開發的自動交易策略，歡迎給筆者一點支持和鼓勵，可使用筆者的推薦碼註冊幣安, MAX 🙏</p><ul><li>幣安 <a href="https://accounts.binance.com/en/register?ref=38192708">https://accounts.binance.com/en/register?ref=38192708</a></li><li>MAX <a href="https://max.maicoin.com/signup?r=c7982718">https://max.maicoin.com/signup?r=c7982718</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1450261bbdc1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BBGO — bollmaker 穿越牛熊的自動交易機器人]]></title>
            <link>https://c9s.medium.com/bbgo-bollmaker-%E7%A9%BF%E8%B6%8A%E7%89%9B%E7%86%8A%E7%9A%84%E8%87%AA%E5%8B%95%E4%BA%A4%E6%98%93%E7%AD%96%E7%95%A5-b573ba6625b3?source=rss-c82974340894------2</link>
            <guid isPermaLink="false">https://medium.com/p/b573ba6625b3</guid>
            <category><![CDATA[加密貨幣]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[trading]]></category>
            <category><![CDATA[自動交易機器人]]></category>
            <category><![CDATA[trading-bot]]></category>
            <dc:creator><![CDATA[c9s]]></dc:creator>
            <pubDate>Tue, 26 Apr 2022 04:54:29 GMT</pubDate>
            <atom:updated>2022-11-16T03:29:58.288Z</atom:updated>
            <content:encoded><![CDATA[<h3>BBGO — bollmaker 穿越牛熊的自動交易機器人</h3><h4>你還在用老派網格交易嗎? 試試新一代的 bollmaker 策略吧</h4><h4>網格交易</h4><p>其實經歷 2020 年到 2022 年這整整兩年的加密貨幣牛市，很多人應該都已經知道網格交易策略是什麼。</p><p>熟悉網格交易的朋友應該都知道，網格需要設定區間，所以，要不是你的區間設定得非常好，每次抓震盪區間都能夠抓到非常準確，就是你必須砸重金開張天地網格，設下非常大的區間和非常多的格數。 但是天地網格單其實資金利用率很低，因為震盪幅度每天可能 2%~5% 左右遊走，你的區間如果設定是 500% 的上下區間，那可能每天吃到的單就很有限，掛單只能吃到很小的範圍。</p><p>但是在牛市中，震盪區間常常接下來就是幅度不小的拉盤，如果你設定震盪區間網格，那麼每次價格突破你的震盪區間，網格就是一定會幾乎賣飛所有現貨。</p><h4>研發全新穿越牛熊交易策略 — bollmaker</h4><p>筆者這段時間一直在研究交易，在去年第二波新高回落時，思考什麼樣的策略有辦法穿越牛熊，也因此有了一些交易策略的靈感。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VvyKItidPzWtA9VXhm_5BQ.png" /><figcaption>2021 年末 ETHUSDT 走勢</figcaption></figure><p>如上圖，ETHUSDT 的 4h 小時線做肉眼回測，當時是在接近 ATH 4800 左右的位置，價格不斷在布林通道上下方震盪來回作出緩跌，每一次都會重新回到布林通道上方，才繼續開始下跌。</p><p>所以筆者利用布林通道加上部位控制的算法，研發出 bollmaker 這套使用雙重布林通道的造市策略，但沒想到效果意外地好，只要設定完，放著給他跑就可以應付各種價格區間，幾乎不用一直調整參數。</p><p>雖然是自己研發，又是開放原始碼，肯定會有人抄襲模仿，但是筆者不怕，原因是我們每週都持續在研發改進。</p><p>我們先來看 bollmaker 的回測績效:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*ZJ2XZtE4u4Of8_yotjSD3g.jpeg" /></figure><p>使用八月的資料來做回測，測試到九月初的超大暴跌，初始資本: 20,000 USDT+ 1 ETH，單月已實損益 +$7,326.69。</p><p>最關鍵的是，跑完策略後，維持未實現損益 UNREALIZED PROFIT: +$ 17.55</p><p>沒有過度 hold ETH 部位，也沒有提早賣飛 ETH 部位，如果用這個獲利來試算 APY 的話，約是 APY +3097%。</p><h4>bollmaker 實戰的下單位置</h4><p>先來看筆者跑 bollmaker 實戰的下單位置，這是幣安 App 的下單歷史顯示，S 是 Sell 賣單成交，B 是 Buy 買單成交:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/0*VpTetjoaz0s7mUYm" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/0*udA5Yb1VXn2C80mW" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/0*xKiMPqViQAP4WAoV" /></figure><h4>bollmaker 的基本原理</h4><p>其實 bollmaker 顧名思義就是他算是一種造市策略，透過利用在市場上創造流動性，同時在 mid price 上下方掛買單賣單，被動等其他人下單跟你成交來取得獲利。</p><p>但造市策略的天敵就是一路跌和一路漲，所以 bollmaker 透過兩個不同時間區間的布林通道來管控造市的下單。</p><p>長時間通道: 用來控制部位大小</p><p>短時間通道: 用來避免在強趨勢出現的時候下單</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WmAj4zAh7Wn-ZMFrdHclqw.png" /></figure><p>用上圖來解釋，如果我們長時間通道採用 30m，畫出來的布林通道大概是長這樣，價格根據常態分佈的機率 95.4 會在通道內遊走，因此我們抓下方通道用來囤貨，上方通道用來出貨來掛單，並依照通道的寬度去算出一個最大部位的分佈。</p><p>舉例來說，當價格靠近布林通道上方的時候，我們可以設定最多買 ETH 就是買到 0.1 顆，當價格靠近布林通道下方的時候，我們可以設定最多買 ETH 可到 10 顆。</p><p>所以透過這樣價格的遊走和動態的調控部位，我們就可以利用市場上的 Spread 價差來買低賣高獲利。</p><p><strong>bollmaker 是利用向下攤平的概念，在下跌趨勢中降低持有成本，並在反彈拉回的時候有機會能夠賣出並減碼，因此只要你本金足夠，就有辦法在市場週期中賺到錢。</strong></p><h4>BollMaker 適合的市場和情境</h4><p>基本上要跑 bollmaker 主要還是以囤貨為目的，<strong>囤貨和逃頂是兩個極端的面相，兩者很難用同一組設定兼得。 也因此，你需要去選擇一個你願意長期投資的資產來做操作，不要去選投機幣來跑。</strong></p><p>所以當你覺得現在市場行情可以準備開始囤貨，就很適合跑 bollmaker 策略。</p><p><strong>建議跑在市值相對高的幣種，成交量高，震盪也多</strong>，且因為市值高的幣種在空頭市場來的時候，跌幅也不會像很多小幣一樣這麼深。大幣跌 8% 的時候，有些小幣一天可以跌到 20%。</p><h4>BollMaker 策略的缺點</h4><p>醜話也是要先講在先，畢竟沒有策略能夠應付所有市場的極端情況。</p><p><strong>bollmaker 不怕急跌，因為這樣反而有機會在短時間內拉低持倉成本，但 bollmaker 的天敵是一路緩跌完全沒有回彈</strong> — 為什麼？因為價格要靠近布林通道上方的時候，我們才有機會開始減倉。</p><p>bollmaker 在掛單的時候，可採取每分鐘掛單一次，或是每五分鐘掛單一次，這可以自由設定，時間越短，成交頻率越高，獲利也會相對可觀，但在面對下跌的狀況，自然就會犧牲逃頂的特性。</p><p>剛剛上面有講到，bollmaker 是利用向下攤平的概念，在下跌趨勢中降低持有成本，並在反彈拉回的時候有機會能夠賣出並減碼，所以如果你的本金只有幾百美金是沒辦法跑的 — 為什麼? 因為交易所都有最小下單金額限制，通常是十美金，你每次掛單至少需要 10 美金，但你只準備 100 美金的話，就只有 10 次機會可以向下攤平，所以這樣會導致套牢的機率非常大。</p><p>根據筆者的實測，本金最少最少要能夠做 100~200 次以上的掛單，每單金額至少要 20U，也就是本金差不多需要 200 x 20 = 4000 是最小需求。</p><h4>市場價差 Spread</h4><p>由於 bollmaker 的獲利靠的是市場的<strong>波動性</strong>，所以交易所的主動成交波動性很重要，看的是市場上的 taker buy 和 taker sell。</p><p>價格波動性來講，Binance 還是比 FTX 高，如果希望成交頻率高的話，會比較推薦在幣安上面跑 bollmaker。 FTX 也不是不行，但頻率自然會低一點。</p><p>在 MAX 交易所的話，由於 <strong>MAX 交易所的手續費非常低，幾乎是幣安的一半以上</strong>，而且又特別容易升等 VIP，所以如果你要在 MAX 上跑可以掛更近，舉例來說幣安上如果掛 0.1% 的價差 (幣安手續費是 0.075%)，那在 MAX 上可以掛到 0.05% 的價差達到類似的效果。</p><p>如果你喜歡筆者開發的自動交易策略，歡迎給筆者一點支持和鼓勵，可使用筆者的推薦碼註冊幣安, MAX 或 FTX 🙏</p><ul><li>幣安 <a href="https://accounts.binance.com/en/register?ref=38192708">https://accounts.binance.com/en/register?ref=38192708</a></li><li>MAX <a href="https://max.maicoin.com/signup?r=c7982718">https://max.maicoin.com/signup?r=c7982718</a></li><li>FTX <a href="https://ftx.com/referrals#a=bbgo">https://ftx.com/referrals#a=bbgo</a></li></ul><h4>如何設定 bollmaker?</h4><p>如果你是工程師，對怎麼 build &amp; install 已經非常熟悉了，可以直接參考 bbgo 官方 repository 的文件做設置:</p><p><a href="https://github.com/c9s/bbgo">GitHub - c9s/bbgo: The modern cryptocurrency trading bot written in Go.</a></p><p>如果你都還不懂，也還沒有跑過 bbgo ，可以先看看下面這篇:</p><p><a href="https://c9s.medium.com/bbgo-%E5%9C%A8%E5%AE%B6%E4%B9%9F%E5%8F%AF%E4%BB%A5%E8%B7%91%E7%B6%B2%E6%A0%BC%E7%AD%96%E7%95%A5%E7%A8%8B%E5%BC%8F-cdb59e171cf9">BBGO — 在家也可以跑網格策略程式</a></p><p>如果各位已經 ready 了，那就可以開始來設定 bollmaker 了。 先來看筆者建議的設定:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4d3ceb80b7845d7a8d09ea6009f93ce8/href">https://medium.com/media/4d3ceb80b7845d7a8d09ea6009f93ce8/href</a></iframe><p>以上，我們先看到 persistence 有設定 redis。 bbgo 基本上要執行是可以不用 redis 的，但是因為我們需要紀錄部位資訊，重開 bbgo 之後也要能夠載入回來，所以這邊要設定一下 redis，沒有的話，可以裝一下:</p><pre>apt install redis</pre><p>繼續往下看到 exchangeStrategies 的部分，我們設定了 bollmaker ，設定細節如下:</p><p>interval 是你多久要下單一次， 1m 就是一分鐘，可使用的參數有 1m , 5m , 15m , 30m , 1h 等等，當然如果你使用越慢的掛單頻率，可以透過增加每次掛單金額來提高獲利率。</p><p>amount 是你每次的下單金額 (BNBUSDT 的話，是以 USDT) 計算，這邊寫 30，意味著我們下單的顆量是 $30 等值的 BNB 顆量 (Quantity)。 剛剛有講到，這邊的 amount 最少是你的本金 1/100 或甚至 1/200, 最好可以到 1/500。</p><p>spread 是掛單距離 mid price 的價差，所謂的 mid price 是 (第一檔賣單價格 + 第一檔買單加格) / 2。 通常設定 0.1% 左右，依照你的手續費比率來設定。 幣安是 0.075% ，因此我們這邊設定 0.1%。 如果是使用 MAX 交易所的話，可以設定 0.06% 左右。 spread 的設定跟 interval 參數有關，你可以打開線圖看每個分線的震幅 (Amplification)，只要小於這個震幅，成交頻率就會夠高。</p><p>long 是指我們的 bollmaker 只做多頭部位 (只增加持倉，不會一開始就減倉)，不會賣掉你原本帳號裡手動買的部位。</p><p>minProfitSpread 是指，當目前價格比持有成本高出 minProfitSpread 後，我們才開始掛賣單，這個數值越小越可以避險，但是在牛市也就越容易賣飛。</p><p>buyBelowNeutralSMA 是指，當價格在布林通道的 SMA 以下我們才開始掛買單，這個設定是用來應付空頭市場，如果在牛市，會建議不要啟用 (可改為 false)。</p><p>dynamicExposurePositionScale 就是我們用來調控部位的設定了，其中你看到 [-1, 1] 請不要去改他，你要修改的是 range ，-1 對應的就是布林通道下方， 1 對應的是布林通道上方。 也就是，如果設定 [100, 1] ，那麼你在布林通道下方最多就是買到 100 顆，上方最多買到 1 顆。 (這個部分的設定你可以一邊運行 bbgo 一邊依照需求修改，改完只要重啟 bbgo 即可)</p><p>defaultBollinger 這個就是用來控制部位的布林通道，詳細設定你可以用 TradingView 或是幣安的走勢圖選一個合適布林通道出來用，這邊建議不要抓太近抓到 5m 或甚至 15m 都太短。</p><p>neutralBollinger 這個是用來偵測短期趨勢用的布林通道，加上 tradeInBand 這個選項，如果超過這個布林通道的區間，bollmaker 就會暫停掛單。</p><p>最後，存檔好你的 bbgo 設定，就可以起飛:</p><pre>bbgo run</pre><p>如果懶得自己設定，有在用 Linode 的朋友也可以用筆者準備的 StackScript 做一鍵部署:</p><p><a href="https://cloud.linode.com/stackscripts/1002384">Linode Manager</a></p><p>☝☝☝ ️️️️Linode StackScript for BollMaker</p><p>最後~</p><p>如果你喜歡筆者開發的自動交易策略，歡迎給筆者一點支持和鼓勵，可使用筆者的推薦碼註冊幣安, MAX 或 FTX 🙏</p><ul><li>幣安 <a href="https://accounts.binance.com/en/register?ref=38192708">https://accounts.binance.com/en/register?ref=38192708</a></li><li>MAX <a href="https://max.maicoin.com/signup?r=c7982718">https://max.maicoin.com/signup?r=c7982718</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b573ba6625b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[requestgen — Golang API Client 整合新利器]]></title>
            <link>https://c9s.medium.com/requestgen-golang-api-client-%E6%95%B4%E5%90%88%E6%96%B0%E5%88%A9%E5%99%A8-a2311eb38b86?source=rss-c82974340894------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2311eb38b86</guid>
            <category><![CDATA[code-generator]]></category>
            <category><![CDATA[cryptocurrency-exchange]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[c9s]]></dc:creator>
            <pubDate>Sun, 02 Jan 2022 14:28:47 GMT</pubDate>
            <atom:updated>2022-01-03T03:27:16.591Z</atom:updated>
            <content:encoded><![CDATA[<h3>requestgen — Golang API Client 整合新利器</h3><p><a href="https://github.com/c9s/requestgen">requestgen</a> 和 <a href="https://github.com/c9s/callbackgen">callbackgen</a> 算是筆者在 2021 年末開發的兩個 Go 程式語言開發的新武器，不過時間有限，本文就先只介紹 requestgen。</p><p>requstgen 顧名思義就是 request generator，幫助你一鍵刻完 Request 程式碼。</p><p>開發 requestgen 的主要原因是最近幾年在整合加密貨幣交易所的 API，不斷地在重複做 API Client 開發的工作，但也因為 Go 程式語言對於型別的要求相較 Node.js 繁瑣，也因此型別欄位都必須定義清楚，在程式碼的撰寫上勢必得花更多功夫。</p><p>因此下定決心找時間利用 Go 1.5 之後的 go/ast, go/types 等 Go 編譯器的相關 API 來開發了一個 code generator。</p><p>不得不說，Go generate 真的是相當方便的一個工具，雖然 Go 還沒有泛型可以使用，但 Go generate 是目前最接近這樣性質的一個工具。</p><p>話不多說，先來看看 Go generate 可以用來幹嘛</p><p>一般來說，如果要開發一個 API request 的銜接，通常都要先開發一個 RESTful API Client 用來處理 HTTP Request 請求，和 HTTP Response 回應等等，如果要處理 Authentication 那就相對麻煩。 RESTful API Client 開發完之後，還要針對每一個 API Endpoint 處理 Request 的參數，有些使用 GET 要帶上 Query parameters，有些則使用 POST 同時帶上 Query parameters 和 Body parameters，對於 parameters 的處理，有些人使用相對彈性的 map[string]interface{} ，但這樣也沒有辦法很容易的對於欄位型別和欄位的值做驗證，而寫成 struct 這類的 data object，則要寫更多 getter, setter 的程式碼來處理。</p><p>譬如:</p><pre>req := client.NewPlaceOrderRequest()<br>orderList, err := req.Symbol(&quot;BTCUSDT&quot;).<br>   Price(&quot;3600&quot;).<br>   Quantity(&quot;1.0&quot;).<br>   OrderType(&quot;limit&quot;)<br>   Do(ctx)</pre><p>要寫出上面 API 的背後的實作，少則百行，除了要寫 struct 欄位，還得加上 setter, 以及最後處理參數驗證與 Request 發送的 Do method。</p><p>但有了 requestgen 之後，我們只需要描述 Request 與 Response 的結構即可。</p><p>首先是 struct 的部分，要從 API 文件上參考 JSON ，然後改寫成 struct ，這個部分剛好 GoLand 幫我們提供了一個工具可以在貼上 JSON 的時候自動轉成 Go struct ，非常方便。</p><p>接著，只要在這個 struct 上方加上一段 //go:generate requestgen 就可以自動產生對應的所有代碼，少寫相當多程式！</p><p>首先先把 requestgen 需要的 struct tag 加上:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2568ad75da144c9606f0cba643589ccb/href">https://medium.com/media/2568ad75da144c9606f0cba643589ccb/href</a></iframe><p>上方可以看到 param 這個 struct tag，便是用來定義 request 的 parameter 名稱。</p><p>而欄位的型別，只要是 pointer 型別，對 requestgen 來說就是可選欄位 (optional parameter) 如果沒有指定，就不會隨著 request 送出。</p><p>如果有驗定欄位的值，則可以使用 valid values 來定義，用 “,” 來分隔數值。</p><p>如果是必要欄位，則可在 param struct tag 加上 required 這個 option。</p><p>struct 的上方，可以看到一段 go:generate 開頭:</p><pre>//go:generate requestgen -type PlaceOrderRequest</pre><p>這就是告訴 requestgen 要產生 PlaceOrderRequest 這個 struct type 的 accessor methods。</p><p>上方是一個 Minimal example，還沒有完全滿足我們的需求，我們的重點還是在於這個最難處理的 Do(ctx) method。</p><p>因此在第二個範例，我們加上了更多 requestgen 的參數，包含 -method 與 -url 用來指定這個 API Request 調用的方法以及路徑，最後還有回傳的型別 -responseType ，請見下方範例:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/76ad147d39e4ddfbce0534ab67ade2f6/href">https://medium.com/media/76ad147d39e4ddfbce0534ab67ade2f6/href</a></iframe><p>其中，眼尖的讀者可能發現了我們在 struct 內的第一個欄位新增了一個 requestgen.AuthenticatedAPIClient 這個欄位。</p><p>這個型別其實是一個 interface，requestgen 在靜態剖析你的 struct 結構時，如果發現這個 interface，他就會知道原來你要發送的 API 是需要做 Authentication 的 API，會自動幫你呼叫實作 AuthenticatedAPIClient 這個介面的 NewAuthenticatedRequest 方法，它的原型如下:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1201249e5ac3e1d55dbe106bc8e84c6/href">https://medium.com/media/c1201249e5ac3e1d55dbe106bc8e84c6/href</a></iframe><p>只要你傳遞到 Request struct 中的 client 符合這個介面的需求，他就可以利用這個介面幫你介接你的 API Request 以及 API Response ，甚至 API Response 的 decoding (or unmarshaling)。</p><p>如此一來，requestgen 就會自動幫我們產生以下 Do(ctx) 的實作:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce0d7ab231c378438a1652c154f43c35/href">https://medium.com/media/ce0d7ab231c378438a1652c154f43c35/href</a></iframe><p>可能有些讀著覺得只是玩玩用的工具罷了，不，這可不是只是玩玩的工具，這個工具筆者已經正式用在 BBGO 的交易所介面開發，是有真實的應用，有興趣的朋友可以看看 kucoin API 的整合實作</p><p><a href="https://github.com/c9s/bbgo/blob/main/pkg/exchange/kucoin/kucoinapi/marketdata.go#L3">bbgo/marketdata.go at main · c9s/bbgo</a></p><p>以及 requestgen 本身附上的範例:</p><p><a href="https://github.com/c9s/requestgen/tree/main/example/api">requestgen/example/api at main · c9s/requestgen</a></p><p>如果有朋友有興趣甚至在使用後有些心得，也歡迎各位回饋意見。</p><p>—</p><p>最後一點無關的，如果還沒有 Kucoin 交易所帳號的朋友，也歡迎透過我下面的推薦連結註冊一下~</p><p><a href="https://www.kucoin.com/ucenter/signup?rcode=r3KX2D4">KuCoin | Cryptocurrency Exchange | Buy &amp; Sell Bitcoin, Ethereum, and More</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2311eb38b86" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BBGO Grid Trading on OKEx]]></title>
            <link>https://medium.com/bbgo/okex-grid-trading-with-bbgo-cd2f756d63e2?source=rss-c82974340894------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd2f756d63e2</guid>
            <category><![CDATA[okex]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[bbgo]]></category>
            <category><![CDATA[grid-trading]]></category>
            <dc:creator><![CDATA[c9s]]></dc:creator>
            <pubDate>Tue, 28 Dec 2021 17:20:18 GMT</pubDate>
            <atom:updated>2021-12-28T17:38:26.367Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://blog.coincodecap.com/go/okex"><strong>OKEx</strong></a> is one of the largest <a href="https://blog.coincodecap.com/crypto-exchange">crypto exchanges</a> that accounts for over $1.5 billion only from its futures trading platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WI95ubDYKusE5Njb.png" /></figure><p>BBGO is an open source crypto trading bot written in Go programming language, and it has a built-in grid trading strategy.</p><p>If you haven’t heard it, you can <a href="https://github.com/c9s/bbgo">check out the GitHub project here</a>.</p><p>This article will talk about how to run BBGO grid trading bot on OKEx.</p><p>First things first, you should have an OKEx account before you get started, you can <a href="https://www.okex.com/join/2412712?src=from:ios-share">register the OKEx account here with the referral code</a> to support BBGO.</p><p>After you registered your account, click the user icon on the top right of the web page, you shall see the “API” link. Click it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/341/1*tV-Agf5WgMu5exG3y4I6HQ.png" /></figure><p>And then click the “Create V5 API Key” button to create your API Key:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/179/1*eUlp7QuyQCV-ljCpOn598w.png" /></figure><p>You should see the API Key creation form like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/764/1*jT9aSstDVczpK7OoXW66fw.png" /></figure><p>Please give the key a name and choose on the “Trade” option. Then click on the “Create” button.</p><p>The API key will then be created, you should safely note or store the API key and API secret. We will use them later.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KmDyOCtj1OekhdLG.png" /></figure><p>To run BBGO, you need two files:</p><ol><li>bbgo.yaml the core configuration file. it contains the strategy configuration, risk management and exchange session configuration.</li><li>.env.local the dotenv file, it contains your API key, API secrets and other credentials.</li></ol><p>To set up the OKEx session with BBGO, you need a dotenv file, usually named “.env” or “.env.local”, let’s create a file named .env.local, and put your API key and API secret into the file:</p><pre>OKEX_API_KEY=1089cbbb-xxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>OKEX_API_SECRET=3Fxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<br>OKEX_API_PASSPHRASE=zzxxxxxxxxxxxxxxxxxxxxxxxxxxxx</pre><p>Now let’s create the bbgo.yaml file:</p><pre>---<br>sessions:<br>  okex:<br>    exchange: okex<br>    envVarPrefix: okex</pre><pre>exchangeStrategies:<br>- on: okex<br>  grid:<br>    symbol: BTCUSDT<br>    quantity: 0.001<br>    gridNumber: 200<br>    profitSpread: 5000<br>    upperPrice: 50_000<br>    lowerPrice: 46_000</pre><p>The above config content is in YAML format, which contains 2 sections, the first one is the session, you can see we defined the okex session.</p><p>And the second part is the exchange strategies, we defined one grid strategy on the okex exchange session.</p><p>We will explain the above parameters:</p><p>symbol means the market we want to trade.</p><p>quantity means how much quantity for each grid order.</p><p>gridNumber means how many grid orders do you want to place.</p><p>upperPrice means the highest price of this grid.</p><p>lowerPrice means the lowest price of this grid.</p><p>profitSpread means once your buy order is executed, what’s the profit spread of your sell order. for example, if you buy BTC at 46000 and your profit spread is 500, then it will place a BTC sell order at 46500 (46000 + 500).</p><p>The config files are ready, let’s download the bbgo binary from GitHub:</p><pre>curl -L -O <a href="https://github.com/c9s/bbgo/releases/download/v1.21.0/bbgo-slim-v1.21.0-24-gf78a7d37-linux-amd64.tar.gz">https://github.com/c9s/bbgo/releases/download/v1.21.0/bbgo-slim-v1.21.0-24-gf78a7d37-linux-amd64.tar.gz</a><br>tar xvf bbgo-slim-v1.21.0-24-gf78a7d37-linux-amd64.tar.gz<br>mv bbgo-slim-linux-amd64 bbgo</pre><p>And then we can start running bbgo!</p><pre>./bbgo run</pre><p>And that’s it!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A0lyfWiPxKQb4VGC4m1HHw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd2f756d63e2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bbgo/okex-grid-trading-with-bbgo-cd2f756d63e2">BBGO Grid Trading on OKEx</a> was originally published in <a href="https://medium.com/bbgo">BBGO</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[如何使用 MetaMask 連接 Polygon 測鏈]]></title>
            <link>https://c9s.medium.com/%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8-metamask-%E9%80%A3%E6%8E%A5-polygon-%E6%B8%AC%E9%8F%88-c3cb3176c475?source=rss-c82974340894------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3cb3176c475</guid>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[polygon-network]]></category>
            <category><![CDATA[matic-network]]></category>
            <category><![CDATA[metamask]]></category>
            <dc:creator><![CDATA[c9s]]></dc:creator>
            <pubDate>Thu, 25 Nov 2021 04:43:37 GMT</pubDate>
            <atom:updated>2022-11-20T13:29:28.657Z</atom:updated>
            <content:encoded><![CDATA[<h4>加密貨幣麻瓜都看得懂的一步步教學，附圖解。</h4><p>基於現在以太網路壅塞還有持續高昂的 Gas fee，現在以太網路已經變成早期以太持有者專用的區塊鏈網路了，怎麼說呢? 筆者光是在 Uniswap 上要做一個換幣的動作，就至少要付出 0.027ETH 等值 $117 美金的手續費!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/347/1*ilOWEpiFWCkPtnR9wR9R2g.png" /></figure><p>為了解決轉帳手續費高昂還有轉帳速度慢的問題，最近很多交易都已經改到一些以太網路的側鏈 (Sidechain) 上運作，譬如 Polygon Network</p><p>最近火紅的 Polygon 幣價也不斷往上… 光在去年的時候幣價才 0.01 元，現在已經漲到將近 1.78 左右，年中高點甚至達到 2.7。 Polygon 雖然幣價漲這麼多，但是在 Polygon 鏈上的手續費卻誇張的便宜，很多交易只需要 0.001 美元左右的手續費，這樣比起來是不是覺得以太網路很廢? 😂</p><p>註: Polygon Network 改名前為 MATIC Network</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6GMbWTNUNNvdHXV_eeiDHA.png" /></figure><p>什麼是側鏈呢？側鏈是一種跨區塊鏈的解決方案，透過這種解決方案，可以實現數位資產安全地從第一個區塊鏈到第二個區塊鏈的轉移，又可以從第二個區塊鏈轉移到第一個區塊鏈。</p><p>基本上你可以想像成就是把以太鏈上的資產，轉移並且轉換到其他替代性方案的鏈上去做轉帳、到 DEX 交易或做 FARMING 賺取利潤等等。</p><p>側鏈可以是獨立的區塊鏈，具有自己的帳本、共識機制、智能合約等。大部份情況下，側鏈可以不需要有自己的代幣 (Token)，譬如 Arbitrum 等等。</p><p>為了要讓數位資產可以在兩個區塊鏈上交換，兩邊通過雙向錨定（Two-way Pegging）的方式做橋接 (Bridging)。</p><p>簡單的說，在以太鏈上的 ETH，要進入到 Polgyon 鏈 (都是以太網路相容的鏈上) 就會換成在 Polygon 上的 WETH (Wrapped ETH)，這個 WETH 就是所謂的 Two-way Pegging Token。</p><p>而 Polygon 在以太網路上有部署一個橋接用的智能合約，當你從以太網路上轉移資產到 Polygon 上之後，他會自動呼叫 Polygon 鏈上的 WETH Token 合約去鑄造你的 WETH 出來轉移到你的帳戶。</p><p>當你要從 Polygon 鏈上轉移 WETH 出來到以太網路上變成 ETH 時，你是轉 WETH 到 Polygon 鏈上的智能合約，然後 Polygon 呼叫在以太網路的合約把當時轉進合約中的 ETH 還給你。</p><p>Polygon 支援所謂 Mint-able Asset Token，就是在跨鏈轉移資產的時候，或是你想要在 Polygon 鏈上鑄造 (Mint) 代幣的時候，自動去呼叫以太鏈上對應代幣的銷毀 (Burn)。</p><p>話說了這麼多，要怎麼連結 MetaMask 到 Polygon 呢? 以下提供幾個方法:</p><p>第一個簡單的方法，是透過 <a href="https://chainlist.org/">Chainlist.org</a> 這個網站，這個網站收集了所有側鏈的連線資訊，你只要點個按鈕就可以把這些側鏈加入到你的 MetaMask。</p><p>為了安全性，請一定要檢查網域名稱是否為 “chainlist.org”，現在有很多釣魚網站很可能會利用 chain1ist.org 這種把 L 換成 1 的網域來騙你連線你的錢包，把你的錢轉走。</p><p>首先點右上角的 “Connect Wallet”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tU7dQ6MRRK3Z0t2tW9_dKg.png" /></figure><p>這時候會跳一個視窗出來，請你確認連線:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*zcveYRLEhI-TjnLDCroffw.png" /><figcaption>Metamask Connect</figcaption></figure><p>接著點 “Next” ，Metamask 會再請你確認:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*prY-wFZwF8WIYT--VkxOIw.png" /><figcaption>Metamask Connect 畫面</figcaption></figure><p>再點 Connect ，就可以讓 chainlist.org 與 MetaMask 連線成功，但此時只是網站和你的 MetaMask 連線成功了，還沒有把 Polygon 加到你的 MetaMask 呢。</p><p>請在上方文字框框輸入 “Polygon”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*7XINROKzrxYaJY2wvHbUSQ.png" /><figcaption>chainlist.org search polygon</figcaption></figure><p>左邊的 Polygon Mainnet 就是 Polygon 的主要網路，點 “Add To Metamask”，會跳出一個視窗請你確認資訊，請一定要確認你使用的 Network URL, Chain ID 是否正確, Polygon 網路的 Chain ID 是 137。 <a href="https://polygon-rpc.com">https://polygon-rpc.com/ </a>則是 Polygon 官方提供的 Gateway:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*fVbCbo_aaJlMfSOmKv2Lsw.png" /></figure><p>請點選 Approve，之後會跟你確認是否要 Swtich 到 Polygon 網路:</p><p>如果你接著想使用 Polygon 網路，那麼可以選 Switch Network:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*J050pj9UxOZPZJjRNuNVTQ.png" /></figure><p>以上就是用 Chainlist.org 加入 Polygon 的方法。</p><p>第二個方法比較進階，適合進階使用者，是利用 MetaMask 的網路設定功能，手動輸入 Polygon 鏈的連線資訊，安裝 MetaMask 之後，點選瀏覽器右上方的小狐狸圖示:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/417/1*UQzCoogKKxY8XXoVtlXnIg.png" /></figure><p>點開之後，選網路的下拉選單:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*50_QTBOCvmJ7kivzybsndQ.png" /></figure><p>接著點 “Add Network”，此時 Chrome 會跳出一個分頁，只要照著畫面輸入即可:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*uciq0kDpT3txdJu9wL7umw.png" /><figcaption>MetaMask Settings -&gt; Add a network</figcaption></figure><p><strong>Network Name</strong> 輸入 <strong>Polygon</strong></p><p><strong>New RPC URL</strong> 輸入 <a href="https://polygon-rpc.com/">https://polygon-rpc.com/</a></p><p><strong>Chain ID</strong> 輸入 <strong>137</strong></p><p><strong>Currency Symbol</strong> 輸入 <strong>MATIC</strong></p><p><strong>Block Explorer URL</strong> 輸入 <a href="https://polygonscan.com">https://polygonscan.com</a></p><p>最後按下 Save 即可。</p><p>如果你喜歡我的文章或是想要支持 BBGO 自動交易機器人，歡迎使用我的幣安推薦碼取得 5% 手續費回扣，支持 <a href="https://twitter.com/hashtag/bbgo?src=hashtag_click">#bbgo</a> 開發</p><p><a href="https://accounts.binance.com/en/register?ref=VGDGLT80">Bitcoin Exchange | Cryptocurrency Exchange | Binance</a></p><p>👆👆👆</p><p>你也可以點以下連結加入 BBGO 的 Telegram 群組，筆者會不定期提供加密貨幣市場相關的資訊:</p><p><a href="https://t.me/bbgocrypto">BBGO 加密貨幣情報</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3cb3176c475" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[新手如何入門永續合約?]]></title>
            <link>https://c9s.medium.com/%E6%96%B0%E6%89%8B%E5%A6%82%E4%BD%95%E5%85%A5%E9%96%80%E6%B0%B8%E7%BA%8C%E5%90%88%E7%B4%84-1c6c755ebca4?source=rss-c82974340894------2</link>
            <guid isPermaLink="false">https://medium.com/p/1c6c755ebca4</guid>
            <category><![CDATA[加密貨幣]]></category>
            <category><![CDATA[永續合約]]></category>
            <dc:creator><![CDATA[c9s]]></dc:creator>
            <pubDate>Sat, 25 Sep 2021 09:02:22 GMT</pubDate>
            <atom:updated>2021-09-25T09:02:22.436Z</atom:updated>
            <content:encoded><![CDATA[<p>最近有非常多朋友剛進入幣圈，最常問的就是如何入門永續合約?</p><p>真的聽過太多玩合約一開始暴賺，入金一次比一次又更多，市場突然轉向插針，就全部沒了，不只錢全部還給市場，本金也一次虧光。 目前聽到周遭爆倉最多的是 42 萬 USDT。</p><p>幫你換算一下 42 萬 USDT 可以買到什麼而且不會不見的東西:</p><p>ETH 2,800 的價錢你可以買 150 顆 ETH</p><p>BTC 42,000 的價錢，你可以買 10 顆 BTC</p><p>LINK 24 的價錢，你可以買到 17,500 顆 LINK</p><p>Crypto Market 的市場比傳統期貨市場更難做，如果你本來就不是期貨操盤手，勸你真的別把錢捐給幣安</p><p>以下就教大家怎麼開始操作永續合約</p><p>如果你真的還是要投合約:</p><p>請把 USDT, ETH 轉到以下 ETH 地址</p><p>0xeBcf7887A5b767DEb2e0C77E46A22c6Adc64E427</p><p>這樣就可以支持 BBGO 開發還有作者的文章～ 非常感謝 ❤️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1c6c755ebca4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[蕭邦練習曲練習心得 Chopin Etude Op25 №6]]></title>
            <link>https://c9s.medium.com/%E8%95%AD%E9%82%A6%E7%B7%B4%E7%BF%92%E6%9B%B2%E7%B7%B4%E7%BF%92%E5%BF%83%E5%BE%97-chopin-etude-op25-6-32733c024c8f?source=rss-c82974340894------2</link>
            <guid isPermaLink="false">https://medium.com/p/32733c024c8f</guid>
            <category><![CDATA[蕭邦練習曲]]></category>
            <category><![CDATA[練習曲]]></category>
            <category><![CDATA[chopin]]></category>
            <category><![CDATA[蕭邦]]></category>
            <dc:creator><![CDATA[c9s]]></dc:creator>
            <pubDate>Sat, 18 Sep 2021 14:46:11 GMT</pubDate>
            <atom:updated>2021-09-18T16:34:03.203Z</atom:updated>
            <content:encoded><![CDATA[<h3>蕭邦練習曲 Chopin Etude Op25 №6 練習心得</h3><p>這是蕭邦練習曲中有名的三度雙音練習曲，也是號稱最難的練習曲（之一），不過蕭邦練習曲裡面似乎沒有什麼不難的就是了。 😂</p><p>蕭邦在寫這些練習曲的時候正氣血方剛的年紀，他在每首練習曲裡面，特別都塞了一些特別變態的片段，就是讓你練個千百萬次都不一定能不彈錯音，所以這篇就來談談這首練習曲到底哪邊變態 😂</p><p>當初選擇練習這首練習曲 (筆者一直是自學)，除了我把 “練完 Chopin Etude Op10” 列為我這十年內要練完的目標之外，主要是我自己在練李斯特弄臣的三度雙音過門覺得不夠快不夠乾淨，所以決定也把這首加入我的練習菜單裡。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zezYMfHEYFjhYcRpVhBv7w.png" /><figcaption>李斯特弄臣的三度雙音過門片段</figcaption></figure><p>不過，開始練蕭邦的 Etude op25 no.6 之後才發現事情和我想的不一樣。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J29qnGDNAKZPkVG_vGb4cw.png" /><figcaption>Chopin Etude Op25 №6 譜例</figcaption></figure><p>其實第一頁的這個雙音，和其他部分比起來都算簡單，這個部分主要難的地方是 14, 25 在彈的時候音色要穩定且快速，有時候雙音在彈奏時，有些手指可能會因為速度跟不上而導致音沒有對齊。</p><p>如果你試著挑戰這首時，如果第一頁就已經無法克服，真的建議先換別首練。</p><p>後來我在練習的過程中發現這首練習曲的基礎，其實是 Chopin Etude No10 №2，為什麼呢？因為雙音其實很依賴 3,4,5 指轉換彈奏半音階的速度還有力道，如果 4,5 指不夠結實，控制力不好，彈奏出來的雙音就很容易不整齊。 所以我回到 Chopin Etude Op10 №2 一起合併練，練了一段時間之後發現真的很有幫助。不過 Chopin Etude No10 №2 又是另外一個難到炸的黑洞，就之後再談了。</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WcNMqPIYuur6eJ-A.jpg" /><figcaption>Chopin Etude Op10 №2 譜例</figcaption></figure><p>Op25 №25 的第一道真正的關卡其實是在第二頁附近的這段:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rm2fEqeu5Fkl0kiH6ZnDaQ.png" /></figure><p>也是我目前查過資料最多人卡關的一段，左手彈奏出主旋律的同時，右手必須連續圓滑彈奏下行的雙音。 差不多就是在 31, 21 要轉 53 這邊，如果彈不好，就很容易斷掉。 31, 21 這邊則需要快速點過，大拇指的反應跟速度也要夠快。 21 轉 53，則需要帶一點手腕。 要完全克服這邊，還是老話一句，慢練而且需要花很長一段時間練習。XD</p><p>這邊有些 Online Course 會建議這一小節的每組雙音，拆成兩個兩個反覆練習，慢慢把手指肌肉練出來，克服彈奏下行音階的不同手形。 (個人的心得是手形不同，肌肉使用的方式也會不太一樣，需要分開練習)</p><p>接下來第二道關卡也是下行的雙音，但音型不同，右手必須在 12 與 345 反覆交換彈奏，而且橫跨黑鍵下行:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XCSDrdX6XP_ZkAIyb4z9-Q.png" /></figure><p>這邊為了能夠快速的在黑鍵白鍵切換，手的位置會需要稍微深入琴鍵一點才會比較好彈奏，而因為靠近琴鍵的力矩中心，會需要花更多一點的力氣，一樣，慢練可以讓肌肉逐漸快速抓到好的位置，而且可以讓音變得更平均。</p><p>這段後方有一段雙手一起來的雙音過門，雖然看起來恐怖，但其實難度比起來相對容易多了，基本上指法就是 53, 21 反覆下行:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iRCBXQgfDhH_w0dddKYQJw.png" /></figure><p>最後一段關卡，也是不同手形的雙音半音階下行，這一段有些鋼琴家會用左手輔助彈奏，不過有些鋼琴家比較硬派，全靠右手彈完，也是一樣 12 轉 53 需要靠點手腕轉換位置:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*NnrPP-y29xVM2xpjWGDXtQ.png" /></figure><p>以上這幾段關卡算是整首裡面特別難的部分，每次拆出來分開練習，對於彈奏技巧會很有幫助，對後面使用到的音型都算相對容易了。</p><p>P.S. 由於筆者一直是自學古典鋼琴，如果有錯的部分就再請各位多多指教了。</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32733c024c8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>