Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Go Crypto Trading

7490b4e3e9cb85a1f7dc0c8ea01a86e5?s=47 Yo-An Lin
November 21, 2020

Go Crypto Trading

In the slides, we introduce the background of Bitcoin's origin, explain public finance, and why decentralized finance might work. Lastly, introduce BBGO's trading framework and the strategies.

7490b4e3e9cb85a1f7dc0c8ea01a86e5?s=128

Yo-An Lin

November 21, 2020
Tweet

Transcript

  1. Yo-An Lin (c9s) 2020 Nov 1 Go Crypto Trading Build

    your own crypto trading bot in few minutes.
  2. Cryptos? Really?

  3. 2008 Bitcoin

  4. Let’s go back to 2008

  5. None
  6. Bank-based Financial System

  7. Public Finance

  8. How Government Bond Works Interest

  9. How Corporate Bond Works? Interest Issue corporate bond Corporate Fund

    Individuals Individuals Individuals
  10. How Junk Bond Works? Interest (high yield) Issue corporate bond

    Corporate (Low Credit Rating) Bank Investor High yield bond
  11. Securitization Bundled Mortgages Bank Investor Investor Investor

  12. Government National Mortgage Association 吉利美

  13. Government Sponsored Enterprise 房地美

  14. 名稱都有 Government

  15. 其實都是私⼈機構

  16. 房利美可以購買非政府擔保的房貸債權 並證券化來發⾏抵押債券

  17. 吉⼒美只為抵押債券提供擔保 沒有美國政府信⽤擔保

  18. None
  19. Bank Run 銀⾏擠兌

  20. QE Corporation (Low Credit Rating) Corporation Financial Institutions Lower Interest

    Rate
  21. None
  22. Yes, Your Bank Can Fail

  23. This is not the first time

  24. 存在銀⾏裡的錢 銀⾏會拿去投資

  25. 不同銀⾏的投資比例不同

  26. 虧錢的投資變成壞帳

  27. 授信弊案也會變成壞帳

  28. None
  29. 1930 年經濟⼤蕭條

  30. Glass-Steagall Act 格拉斯-斯蒂格爾法案

  31. 對美國銀⾏系統進⾏改⾰的法律,描述了 1933年銀⾏法分離商業銀⾏和投資銀⾏ 業務的四個規定 美國聯邦存款保險公司是依此法成立。這 部法律的⽬的在於對投機採取⼀些控制措 施。

  32. 允許聯邦儲備系統調節存儲帳號的利息, 被1980年儲蓄機構解除管制和貨幣控制 法取消 禁⽌銀⾏控股公司擁有其它⾦融公司的規 定被1999年11⽉12⽇⽣效的⾦融服務法 現代化法案取消

  33. 那 2008 年之後呢?

  34. 沃爾克法則 由美聯儲1979-1987年的前主席、前任美國 總統經濟複蘇顧問委員會主席 Paul Volcker 提出

  35. 禁⽌銀⾏從事⾃營性質的投資業務 禁⽌銀⾏擁有、投資或發起對沖基⾦和私募 基⾦

  36. 那現在呢?

  37. None
  38. None
  39. 歷史⼀直在重演

  40. ⽤區塊鏈達成去中⼼化⾦融 Decentralized Finance

  41. 由機器來⾃動處理轉帳、放貸

  42. None
  43. 有⼈把 Bitcoin 視為

  44. 美元或歐元以外的避險資產

  45. None
  46. Bitcoin 2019~2020 1w interval

  47. 為何要做加密貨幣交易?

  48. 傳統⾦融市場

  49. 開盤時間 收盤時間

  50. 交易額度限制

  51. 漲停跌停

  52. 相對封閉的市場

  53. 加密貨幣⾦融市場

  54. 24H 全年無休交易所

  55. 可隨時轉出轉入全球交易所

  56. 新世代的交易系統

  57. 以及更有效率的撮合引擎

  58. 相對透明的交易市場

  59. None
  60. 為什麼要⾃動交易?

  61. 情緒⼲擾交易

  62. None
  63. None
  64. None
  65. None
  66. 正確的交易⼼態 Trading Attitude

  67. 我對錢沒有興趣

  68. Algorithmic Trading

  69. Algorithmic trading is a method of executing orders using automated

    pre-programmed trading instructions accounting for variables such as time, price, and volume. This type of trading was developed to make use of the speed and data processing advantages that computers have over human traders.
  70. Quantitative analysis is the use of mathematical and statistical methods

    (mathematical finance) in finance. Those working in the field are quantitative analysts (or, in financial jargon, a quant).
  71. None
  72. James Simons American mathematician, Billionaire hedge fund manager, Former research

    staff of the Communications Research Division of the Institute for Defense Analyses (IDA)
  73. ⽂藝復興是全世界名氣最響的對沖基⾦公司之⼀,其創始⼈詹姆斯· ⻄蒙斯 (James Simons) 堪稱傳奇⼈物。他有很多外號,比如“華爾 街最賺錢的數學家”、“全球最賺錢的基⾦經理”、“量化交易之 ⽗”等。 Renaissance Technologies

  74. 根據彭博社億萬富翁指數 (Bloomberg Billionaire Index) 顯⽰,Simons 在 2016 年的⾝家⼤約值 155 億美元左右。根據

    Hedge Fund Research 報導,James Simons 在 2016 年的收入為 16 億美元,位於世界對沖基⾦經理收入榜單⾸位。
  75. ⼤獎章對沖基⾦ 成立於 1988 年。“⼤獎章”是⼀個典型的量化“⿊盒⼦”基⾦,其交易策 略都是基於複雜的電腦程式碼和演算法,外⼈無從知道它的交易規 則。 Medallion

  76. The Man Who Solved the Market: How Jim Simons Launched

    the Quant Revolution
  77. 交易策略 Trading Strategy

  78. 選擇交易商品

  79. 定義進場與出場條件

  80. • Market neutral strategy • Swing trading strategy • News

    trading strategy • Signal trading strategy • Day trading • ……
  81. Market Neutral Strategy

  82. Pure Market Making

  83. Place Sell Order Place Buy Order

  84. Cross Exchange Market Making

  85. Hedging is a strategy for reducing exposure to investment risk.

    An investor can hedge the risk of one investment by taking an offsetting position in another investment. The values of the offsetting investments should be inversely correlated.
  86. Cross Exchange Market Making

  87. Cross Exchange Market Making

  88. SELL BUY BUY BACK SELL Hedge Low Risk

  89. Swing Trading

  90. None
  91. Grid Trading

  92. None
  93. Bollinger-Band Grid Trading

  94. upper price lower price

  95. BBGO The Open Source Crypto Trading Framework

  96. BBGO Trading framework • Open Source & Transparency - you

    run what you can see. • KISS principle designed framework - simple, easy to use for users. • Minimalist design strategy interface - ~20 lines go code to implement a new strategy. • One config to rule them all. • Multi-exchange session support. • Run multiple strategies in one process.
  97. None
  98. Exchange RESTful API WebSocket FIX protocol BBGO Balance Update Trade

    Update Order Update Place Order Matching Engine Order Book Strategy #1 Strategy #2 Strategy #3 Public Market Data
  99. Public Market Data?

  100. None
  101. Bid Orders Ask Orders

  102. 買單掛的價格未成交,會被掛在買單簿上 = maker 賣單掛的價格未成交,會被掛在賣單簿上 = maker

  103. Best Bid Best Ask

  104. Best Bid Sell Order @ 16,342.75 賣單直接與買單成交 = taker

  105. Best Ask Buy Order @ 16,342.76 買單直接與第⼀檔賣單成交 = taker

  106. One Config File to Run Multiple Strategies

  107. exchangeStrategies: - on: binance bollgrid: symbol: BTCUSDT interval: 5m gridNumber:

    20 quantity: 0.01 profitSpread: 30.0 策略可以掛在任何⼀個交易所
  108. exchangeStrategies: - on: binance bollgrid: symbol: BTCUSDT interval: 5m gridNumber:

    20 quantity: 0.01 profitSpread: 30.0 策略設定檔
  109. 基礎風險控制

  110. riskControls: sessionBased: # "binance" is the session name that you

    want to configure the risk control binance: # orderExecutor is one of the risk control orderExecutor: # symbol-routed order executor bySymbol: BTCUSDT: # basic risk control order executor basic: minQuoteBalance: 100.0 maxBaseAssetBalance: 3.0 minBaseAssetBalance: 0.0 maxOrderAmount: 1000.0 下單的風險控管
  111. 開發⾃⼰的交易策略? Writing your own trading strategy?

  112. You Only Need Two Methods

  113. type Strategy struct { Symbol string `json:"symbol"` } func (s

    *Strategy) Subscribe(session *bbgo.ExchangeSession) { } func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error { return nil }
  114. Connecting Your Strategy

  115. func init() { bbgo.RegisterStrategy("skeleton", &Strategy{}) } type Strategy struct {

    Symbol string `json:"symbol"` } func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) { session.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: "1m"}) } func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error { session.Stream.OnKLineClosed(func(kline types.KLine) { _, err := orderExecutor.SubmitOrders(ctx, types.SubmitOrder{ Symbol: kline.Symbol, Side: types.SideTypeBuy, Type: types.OrderTypeMarket, Quantity: 0.01, }) if err != nil { log.WithError(err).Error("submit order error") } }) return nil } 註冊交易策略
  116. func init() { bbgo.RegisterStrategy("skeleton", &Strategy{}) } type Strategy struct {

    Symbol string `json:"symbol"` } func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) { session.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: "1m"}) } func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error { session.Stream.OnKLineClosed(func(kline types.KLine) { _, err := orderExecutor.SubmitOrders(ctx, types.SubmitOrder{ Symbol: kline.Symbol, Side: types.SideTypeBuy, Type: types.OrderTypeMarket, Quantity: 0.01, }) if err != nil { log.WithError(err).Error("submit order error") } }) return nil } 策略的 struct, ⽤來讀設定
  117. func init() { bbgo.RegisterStrategy("skeleton", &Strategy{}) } type Strategy struct {

    Symbol string `json:"symbol"` } func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) { session.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: "1m"}) } func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error { session.Stream.OnKLineClosed(func(kline types.KLine) { _, err := orderExecutor.SubmitOrders(ctx, types.SubmitOrder{ Symbol: kline.Symbol, Side: types.SideTypeBuy, Type: types.OrderTypeMarket, Quantity: 0.01, }) if err != nil { log.WithError(err).Error("submit order error") } }) return nil } 策略訂閱 K-line 資料
  118. func init() { bbgo.RegisterStrategy("skeleton", &Strategy{}) } type Strategy struct {

    Symbol string `json:"symbol"` } func (s *Strategy) Subscribe(session *bbgo.ExchangeSession) { session.Subscribe(types.KLineChannel, s.Symbol, types.SubscribeOptions{Interval: "1m"}) } func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, session *bbgo.ExchangeSession) error { session.Stream.OnKLineClosed(func(kline types.KLine) { _, err := orderExecutor.SubmitOrders(ctx, types.SubmitOrder{ Symbol: kline.Symbol, Side: types.SideTypeBuy, Type: types.OrderTypeMarket, Quantity: 0.01, }) if err != nil { log.WithError(err).Error("submit order error") } }) return nil } K-line 結束就下單
  119. 內建布林網格通道策略 Built-in Bollinger Grid Strategy

  120. 網格到底賺錢嗎?

  121. 固定價格區間網格

  122. 固定價位網格獲利能⼒

  123. BTC HODL

  124. 抱著 BTC 不動 都賺得比固定網格多

  125. 鄉⺠曬單通常都曬 ETH 因為波動比 BTC ⼩

  126. 答案是可以 但是可以賺更多嗎?

  127. 讓網格不要再進場

  128. 價格拉升速度快突破 EWMA 很多的時候預計會有拉回,不要再下買單

  129. 獲利多⼀倍

  130. Thank You

  131. Disclaimer: TradeAtYourOwnRisk

  132. 投資⼀定有風險,基⾦投資有賺有賠,申購前應詳閱公開說明書。

  133. 可能沒時間 Q & A 但可以來我們公司找我討論

  134. None
  135. 全台第⼀家加密貨幣實體⾨市 ⾨市⼈員與客⼾⾯對⾯介紹交易 平台產品 同時活動展演廳不定時會舉辦區 塊鏈主題講座與知識課程,活絡 加密貨幣社群與開拓新會員。

  136. MAX 9USDT REFERAL https://bit.ly/max-9usdt