發表文章

目前顯示的是有「Strategies」標籤的文章

Gekko 交易機器人 - TEMA 策略 (Triple EMA strategy),附帶有安全網機制 (SafetyNet) 來避免在熊市被套牢

圖片
這是一個以 EMA (指數移動平均) 決定做多做空的交易策略, 但當短期趨勢超過了 EMA 線則會在上方使用一個更長時間的 SMA (簡單移動平均) 作為整個交易系統的安全網 (SafetyNet) ,在短期的 SMA 超越這個安全網前會避免任何可能被套牢的交易。所以簡單理解的概念就是在市場看多的時候進行交易,而市場下跌時則避免摻入其中,但實際上的運作狀況仍然有待測試。 JS Code : /* TEMA Triple EMA strategy with 'safety net' --- Uses 1x TEMA to go long/short if short trend is over TEMA. On top of this it uses a longer SMA as a safety net and simple stays out of the market if short SMA is under that SMA. --- The general idea is to buy in good market conditions and simply not be a part of longer downwards trends. */ // req's var log = require ('../core/log.js'); var config = require ('../core/util.js').getConfig(); // strategy var strat = { /* INIT */ init: function() { // base this.name = 'TEMA'; this.requiredHistory = config.tradingAdvisor.historySize; this.debug = false; // outputs messages, set to false to increase performance // add indicators and reset trend this.resetTrend(); this.addTulipIndicator...

[ 2/14 更新] Gekko 交易機器人 - 策略 (Strategies) 彙整,整理網路上找到的交易策略

Gekko 的交易策略 (Strategies) 在網路上有非常多資源,這篇會整理列出實測過可以使用的策略,但不保證它的表現和收益一定合乎預期,甚至有些策略即使在預設的參數下也沒辦法發揮的非常好,不過對於有興趣開發策略的人來說這些應該都是不錯的範本,這些策略都不是出自於我,只是提供一個整理和參考,實際的使用情況我也不負任何責任,敬請使用 Backtest 或模擬交易功能來測試策略,不要輕易使用真實資金冒險。 I DO NOT OWN THESE AMAZING STRATEGIES. If you are the original author of the strategies and you don't want these to post on this site, please contact me. I'll remove it asap and I'm sincerely sorry to offended your copyright. aroon_public (2/14 更新) 需要安裝 : helper.js JS File :  http://justhodl.ml/strat/TEMA.js Toml File : http://justhodl.ml/strat/TEMA.toml 來源 Source : https://github.com/tommiehansen/gekko_tools TEMA (2/12 更新) 需要安裝 : 無 JS File :  http://justhodl.ml/strat/aroon_public.js Toml File : http://justhodl.ml/strat/aroon_public.toml 來源 Source : Discord @shop bestone-updated-hardcoded-config 需要安裝 : npm install lodash async JS File :  http://justhodl.ml/strat/bestone-updated-hardcoded-config.js Toml File : http://justhodl.ml/strat/bestone-updated-hardc...

Gekko 交易機器人 - 基於 ConvNetJs 深度學習 (Deep Learning) 框架的交易策略 (Strategy),隨時間市場自動調整參數

圖片
這是一個在 Discord 群翻到的 Gekko 策略,它本身並沒有 .toml 檔也就是沒有參數需要設置, 因為它的參數是隨市場、時間自動運算的 ,但跟之前以 MA 線判定牛 / 熊市的 RSI 策略 又不太一樣,因為 RSI 那個策略是固定的兩組參數,簡單來說市場對策略來說非牛即熊,並不能真的很有彈性地去變化。 但原作者也有提到 Neural Network 的策略並不是簡單的複製貼上,你必須要了解它的內容和原理才能真正使用它。 這是一個基於 ConvNetJs 深度學習框架的交易策略,光是需要載入的程式庫就一大堆, 但卻沒有用到技術指標和 Gekko 內建的 Tulip、TA-Lib ,真正跑起來運算量也比一般策略大上不少 ,有興趣的人可以把策略拆開來研究研究。 Js Code :  var convnetjs = require('convnetjs') var z = require('zero-fill') var stats = require('stats-lite') var n = require('numbro') var math = require('mathjs') const cluster = require('cluster'); const numCPUs = require('os').cpus().length; var _ = require('lodash'); var gauss = require('gauss'); const deepqlearn = require('convnetjs/build/deepqlearn'); var log = require('../core/log.js'); // the below line starts you at 0 threads global.forks = 0 // the below line is for calculating the last mean vs the now mean. var oldmean = 0 getOption = function () {   } ...

Gekko 比特幣、加密貨幣交易機器人 Trading Bot - 簡易版 RSI 自動判定 [牛 / 熊] 市、短線對沖交易策略

圖片
這是一個基於 MA (移動平均) 線來自動改變 RSI 參數的短線交易策略 ,目的在於配合不同市場情況適合不同的應對,才能把可能收益最大化。由於這是一個自訂策略 (Custom Strategy) 所以必須要建立獨立的 .js 檔。 JS CODE : /*     RSI Bull and Bear     Use different RSI-strategies depending on a longer trend       (CC-BY-SA 4.0) Tommie Hansen     https://creativecommons.org/licenses/by-sa/4.0/ */ var _ = require ('lodash'); var log = require ('../core/log.js'); // Configuration var config = require ('../core/util.js').getConfig(); var async = require ('async'); // Let's create our own method var method = {}; // Prepare everything our method needs method.init = function () {    this.name = 'RSI Bull and Bear';    // Keep state about stuff    this.trend = {        direction: 'none',        duration: 0,        persisted: false,        adviced: false    };    // How many candles do we need as a base before start g...