├── 001单平台均衡策略-研究.md ├── 15MIN-BTCUSDTPERP-BOT.md ├── 1btc起Fmex空头解锁策略后市看空.md ├── 1btc起fmex多头解锁策略后市看多.md ├── 2-Moving-Average-Color-Direction-Detection.md ├── 2014年的简易比特币高频策略机器人.md ├── 3-Supertrend-Add-In-This-Single-Script.md ├── 30行赌徒策略-做空.md ├── 30行赌徒策略.md ├── 3EMA-Boullinger-PIVOT.md ├── 3EMA.md ├── 50行多平台对冲策略教学.md ├── 50行网格策略教学.md ├── 60行三角对冲策略教学.md ├── 72s-Adaptive-Hull-Moving-Average.md ├── ADX-and-DI-for-v4.md ├── AK-MACD-BB-INDICATOR-V-100.md ├── AMACD-All-Moving-Average-Convergence-Divergence.md ├── API-测试新手入门.md ├── ATR-RSI组合策略.md ├── ATR-Smoothed.md ├── Accurate-Swing-Trading-System.md ├── Alert-alertcondition-or-strategy-alerts.md ├── AlphaTrend-Strategy.md ├── AlphaTrend-use-mfi.md ├── AlphaTrend.md ├── Angle-Attack-Follow-Line-Indicator.md ├── Arnaud-Legoux-Moving-Average-Cross-ALMA.md ├── A股港股对冲套利策略.md ├── BB-RSI-ADX-Entry-Points.md ├── BEST-Engulfing-Breakout-Strategy.md ├── BRAHMASTRA.md ├── BSC-Transaction.md ├── BTC-LTC-地址监视-短信通知.md ├── BTC-V反策略.md ├── BTC-bot.md ├── BTCUSDT量化交易执行体.md ├── Backtest-Engine.md ├── Backtesting-Indicator.md ├── Bad-guy-strategy.md ├── Best-TradingView-Strategy.md ├── Big-Snapper-Alerts-R30-Chaiking-Volatility-condition-TP-RSI.md ├── Big-candle分享.md ├── Binance-buy-and-sell-statistics币安买卖统计.md ├── Binance-刷量工资.md ├── Bit-Maker-30-套利-智能学习-USDT-本位-Binance-单平台-Arbitrage-USDT-Standard.md ├── Bit-Maker-现货USDT合约总余额监控.md ├── Bit-Maker-现货USDT等额监控.md ├── BitMEX-简单测试.md ├── BitMEX-高级API功能-V110-期货批量下单编辑订单冰山订单一键撤单定时撤单-Python2-3.md ├── BitMEX-高级API功能-期货批量下单一键撤单-JavaScript.md ├── Bitcoin-Scalper-30MIN.md ├── Bitmex仓位变化推送微信wss协议需要bitmex-api-IDBitmex-position-change-pushwebsocket.md ├── Bitmex获取amount.md ├── Bn-获取精度最小变动单位-稳定交易系统必备.md ├── Bollinger-Awesome-Alert-R1.md ├── Bollinger-Bands-Stochastic-RSI-Extreme.md ├── Bollinger-Bands-Strategy.md ├── Bollinger-RSI-Double-Strategy-v11.md ├── Bollinger-lows.md ├── Brick-count-Renko.md ├── Broken-Fractal-Someones-broken-dream-is-your-profit.md ├── Bullish-Bearish-Engulfing.md ├── Bully-Signals.md ├── Buy-Sell-Strat.md ├── BuySell-Strategy-depends-on-AOStochRSIATR-by-SerdarYILMAZ-SerdarYILMAZ.md ├── BuySell-Strategy-depends-on-AOStochRSIATR-by-SerdarYILMAZ.md ├── BuySell-Strategy-depends-on-AOStochRSIATR.md ├── Bybit-算法接针-VWAP-BTC.md ├── C-API调用例子.md ├── CCI-EMA-with-RSI-Cross-Strategy.md ├── CCI-MTF-ObOs.md ├── CM-MACD-Custom-Indicator-Multiple-Time-Frame-V2.md ├── CM-Sling-Shot-System.md ├── CTA策略之商品期货简易马丁格尔.md ├── CTA策略之钱德动量摆动策略CMO.md ├── Candle-Strength.md ├── Chande-Kroll-Stop.md ├── Chandelier-Exit.md ├── ChatGPT处理交易所上新公告.md ├── CoinPark交易所通用协议-627-1600-更新-关闭了SSL验证.md ├── Combo-2-20-EMA-Bandpass-Filter.md ├── Concept-Dual-SuperTrend.md ├── Consolidation-Zones-Live.md ├── Convert_Record_Cycle.md ├── Crodls-Supertrend.md ├── C期货高频套币策略OKEX-Websocket版.md ├── C版多图表测试.md ├── DMI-测试范例.md ├── Darvas-Box-Buy-Sell.md ├── Delta-RSI-Oscillator-Strategy.md ├── Demark-Reversal-Points-CC.md ├── Demark-Reversal-Points.md ├── Demark-Setup-Indicator.md ├── Demo如何利用策略交互动态调整策略参数.md ├── Demo速度测试-websocket-vs-rest.md ├── Deribit-websocket-范例.md ├── Deribit期权Delta动态对冲策略教学.md ├── Deribit期权测试策略.md ├── Diamond-Trend.md ├── Directional-Movement-Oscillator-DMI.md ├── Donchian-Breakout-no-repaint.md ├── Dual-Thrust-OKCoin-期货.md ├── Dual-Thrust-OKEX-Feature.md ├── Dual-Thrust-OKEX期货-教学.md ├── Dual-Thrust-Trading-Algorithm-ps4.md ├── Dual-Thrust-商品期货.md ├── Dual-Thrust-麦语言版Dual-Thrust-MyLanguage-version.md ├── EHMA-Range-Strategy.md ├── EMA-2155200.md ├── EMA-AROON-ASH.md ├── EMA-Cloud-Intraday-Strategy.md ├── EMA-SCALPEUR-RSi-SHORT.md ├── EMA-TREND-CLOUD.md ├── EMA-bands-leledc-bollinger-bands-trend-catching-strategy.md ├── EMA趋势跟踪当周次周季度.md ├── ESSMA.md ├── ETHUSDTPERP-BOT-30min.md ├── Easy-stock.md ├── Engulfing-Candles.md ├── EtHEriOOOm-30MIN.md ├── Exit-from-specific-entries.md ├── FMEX简单交易挖矿机器人.md ├── FMEX简单排序挖矿机器人.md ├── FMZ实盘机器人自动检测重启程序微信推送.md ├── FMZ扩展API类库.md ├── FMZ教程-JavaScript速成手册.md ├── FMZ教程-Python速成手册.md ├── FTL-Range-Filter-X2-EMA-UO.md ├── FTSMA-Trend-is-your-frend.md ├── Fibonacci-Progression-With-Breaks.md ├── Fibonacci-Timing-Pattern.md ├── Final-Formula-by-TraderShaman.md ├── Flawless-Victory-Strategy.md ├── Follow-Line-Indicator.md ├── Fomo3D-智能合约监控-Fomo3D-Smart-Contract-Monitoring.md ├── Fukuiz-Octa-EMA-Ichimoku.md ├── Fukuiz-Trend.md ├── Gann-High-Low.md ├── Get-cryptocurrency-current-and-max-supply获取币种供应量.md ├── Get-your-trend.md ├── Goblin-Town-60min-可用版.md ├── Gooners-BTC-Weekly-RSI-Hack-Strategy.md ├── Graph-Spread-Cross-BitcoinTrade.md ├── GuoJian_First.md ├── HA-Market-Bias.md ├── HALFTREND-HEMA-SMA-FALSE-SIGNALs-STRATEGY.md ├── HFT高频订单流因子.md ├── HIGH-LOW-SAR.md ├── HODL-LINE.md ├── HUSD-USD稳定币套利.md ├── Hedge_BTC-ETH-Demo.md ├── Heikin-Ashi-Trend.md ├── Highest-high-lowest-low-stop.md ├── Hull-4ema.md ├── Hull-Moving-Average-Swing-Trader.md ├── Hull-Suite-Strategy.md ├── Iceberg-Buy-Order.md ├── Ichimoku-Cloud-Smooth-Oscillator.md ├── Indicator-WaveTrend-Oscillator.md ├── Intraday-BUY-SELL.md ├── Inverted-Hammer-Extended-Options.md ├── JS多图表模板v10_20200429.md ├── JavaScript版K线数据行情收集器.md ├── Johnys-BOT.md ├── KLineChart-演示KLineChart-Demo.md ├── KRT凯尔特纳通道.md ├── Keltner通道突破止损加盈利10即长期持有策略-v23-dev-多周期.md ├── KijunSen-Line-With-Cross.md ├── KingKeltner趋势策略_低频.md ├── Ks-Reversal-Indicator-I.md ├── Larry-Connors-RSI2均值回归策略.md ├── Lbuy_Hsell-低买高卖.md ├── Linear-Regression.md ├── Linear-trend.md ├── Low-Scanner-strategy-crypto.md ├── Low-finder.md ├── M-Language-Turtle-Trading-strategy-implementationsV-10.md ├── MA-Emperor-insiliconot.md ├── MA-HYBRID-BY-RAJ.md ├── MACD-Pine简单策略.md ├── MACD-ReLoaded-STRATEGY.md ├── MACD-SMA-200-Strategy.md ├── MACD-Strategy.md ├── MACD-Willy-Strategy.md ├── MACD低买高卖自动跟单滑动止损.md ├── MACD画图范例.md ├── MACD逃顶策略.md ├── MAGIC-MACD.md ├── MAHL-Band.md ├── ML-Alerts-Template.md ├── MTF-RSI-STOCH-Strategy.md ├── MacD-Custom-Indicator-Multiple-Time-FrameAll-Available-Options.md ├── Matrix-Series.md ├── Ma单均线趋势交易.md ├── Midas-Mk-II-Ultimate-Crypto-Swing.md ├── MilleMachine.md ├── Mobo-Bands.md ├── Momentum-20.md ├── Momentum-based-ZigZag.md ├── Monthly-Returns-in-PineScript-Strategies.md ├── Moon-Launch-Alerts-Template-Indicator.md ├── Moving-Average-Buy-Sell.md ├── Moving-Average-Colored-EMA-SMA.md ├── Moving-Average-Cross-Alert-Multi-Timeframe-MTF.md ├── Moving-Average-Cross.md ├── MultiSymbolCtrlLib.md ├── My-1-价值平均定投策略.md ├── My语言仓位变化推送通知.md ├── NMVOB-S.md ├── Nick-Rypock-Trailing-Reverse-NRTR.md ├── Nik-Stoch.md ├── OBV-MACD-Indicator.md ├── OCC-Strategy-R51.md ├── OKCoin期货条件触发委托带止损.md ├── OKEX-V5-K线数据分页查询例子-Python版.md ├── OKEX-V5-K线数据分页查询例子.md ├── OKEX-V5-WS接口账户持仓推送例子.md ├── OKEX-V5止盈止损接口.md ├── OKEX-V5获取所有未成交订单.md ├── OKEX交易对信息.md ├── OKEX期现对冲.md ├── OKEx跨期对冲策略.md ├── OKXBinance-Websocket高频交易模板-多品种OKEX-Binance-Websocket-High-Frequency-Multi-Symbols-Trading-Template.md ├── OKex期货测试for新手.md ├── OK确认无法提币交易对.md ├── OkEX-Websocket-Realtime-v3.md ├── OkEX-高级API功能-V110-期货批量下单现货TBD-Python2-3.md ├── OkEX合约-仓位管理系统.md ├── Okex交易所获取指定币种持仓返回发明者Position结构数组.md ├── Okex张币转换欧意张换算为币数或者币数换算为张.md ├── Optimized-Trend-Tracker.md ├── Order-Block-Finder.md ├── Parabolic-SAR-Buy-And-Sell.md ├── Parabolic-SAR.md ├── Paul-The-Gambler-Lévy-Gold-Edition.md ├── Paul-The-Gambler-Lévy.md ├── Peak-detector.md ├── Pivot-Based-Trailing-Maxima-Minima.md ├── Pivot-Order-Blocks.md ├── Pivot-Point-Supertrend.md ├── Pivot-Points-High-Low-Multi-Time-Frame.md ├── Pivot-Trend.md ├── PlanB-Quant-Investing-101-v2.md ├── Playing-the-cross.md ├── Price-Divergence-Strategy-v10.md ├── Profit-Maximizer-PMax.md ├── Push-Binance-deal-order-to-WeChat实时推送币安成交到微信wss协议练习.md ├── Python-API-测试.md ├── Python-KLineChart.md ├── Python-机器学习之-SVM-预测买卖.md ├── Python-精简多品种-MACD-趋势策略.md ├── Python版-TableTemplet-测试版Python-Version-TableTemplet-Beta-Version.md ├── Python版MACD指标画图范例.md ├── Python版冰山委托-买入.md ├── Python版冰山委托-卖出.md ├── Python版单平台均衡策略教学.md ├── Python版商品期货跨期对冲策略-教学.md ├── Python版多品种追涨杀跌策略教学.md ├── Python版多图表范例.md ├── Python版简单网格策略教学.md ├── Python版追涨杀跌策略教学.md ├── Python版追涨杀跌策略教学币安USDT永续合约.md ├── Python简单测试策略.md ├── QQE-MOD-SSL-Hybrid-Waddah-Attar-Explosion.md ├── QQE-signals.md ├── Quantitative-Qualitative-Estimation.md ├── R-Breaker-交易策略.md ├── R-Breaker11-交易策略.md ├── RAVI-FX-Fisher.md ├── README.md ├── RISOTTO.md ├── RSI-Buy-Sell-Signals.md ├── RSI-Divergence-Indicator.md ├── RSI-Divergence-with-Pivot-BB-SMA-EMA-SMMA-WMA-VWMA.md ├── RSI-MTF-ObOs.md ├── RSI-Trend.md ├── RSI-ZIGZAG22.md ├── RSI-and-BBand-simultaneously-OverSold.md ├── RSI-by-zdmre.md ├── RSI_now_sb_ok.md ├── RSI统计套利策略.md ├── Rainbow-Oscillator.md ├── Range-Filter-Buy-and-Sell-5min-Strategy.md ├── Range-Filter-Buy-and-Sell.md ├── RecordsCollecter-升级提供自定义数据源功能.md ├── RecordsCollecter-升级提供自定义数据源功能支持CSV数据文件提供数据源.md ├── RecordsCollecter-教学.md ├── RedK-Dual-VADER-with-Energy-Bars.md ├── RedK-Momentum-Bars.md ├── RedK-Volume-Accelerated-Directional-Energy-Ratio.md ├── Relative-Strength-Index-Divergences-Libertus.md ├── Renko-Reversal-Alert.md ├── Rolling-Heikin-Ashi-Candles.md ├── SAR-3SMMA-with-SL-TP.md ├── SAR-high-and-low.md ├── SAR抛物线转向指标.md ├── SMA-Trend.md ├── SMA-pine语言教学策略脚本.md ├── SSL-CHANNEL-STOCH-RSI.md ├── SSL-Channel.md ├── SSL-Hybrid-STOCH-RSI.md ├── SSL-Hybrid.md ├── SSS.md ├── SUPERTREND-ATR-WITH-TRAILING-STOP-LOSS.md ├── SWING-TRADE-SIGNALS.md ├── Scalping-EMA-ADX-RSI-with-Buy-Sell.md ├── Scalping-PullBack-Tool-R1.md ├── Scalping-Swing-Trading-Tool-R1-4.md ├── Schaff-Trend-Cycle.md ├── SeamlessConnWS.md ├── Sentiment-Oscillator.md ├── Shannon-Entropy-V2.md ├── Shannons-Demon.md ├── Sidboss.md ├── Simple-1m-Scalper-by-thimblemunch.md ├── Simple-Buy-Sell-Signals.md ├── Slope-Adaptive-Moving-Average.md ├── Sma-BTC-killer.md ├── Smaller-Fractals-Transparency.md ├── Smarter-MACD.md ├── Smooth-HA-Candles-MTF-v1.md ├── SpotGridStra.md ├── Squeeze-Momentum-Indicator.md ├── StochRSI和okcoin一致.md ├── Stochastic-RSI-Double-Strategy.md ├── Super-Scalper-5-Min-15-Min.md ├── Super-Scalper.md ├── Super-Trend-Daily-20-BF.md ├── Super-trend-B.md ├── SuperB.md ├── SuperHunter-智能学习-多账户合并展示版.md ├── SuperJump-Turn-Back-Bollinger-Band.md ├── SuperTREX.md ├── SuperTrend-V1.md ├── SuperTrend.md ├── SuperTrended-Moving-Averages.md ├── SuperTrend策略教学.md ├── Supertrend4moving.md ├── Support-Resistance-breakout.md ├── Swing-High-Low-Indicator-w-MACD-and-EMA-Confirmations.md ├── Swing-Highs-Lows-Candle-Patterns.md ├── Swing-Hull-rsi-EMA-Strategy.md ├── T-Step-LSMA.md ├── TD狄马克序列.md ├── TMA-Legacy.md ├── TMA-Overlay.md ├── TUE-ADX-MACD-Confluence-Strategy.md ├── TUE-ADX-MACD-Confluence-V10.md ├── TableTemplet.md ├── Telegram-发信接口-V200-Python.md ├── Tom-DeMark-Sequential-Heat-Map.md ├── Trade-Hour-V3.md ├── Trading-ABC.md ├── Trading-the-Equity-Curve-Position-Sizing-Example.md ├── TradingView-Alerts-to-MT4-MT5-dynamic-variables-NON-REPAINTING.md ├── TradingViewWebHook信号执行策略教学.md ├── TradingViewWebHook直连策略.md ├── TradingView下单机器人11.md ├── TradingView信号-带止盈.md ├── TradingView信号执行策略2教学.md ├── TrendScalp-FractalBox-3EMA.md ├── Trendelicious.md ├── Triple-EMA-MACD.md ├── Triple-Supertrend-with-EMA-and-ADX.md ├── Twin-Range-Filter.md ├── TypeScript-演示.md ├── Uniswap-V3-交易类库Uniswap-V3-Trade-Template.md ├── Utility-Logger.md ├── Utility-Ticker.md ├── U本位网格振幅筛选.md ├── VNC-SVM-Test.md ├── Villa-Dinamic-Pivot-Supertrend-Strategy.md ├── Vitalik-Scalpe.md ├── Volume-Divergence.md ├── Volume-Flow-v3.md ├── VuManChu-Cipher-B-Divergences-Strategy.md ├── WR-突破马丁.md ├── Welcome-to-the-BEARMARKET-30MIN.md ├── Williams-R-Smoothed.md ├── Z-Score-with-Signals.md ├── ZT-交易所接口可用于对接平台暂不支持的冷门交易所-ZT.md ├── ZigZag-PA-Strategy-V41.md ├── ahr999定投策略.md ├── baguette-by-multigrain.md ├── binance_util.md ├── bitfinex保证金交易.md ├── blackcat-L2-Reversal-Labels-Strategy.md ├── bollmaboll.md ├── boll傻瓜版.md ├── buy-hold-买入持有.md ├── bybit-swap永续加仓策略.md ├── bybit反向合约动态网格特异网格.md ├── coingecko_crawler.md ├── common.md ├── crypto-futures-hourly-scalping-with-ma-rsi-ogcheckers.md ├── derbit-期权回测测试.md ├── footprint-chart.md ├── grid.md ├── jma-dwma-by-multigrain.md ├── js-R-Breaker.md ├── okex-BTC合约账户公开.md ├── okex币币最小交易量.md ├── okex订单薄校验checksum算法函数.md ├── pine语言学习脚本.md ├── python-状态栏表格-显示按钮范例.md ├── python.md ├── python利用asyncio-http获取行情数据示范.md ├── python版-Dual-Thrust-OKCoin-期货.md ├── python版-画线类库-兼容2-3-Python-Version-Drawing-Class-Library-Compatible-2-3.md ├── python版现货数字货币交易类库Python-Version-Spot-Cryptocurrency-Trading-Class-Library.md ├── rest-版OKEX跨期对冲策略教学.md ├── robotCtrl教学策略.md ├── stoch-supertrd-atr-200ma.md ├── stochRSI策略-指标框架.md ├── talib简单应用之查找三只乌鸦.md ├── thena-swap交易类库.md ├── tv高低点策略.md ├── websocket-版OKEX跨期对冲策略教学.md ├── 一根均线-趋势-Demo.md ├── 一目均衡.md ├── 三均线系统Exodus.md ├── 三大交易所止盈止损集成类库.md ├── 三行代码实现阿尔戈斯机器学习快速解读行业新闻的反指策略.md ├── 三角套利-基础版.md ├── 三角套利策略体验版.md ├── 三角套利赚取小币种盘口价差.md ├── 不同计价币的现货对冲策略-Ver11.md ├── 不同计价币的现货对冲策略教学.md ├── 交互模板.md ├── 交易对精度标定.md ├── 交易所上新币第一时间挂单机器人.md ├── 交易所对倒刷量对敲互刷.md ├── 交易所最小数量和精度.md ├── 交易终端插件范例.md ├── 从第三方网站获取K线-0804更新.md ├── 仓位均衡策略.md ├── 仓位管理配置思路.md ├── 代替废弃的GetMinStock函数.md ├── 价值0418.md ├── 价格波动报警.md ├── 仿Promise异步模板.md ├── 传统均线指标与KD指标的交易策略Trading-Strategy-of-Traditional-MA-Index-and-KD-Index.md ├── 你不知道的MACDMA指标组合策略MACDMA-Indicator-Combination-Strategy.md ├── 使用-BotVS-构建一个机械化策略.md ├── 使用画线类库画K线以及均线图表范例.md ├── 入门模板之各个平台余额.md ├── 典型价格百分比通道-凯尔特纳与百分比通道变形.md ├── 内外盘期货品种实时差价图.md ├── 冰山委托-买入-Copy.md ├── 冰山委托-买入.md ├── 冰山委托-卖出.md ├── 冰山委托买入-Jason.md ├── 冰山委托买入简单版Simple-Iceberg-order-to-buy.md ├── 冰山委托卖出简单版Simple-Iceberg-order-to-sell.md ├── 冲币安新上币开盘.md ├── 函数自动容错模板.md ├── 分享-ADX值达到条件进行通知.md ├── 分享-ATR为例均值计算中容错教程.md ├── 分享-赌徒策略-马丁策略.md ├── 分享-逐棒分析多空强弱指示器.md ├── 分享RSI超买超卖策略.md ├── 分享抢新现货策略.md ├── 分享模板引用错误追踪.md ├── 切换OKEX_V5模拟盘交易终端插件.md ├── 利用平均趋向指数辅助MACD策略.md ├── 割庄神器.md ├── 动向指数DMI与高低点策略DMI-and-High-Low-Strategy.md ├── 动态平衡-做市策略-小高.md ├── 动态平衡-做市策略.md ├── 动态平衡alpha.md ├── 动态平衡策略-python-版.md ├── 单商品小卖部策略V20_年化130.md ├── 单平台均衡策略.md ├── 单点狙击高频加仓自动反手解套算法-V12.md ├── 单独计算收益代码来自zero.md ├── 单货币动态均衡V10_区班主.md ├── 单边网格.md ├── 原生多线程JavaScript与WASM性能比较.md ├── 双向合约网格交易v102.md ├── 双均线策略与相对强弱RSI指标组合Combination-of-Double-MA-and-RSI.md ├── 双平台对冲-练习用-求交流求指点.md ├── 双平台对冲js版本two-platforms-hedging-JS.md ├── 发明者APP图表测试策略.md ├── 发明者量化数据库实战.md ├── 取消所有订单.md ├── 可变图表示例.md ├── 各大交易所资金费率汇总.md ├── 各大平台API可用率统计.md ├── 各平台策略代写区块链5年专业经验低价高质量-薇芯bov1107.md ├── 各平台策略代写区块链5年专业经验低价高质量薇芯bov1107.md ├── 合成任意周期K线-使用请看源码最下面.md ├── 合约下单.md ├── 合约对冲_下单多线程版本.md ├── 吕神-简易波动率策略.md ├── 吕神简易波动率策略Pine语言版本.md ├── 商品期货交易类库增加下限价单功能.md ├── 商品期货多品种R-Breaker策略.md ├── 商品期货多品种主力自动移仓海龟交易策略.md ├── 商品期货查看账户详细信息.md ├── 商品期货结算单平仓盈亏历史查询.md ├── 商品期货跨期对冲-单品种套利合约.md ├── 商品期货跨期对冲-百行代码实现.md ├── 回测保存K线到本地CSV.md ├── 固定间距批量挂单插件.md ├── 图表模板增加状态栏表格.md ├── 图表界面信息展示实例1.md ├── 均仓策略.md ├── 均线-趋势_数字货币策略V02.md ├── 均线傻瓜版.md ├── 均线和高低点相对强弱策略Relative-Strength-Strategy-Based-on-Price.md ├── 均线策略python版.md ├── 均线策略范例02.md ├── 基于ATR波动率指标构建的通道策略Channel-strategy-based-on-ATR-volatility-indicator.md ├── 基于ATR波动率指标构建的通道策略Channel-strategy-based-on-ATR.md ├── 基于CCI周期性区间交易策略.md ├── 基于发明者量化基本面数据的商品期现套利图表.md ├── 基于期货基本面分析的交易策略.md ├── 基于随机森林的趋势策略.md ├── 基础网格交易策略.md ├── 复杂看盘图表测试版.md ├── 多交易所并发插件.md ├── 多交易所集合行情-下单-策略-范例.md ├── 多品种期现对冲-手动版.md ├── 多品种期货跨期对冲策略.md ├── 多图表例子数据可下载为csv等表格Multiple-charts-example.md ├── 多图表画线类库.md ├── 多均线策略.md ├── 多平台对冲稳定套利.md ├── 多平台强制滑动平仓买一价.md ├── 多平台账户统计.md ├── 多线程批量任务.md ├── 多线程获取多个交易的深度信息.md ├── 多线程获取多个交易的账户信息.md ├── 大中小三周期跃迁策略V20_现货.md ├── 大道至简系列1-30行代码实现马丁带止损策略ETH回测年化65功能齐全.md ├── 大道至简系列2-40行代码实现简单永续网格策略ETH回测30天收益1188.md ├── 奥克量化-JS对接FMZ扩展API-Demo.md ├── 奥克量化-使用扩展API获取机器人的信息并展示.md ├── 如何找出一定Bar数量的-K线前期高点低点-及-Demo-程序.md ├── 学习API与教程内代码学习文件.md ├── 定投新手入门每周100USDT-定期定额-100USDT-Invested-Every-Week-Regular-Fixed-Investment.md ├── 定投新手入门每周100USDT左右-定期不定额-100USDT-Invested-Every-Week-Regular-Variable-Investment.md ├── 定投止盈脚本.md ├── 定投策略.md ├── 定时撤单.md ├── 定期定额投资BTC盈利验证.md ├── 定点进场下单定点离场卖单.md ├── 定量分型速率交易策略-by泊宇量化.md ├── 对冲27收益率统计系统-支持多组账号统计.md ├── 封装Bithumb的ordersDetail接口.md ├── 山寨币指数20180222基点1000.md ├── 差价监控.md ├── 币安-提币范例代码.md ├── 币安websocket订阅永续合约行情信息.md ├── 币安一次性获取所有合约持仓列表并格式化为发明者Position结构数组.md ├── 币安一次性获取所有挂单列表U本位合约.md ├── 币安交易终端资金划转小工具.md ├── 币安出售所有山寨币.md ├── 币安取消所有交易对未完成订单IO扩展示范Cancel-ALL-Binance-Orders.md ├── 币安合约BNB手续费抵扣-自动购买自动划转.md ├── 币安合约websocket接口查询持仓账户范例.md ├── 币安合约网格-002v.md ├── 币安合约网格-基础版本-001.md ├── 币安合约蝶式套利千团大战策略3.md ├── 币安多交易对-现货-用来市价清仓用的.md ├── 币安多交易对价格区间提醒.md ├── 币安多产品趋势马丁与逆势马丁策略分享.md ├── 币安小额资产转换.md ├── 币安手动开平仓工具.md ├── 币安止盈止损和仓位止盈止损接口U本位合约.md ├── 币安永续双账户单币种对冲YNRUN.md ├── 币安永续多币种对冲策略做多超跌做空超涨-张总python版.md ├── 币安永续多币种对冲策略做空或做多山寨币指数4月10日改进Bug需要更新.md ├── 币安永续多币种对冲策略原版做多超跌做空超涨4月13日最新止损模块.md ├── 币安策略二去掉高低分.md ├── 布林均线突破_vnpy_botvs实现版.md ├── 布林马丁测试版V14.md ├── 常用函数扩展增强类库-Ver-003.md ├── 干货-下单量精度和价格精度-适用各个交易所.md ├── 干货-选币系统-选币因子.md ├── 平台价格指标监控11.md ├── 平台价格比较10.md ├── 平衡挂单策略教学.md ├── 幽灵趋势跟踪策略.md ├── 幽灵趋势跟踪策略业务库.md ├── 幽灵趋势跟踪策略数据库.md ├── 当周季度差价画图插件.md ├── 恒温器-震荡修正为-最高价-最低价-添加增减仓选项-添加额外张数功能-修正cmi数据刷新日期问一天一次变为1小时一次-ok-准备修正一些功能.md ├── 把USDT从合约账户划转到现货-资金账户OKEX币安同时支持.md ├── 抛硬币策略.md ├── 抢盘口做市策略-对敲.md ├── 抢盘口做市策略-高频逼近型.md ├── 指数均衡策略-教学.md ├── 指数对冲修罗场-001.md ├── 指数平衡策略Index-Balance-Bot.md ├── 指数量化.md ├── 指标库python版.md ├── 提币模板.md ├── 收益率统计.md ├── 教学策略TCI策略麦语言移植.md ├── 数字货币合约简易跟单机器人.md ├── 数字货币定投.md ├── 数字货币期货交易类库测试版.md ├── 数字货币期货切换全仓逐仓插件.md ├── 数字货币期货双均线拐点策略教学.md ├── 数字货币期货多品种ATR策略教学.md ├── 数字货币期货现货差价监控.md ├── 数字货币期货类马丁策略.md ├── 数字货币现货多品种双均线策略教学.md ├── 数字货币现货打新抢币策略教学.md ├── 斐波那契数列策略.md ├── 新手上路CoinEx交易-LTC_USDT.md ├── 日志Logger.md ├── 时间格式工具.md ├── 暴力马丁适合eth和btc-Copy.md ├── 暴雪网格-724小时交易机器人每日更新实盘效果.md ├── 有人爆仓时开反向单.md ├── 期现成对下单_Public.md ├── 期货一键对冲插件Hedge-on-two-contracts.md ├── 期货一键平仓插件Cover-all-contracts.md ├── 期货做市高频交易策略.md ├── 期货反手加倍算法.md ├── 期货基础策略.md ├── 本地存储.md ├── 条件开仓马丁.md ├── 来自油管大神的双EMA均线策略.md ├── 查询结算单.md ├── 标准上涨五浪下跌五浪策略.md ├── 标定值或均线交叉策略.md ├── 检查https-quantla-Argus-是否正常.md ├── 模板库使用例子.md ├── 每1分钟统计各个平台间的差价by-JackConan.md ├── 每日市价定投.md ├── 比特币现货阶梯差价对冲.md ├── 永续合约一键市价平仓.md ├── 测试-关于使用kdj与vol量筛选可能会涨的币种.md ├── 测试-关于马丁长期效果.md ├── 测试-布林带策略基于策略框架.md ├── 测试1111.md ├── 测试多图表展示.md ├── 测试多图表展示Python版.md ├── 测试托管者与交易所服务器的真实网络延迟-支持同时测试多个交易所.md ├── 测试插件.md ├── 测试现货买卖操作分限价市价两种情况.md ├── 测试默认参数组功能.md ├── 海龟.md ├── 海龟交易法Turtles-strategy.md ├── 海龟汤策略反趋势交易策略.md ├── 海龟策略btc现货版.md ├── 海龟量化工具-海龟原版E-比率计算.md ├── 深度做市-盘口控制-操盘机器人-做市工具.md ├── 深度快照.md ├── 混合图表的一个复杂例子.md ├── 火币U合约资金划转插件.md ├── 火币期货币币账户间资金划转范例.md ├── 火币点卡.md ├── 火币精度.md ├── 熊赚币牛赚U之平衡策略.md ├── 爬取币安公告永续新上币和下架币.md ├── 爬取币安公告自动出售将要下架币crawl-Binance-announcements-and-sell-Delist-coin.md ├── 牛熊小卖部策略V10_OKex合约.md ├── 牛熊猴市判断V10_区班主.md ├── 现货买入一直占据买一插件.md ├── 现货冰山委托买入插件Simple-Iceberg-order-to-buy-Copy.md ├── 现货冰山委托卖出插件Simple-Iceberg-order-to-sell-Copy.md ├── 现货单币种平衡策略.md ├── 现货卖出一直占据卖一插件.md ├── 现货平衡策略-001v.md ├── 现货指数平衡策略-v11曾实盘跑过一段时间现在疑似有bug因为不用了懒得改.md ├── 现货移动止盈策略.md ├── 现货预定价格循环买卖.md ├── 画线机器人一年翻倍回撤1完美曲线.md ├── 画线类库Plot-library.md ├── 监视并显示多个平台的全部资产总和的变化.md ├── 短信通知接口测试.md ├── 短信通知类库.md ├── 破冰者.md ├── 移植-OKCoin-韭菜收割机-多品种版-注释python版.md ├── 移植-OKCoin-韭菜收割机-注释.md ├── 移植-OKCoin-韭菜收割机-注释python版.md ├── 移植-OKCoin-韭菜收割机.md ├── 窜天猴-多空较量-爆破版.md ├── 窜天猴-移动止损版.md ├── 策略框架.md ├── 策略框架模板.md ├── 简单固定价格止损机器人Stop-Loss-Below-Fixed-Price.md ├── 简单均线策略Moving-Average-Bot-30-lines.md ├── 简单多品种商品期货均线策略.md ├── 简单的做市对冲功能.md ├── 简单网格测试.md ├── 简单预定买入后卖出插件Buy-then-Sell-ping-pong-strategy.md ├── 简单马丁格尔btc合约修改加仓倍率.md ├── 简单马丁格尔合约倍率加强版.md ├── 简单马丁格尔多空交易策略.md ├── 简单马丁格尔多空加仓倍率修改.md ├── 简易数字货币现货跟单机器人策略.md ├── 简易等差合约网格.md ├── 练习01RSI.md ├── 经典MACD交易策略.md ├── 经典均线策略.md ├── 经典均线策略V10_区班主注释简化.md ├── 统计K线回测是否存在趋势.md ├── 统计各个平台间的最大差价by-JackConan.md ├── 统计收益-复制.md ├── 网格变形策略之单边网格-OK期货.md ├── 网格变形策略之单边网格-注释.md ├── 网格变形策略之单边网格.md ├── 网格合约.md ├── 网格挂单加马丁倍数递增.md ├── 股票DualThrust策略.md ├── 股票均线策略.md ├── 自动获取币安永续合约交易精度最小开仓u已弃坑.md ├── 自适应动态双均线策略.md ├── 范例-定时测试微信消息推送.md ├── 获取OK期货实时限价.md ├── 获取周K线.md ├── 获取和讯期货数据Python版本.md ├── 获取币安usdt合约全币种名称.md ├── 获取持仓均价你用对了吗.md ├── 融资融币统计.md ├── 行情中心客户端market-center-client.md ├── 行情中心延时.md ├── 要饭机器人30.md ├── 计划委托买入.md ├── 计划委托卖出.md ├── 订单同步管理系统Synchronous-Server.md ├── 订单同步管理系统类库Single-Server.md ├── 记录净资产变动情况20.md ├── 设定比特币价格并微信推送-100取整突破推送.md ├── 设定比特币价格并微信推送教学-Push-the-price-information-to-telegram.md ├── 调用钉钉接口实现机器人推送消息.md ├── 账号内所有订单显示U本位.md ├── 账户余额变动邮箱提醒-支持添加多个交易所.md ├── 费率汇总.md ├── 超级趋势策略SuperTrend.md ├── 超跌超涨超牛版.md ├── 趋势策略V10-公开.md ├── 趋势跟踪震荡策略.md ├── 趋势马丁网格ver100策略仅供学习参考.md ├── 跨周期均线交易multiple-timeframe-trading.md ├── 跨平台套利新手测试.md ├── 跨时间周期策略.md ├── 转换任意K线周期.md ├── 转换任意K线周期管理模板最近更新20180627.md ├── 轮询价格买入卖出.md ├── 追涨杀跌.md ├── 通过HttpQuery直接获取币安K线数据.md ├── 钉钉推送.md ├── 钉钉群机器人推送超长信息必备.md ├── 闪崩机器人-教学.md ├── 阶梯下单-可设置触发价格.md ├── 随机数猜大猜小.md ├── 震荡突破策略.md ├── 韭菜保护程序唐安奇通道均仓策略.md ├── 顶-底背离指标观察系统-with-止盈止损.md ├── 顺大势逆小势策略之代码实现及可行性分析.md ├── 饥饿者.md ├── 马丁变种原始版.md ├── 马丁格尔打印收益图表.md ├── 马丁策略-V001.md ├── 高低点突破成交量指数加权策略Break-High-and-Low-Volume-Index-Weighting-Strategy.md ├── 高频交易策略之-Penny-Jump.md ├── 高频收割机一号.md ├── 高频跨期套利策略.md ├── 魔改韭菜收割机.md ├── 魔改马丁双向持仓.md ├── 麦语言海龟策略体验.md └── 麦语言网格策略.md /30行赌徒策略-做空.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 30行赌徒策略-做空 5 | 6 | > 策略作者 7 | 8 | 小小梦 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |_StopWin|500|止盈| 19 | |_StopLoss|500|止损| 20 | |_FirstAmount|0.01|单次下单量| 21 | |_MaxGear|8|加倍赌的次数| 22 | 23 | 24 | > 源码 (javascript) 25 | 26 | ``` javascript 27 | var hold = {price : 0, amount : 0} 28 | var _Gear = 0 29 | function main(){ 30 | var initAccount = _C(exchange.GetAccount) 31 | Log(initAccount, "#FF0000") 32 | while(1){ 33 | var ticker = _C(exchange.GetTicker) 34 | if(hold.amount == 0){ 35 | var firstInfo = $.Sell(_FirstAmount) 36 | hold.amount = firstInfo.amount 37 | hold.price = firstInfo.price 38 | } else { 39 | if(ticker.Buy < hold.price - _StopWin){ 40 | var coverStopWinInfo = $.Buy(hold.amount) 41 | hold.price = 0 42 | hold.amount = 0 43 | _Gear = 0 44 | } else if(ticker.Buy > hold.price + _StopLoss && _Gear < _MaxGear){ 45 | $.Buy(hold.amount) 46 | var amount = hold.amount * 2 47 | var addInfo = $.Sell(amount) 48 | hold.price = addInfo.price 49 | hold.amount = addInfo.amount 50 | _Gear++ 51 | } 52 | } 53 | LogStatus(_D(), "加倍下注次数:", _Gear, "\n", "当前持仓:", hold) 54 | Sleep(500) 55 | } 56 | } 57 | ``` 58 | 59 | > 策略出处 60 | 61 | https://www.fmz.com/strategy/113986 62 | 63 | > 更新时间 64 | 65 | 2018-08-29 14:16:21 66 | -------------------------------------------------------------------------------- /30行赌徒策略.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 30行赌徒策略 5 | 6 | > 策略作者 7 | 8 | 小小梦 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |_StopWin|500|止盈| 19 | |_StopLoss|500|止损| 20 | |_FirstAmount|0.01|单次下单量| 21 | |_MaxGear|8|加倍赌的次数| 22 | 23 | 24 | > 源码 (javascript) 25 | 26 | ``` javascript 27 | var hold = {price : 0, amount : 0} 28 | var _Gear = 0 29 | function main(){ 30 | var initAccount = _C(exchange.GetAccount) 31 | Log(initAccount, "#FF0000") 32 | while(1){ 33 | var ticker = _C(exchange.GetTicker) 34 | if(hold.amount == 0){ 35 | var firstInfo = $.Buy(_FirstAmount) 36 | hold.amount = firstInfo.amount 37 | hold.price = firstInfo.price 38 | } else { 39 | if(ticker.Sell > hold.price + _StopWin){ 40 | var coverStopWinInfo = $.Sell(hold.amount) 41 | hold.price = 0 42 | hold.amount = 0 43 | _Gear = 0 44 | } else if(ticker.Sell < hold.price - _StopLoss && _Gear < _MaxGear){ 45 | $.Sell(hold.amount) 46 | var amount = hold.amount * 2 47 | var addInfo = $.Buy(amount) 48 | hold.price = addInfo.price 49 | hold.amount = addInfo.amount 50 | _Gear++ 51 | } 52 | } 53 | LogStatus(_D(), "加倍下注次数:", _Gear, "\n", "当前持仓:", hold) 54 | Sleep(500) 55 | } 56 | } 57 | ``` 58 | 59 | > 策略出处 60 | 61 | https://www.fmz.com/strategy/113796 62 | 63 | > 更新时间 64 | 65 | 2018-08-31 10:43:45 66 | -------------------------------------------------------------------------------- /API-测试新手入门.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | API-测试新手入门 5 | 6 | > 策略作者 7 | 8 | Zero 9 | 10 | > 策略描述 11 | 12 | 新手入门学习模板 13 | 14 | > 策略参数 15 | 16 | 17 | 18 | |参数|默认值|描述| 19 | |----|----|----| 20 | |message|Hello|回显的信息| 21 | |running|true|布尔值| 22 | |maxNumber|111|回显数字| 23 | |ListIdx|0|下拉框: 第一|第二|第三| 24 | |cond|123|条件显示1| 25 | 26 | 27 | > 源码 (javascript) 28 | 29 | ``` javascript 30 | function main() { 31 | Log(exchange.GetAccount()); 32 | Log(message, running, maxNumber); 33 | Log('ListIdx :', ListIdx); 34 | LogProfit(100.3); 35 | Log("这是红色字体颜色", "#ff0000"); 36 | Log("我是带背景色的", "#ffffff223344"); 37 | LogProfit(90, "我也带背景色", "#ffffff0000ff"); 38 | } 39 | ``` 40 | 41 | > 策略出处 42 | 43 | https://www.fmz.com/strategy/4 44 | 45 | > 更新时间 46 | 47 | 2019-03-19 21:09:24 48 | -------------------------------------------------------------------------------- /Accurate-Swing-Trading-System.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Accurate-Swing-Trading-System 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |v_input_1|3|Swing| 19 | |v_input_2|true|Barcolor| 20 | |v_input_3|false|Bgcolor| 21 | 22 | 23 | > 源码 (PineScript) 24 | 25 | ``` javascript 26 | /*backtest 27 | start: 2021-05-08 00:00:00 28 | end: 2022-05-07 23:59:00 29 | period: 4h 30 | basePeriod: 15m 31 | exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] 32 | */ 33 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 34 | // © ceyhun 35 | 36 | //@version=4 37 | study("Accurate Swing Trading System",overlay=true) 38 | 39 | no=input(3,title="Swing") 40 | Barcolor=input(true,title="Barcolor") 41 | Bgcolor=input(false,title="Bgcolor") 42 | 43 | res=highest(high,no) 44 | sup=lowest(low,no) 45 | avd=iff(close>res[1],1,iff(close=tsl ? color.green : close<=tsl ? color.red : na 56 | plot(tsl, color=colr, linewidth=3, title="TSL") 57 | barcolor(Barcolor ? colr : na) 58 | bgcolor(Bgcolor ? colr :na) 59 | 60 | alertcondition(Buy, title="Buy Signal", message="Buy") 61 | alertcondition(Sell, title="Sell Signal", message="Sell") 62 | if Buy 63 | strategy.entry("long", strategy.long) 64 | else if Sell 65 | strategy.entry("short", strategy.short) 66 | ``` 67 | 68 | > 策略出处 69 | 70 | https://www.fmz.com/strategy/367565 71 | 72 | > 更新时间 73 | 74 | 2022-06-04 07:05:48 75 | -------------------------------------------------------------------------------- /AlphaTrend-use-mfi.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | AlphaTrend-use-mfi 5 | 6 | > 策略作者 7 | 8 | 发明者量化 9 | 10 | > 策略描述 11 | 12 | ![IMG](https://www.fmz.com/upload/asset/fac92b30d9603ace21.png) 13 | 14 | > 策略参数 15 | 16 | 17 | 18 | |参数|默认值|描述| 19 | |----|----|----| 20 | |v_input_float_1|5|Multiplier| 21 | |v_input_1|14|Common Period| 22 | |v_input_source_1|0|source: close|high|low|open|hl2|hlc3|hlcc4|ohlc4| 23 | 24 | 25 | > 源码 (PineScript) 26 | 27 | ``` javascript 28 | /*backtest 29 | start: 2021-05-05 00:00:00 30 | end: 2022-05-04 23:59:00 31 | period: 1d 32 | basePeriod: 1h 33 | exchanges: [{"eid":"Bitfinex","currency":"BTC_USD"}] 34 | */ 35 | 36 | 37 | indicator('AlphaTrend', shorttitle='AT', overlay=true) 38 | 39 | coeff = input.float(5, 'Multiplier') 40 | AP = input(14, 'Common Period') 41 | ATR = ta.sma(ta.tr, AP) 42 | src = input.source(close, "source") 43 | upT = low - ATR * coeff 44 | downT = high + ATR * coeff 45 | AlphaTrend = 0.0 46 | AlphaTrend := ta.mfi(hlc3, 14) >= 50 ? upT < nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : upT : downT > nz(AlphaTrend[1]) ? nz(AlphaTrend[1]) : downT 47 | 48 | plot(AlphaTrend) 49 | 50 | if ta.crossover(low, AlphaTrend) 51 | strategy.entry("BUY", strategy.long) 52 | else if ta.crossunder(high, AlphaTrend) 53 | strategy.entry("SELL", strategy.short, when=ta.crossunder(high, AlphaTrend)) 54 | 55 | 56 | ``` 57 | 58 | > 策略出处 59 | 60 | https://www.fmz.com/strategy/360014 61 | 62 | > 更新时间 63 | 64 | 2022-05-06 15:38:52 65 | -------------------------------------------------------------------------------- /BitMEX-简单测试.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | BitMEX-简单测试 5 | 6 | > 策略作者 7 | 8 | 发明者量化 9 | 10 | > 策略描述 11 | 12 | 现已接入BitMEX, 支持全平台API, 支持IO扩展. 13 | 14 | 15 | 16 | > 源码 (javascript) 17 | 18 | ``` javascript 19 | // 只支持实盘 20 | function main() { 21 | exchange.SetContractType("XBTUSD") 22 | Log(_C(exchange.GetAccount)) 23 | Log(_C(exchange.GetTicker)) 24 | Log(_C(exchange.GetDepth)) 25 | Log(_C(exchange.GetRecords)) 26 | Log(_C(exchange.GetTrades)) 27 | // IO Test 28 | Log(_C(exchange.IO, "api", "GET", "user/affiliateStatus")) 29 | 30 | Log(_C(exchange.SetMarginLevel, 10)) 31 | exchange.SetDirection("buy") 32 | var orderId = exchange.Buy(-1, 3) 33 | if (orderId) { 34 | Log(_C(exchange.GetOrder, orderId)) 35 | } 36 | Log(_C(exchange.GetPosition)) 37 | } 38 | ``` 39 | 40 | > 策略出处 41 | 42 | https://www.fmz.com/strategy/40289 43 | 44 | > 更新时间 45 | 46 | 2017-05-08 17:20:34 47 | -------------------------------------------------------------------------------- /BitMEX-高级API功能-期货批量下单一键撤单-JavaScript.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | BitMEX-高级API功能-期货批量下单一键撤单-JavaScript 5 | 6 | > 策略作者 7 | 8 | FawkesPan 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (javascript) 15 | 16 | ``` javascript 17 | /* 18 | 19 | BitMEX Advanced API Interface for FMZ.com. 20 | 21 | Copyright 2018 FawkesPan 22 | Contact : i@fawkex.me / Telegram@FawkesPan 23 | 24 | GNU General Public License v3.0 25 | 26 | */ 27 | 28 | function main() { 29 | Log(exchange.GetAccount()); 30 | } 31 | var bulk = [] 32 | // 添加批量买单 33 | function BulkBuy(symbol,qty,price,type,exec) { 34 | Log("新的Bulk订单 开多 "+ symbol + " " + price + " " + qty) 35 | var order = {}; 36 | order.symbol = symbol; 37 | order.side = "Buy"; 38 | order.orderQty = qty; 39 | order.price = price; 40 | order.ordType = type; 41 | order.execInst = exec; 42 | bulk[Object.keys(bulk).length] = order; 43 | } 44 | // 添加批量卖单 45 | function BulkSell(symbol,qty,price,type,exec) { 46 | Log("新的Bulk订单 开空 "+ symbol + " " + price + " " + qty) 47 | var order = {}; 48 | order.symbol = symbol; 49 | order.side = "Sell"; 50 | order.orderQty = qty; 51 | order.price = price; 52 | order.ordType = type; 53 | order.execInst = exec; 54 | bulk[Object.keys(bulk).length] = order; 55 | } 56 | //执行批量订单 57 | function BulkPost() { 58 | Log("正在执行Bulk订单 共计 " + Object.keys(bulk).length + " 个订单"); 59 | var param = "orders=" + JSON.stringify(bulk); 60 | bulk = []; 61 | exchange.IO("api", "POST", "/api/v1/order/bulk", param); 62 | } 63 | //取消所有订单 64 | function CancelPendingOrders() { 65 | exchange.IO("api","DELETE","/api/v1/order/all","symbol="+exchange.GetCurrency()); 66 | } 67 | ``` 68 | 69 | > 策略出处 70 | 71 | https://www.fmz.com/strategy/105056 72 | 73 | > 更新时间 74 | 75 | 2018-08-30 03:01:43 76 | -------------------------------------------------------------------------------- /Bitmex仓位变化推送微信wss协议需要bitmex-api-IDBitmex-position-change-pushwebsocket.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Bitmex仓位变化推送微信wss协议需要bitmex-api-IDBitmex-position-change-pushwebsocket 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | 使用websocket协议和平台最新的HMAC获取签名的方法,仓位有变化推送到微信 13 | 14 | 15 | 16 | > 源码 (javascript) 17 | 18 | ``` javascript 19 | function main() { 20 | var APIKEY = "your Access Key(Bitmex API ID)" 21 | var expires = parseInt(Date.now() / 1000) + 10 22 | var signature = exchange.HMAC("sha256", "hex", "GET/realtime" + expires, "{{secretkey}}")//secretkey在执行时自动替换,不用填写 23 | var client = Dial("wss://www.bitmex.com/realtime", 60) 24 | var auth = JSON.stringify({args: [APIKEY, expires, signature], op: "authKeyExpires"}) 25 | var pos = 0 26 | client.write(auth) 27 | client.write('{"op": "subscribe", "args": "position"}') 28 | while (true) { 29 | bitmexData = client.read() 30 | if(bitmexData.table == 'position' && pos != parseInt(bitmexData.data[0].currentQty)){ 31 | Log('position change', pos, parseInt(bitmexData.data[0].currentQty), '@') 32 | pos = parseInt(bitmexData.data[0].currentQty) 33 | } 34 | } 35 | } 36 | ``` 37 | 38 | > 策略出处 39 | 40 | https://www.fmz.com/strategy/128624 41 | 42 | > 更新时间 43 | 44 | 2018-12-24 09:26:09 45 | -------------------------------------------------------------------------------- /Bn-获取精度最小变动单位-稳定交易系统必备.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Bn-获取精度最小变动单位-稳定交易系统必备 5 | 6 | > 策略作者 7 | 8 | btc【策略代写】团队 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | #!Python3 18 | 19 | """ 20 | 《策略代写》 与 (此程序帮助) 21 | 22 | 币安合约,可用于解决开单 因精度而产生异常 的问题,获取最小变动单位,用于稳定交易系统的运行 23 | """ 24 | 25 | import requests 26 | 27 | 28 | def get_min_size(symbol: str, host="https://www.binancezh.jp"): 29 | 30 | """ 31 | 获取最小变动单位 32 | Args: 33 | symbol: 交易对(str) 34 | 例如: ETHUSDT 等 35 | host: 域名将影响访问超时 36 | 国外地址: https://fapi.binance.com 37 | 国内地址(变动后需要替换): https://www.binancezh.jp 38 | Returns: 39 | 最小变动价格(str),最小变动数量(str) 40 | """ 41 | 42 | tick_size, step_size = None, None 43 | symbols_info = requests.get(f"{host}/fapi/v1/exchangeInfo", timeout=5).json()["symbols"] 44 | 45 | for info in symbols_info: 46 | if symbol == info["symbol"]: 47 | tick_size, step_size = info["filters"][0]["tickSize"], info["filters"][1]["stepSize"] 48 | break 49 | 50 | return tick_size, step_size 51 | 52 | 53 | def main(): 54 | tick_size, step_size = get_min_size("ETHUSDT") 55 | Log(tick_size, step_size) 56 | 57 | ``` 58 | 59 | > 策略出处 60 | 61 | https://www.fmz.com/strategy/347942 62 | 63 | > 更新时间 64 | 65 | 2022-05-11 19:02:40 66 | -------------------------------------------------------------------------------- /Brick-count-Renko.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Brick-count-Renko 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | > 策略描述 11 | 12 | 砖形指标 13 | 14 | 15 | 16 | > 源码 (PineScript) 17 | 18 | ``` javascript 19 | /*backtest 20 | start: 2021-05-08 00:00:00 21 | end: 2022-05-07 23:59:00 22 | period: 4h 23 | basePeriod: 15m 24 | exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] 25 | */ 26 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 27 | 28 | //@version=4 29 | study("Renko count", overlay=false) 30 | 31 | 32 | counter_green = iff(close > open, 1, 0) 33 | counter_red = iff(close > open, 0, 1) 34 | 35 | size = iff(bar_index>39, 40, bar_index+1) 36 | // function to create a rolling sum and return an integer value using series and series objects 37 | 38 | pine_sum(x, y) => 39 | sum = 0.0 40 | for i = 0 to y - 1 41 | sum := sum + x[i] 42 | 43 | brick_red = pine_sum(counter_red, size) 44 | brick_green = pine_sum(counter_green, size) 45 | if cross(brick_red, brick_green) 46 | label.new(bar_index, brick_red, style = label.style_arrowdown, size = size.normal, xloc =xloc.bar_index, color = color.green) 47 | 48 | plot(brick_red, color = color.red) 49 | plot(brick_green, color = color.green) 50 | if brick_red 51 | strategy.entry("buy", strategy.long) 52 | else if brick_green 53 | strategy.entry("sell", strategy.short) 54 | 55 | ``` 56 | 57 | > 策略出处 58 | 59 | https://www.fmz.com/strategy/368734 60 | 61 | > 更新时间 62 | 63 | 2022-06-12 16:39:56 64 | -------------------------------------------------------------------------------- /Candle-Strength.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Candle-Strength 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (PineScript) 15 | 16 | ``` javascript 17 | /*backtest 18 | start: 2021-05-08 00:00:00 19 | end: 2022-05-07 23:59:00 20 | period: 4h 21 | basePeriod: 15m 22 | exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] 23 | */ 24 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 25 | // © Trade_by_DB 26 | 27 | //@version=5 28 | indicator("Candle Strength",overlay = true ) 29 | 30 | 31 | 32 | 33 | //round function for rounding up to n decimal places 34 | //Thanks to Proper Round Function - QuantNomad 35 | 36 | roundn(x, n) => 37 | mult = 1 38 | if n != 0 39 | for i = 1 to math.abs(n) by 1 40 | mult *= 10 41 | mult 42 | 43 | n >= 0 ? math.round(x * mult) / mult : math.round(x / mult) * mult 44 | 45 | //calculating strength 46 | green = roundn(((close-low)/(high-low) *100), 2) 47 | red = roundn(((high-close)/(high-low)*100), 2) 48 | 49 | if (close>open) 50 | l = label.new(x = bar_index,y = close,text=str.tostring(green) + " %",color=color.green,textcolor = color.white,style=label.style_label_up) 51 | label.set_yloc(l,yloc.belowbar) 52 | strategy.entry("Enter Long", strategy.long) 53 | else if (open > close) 54 | l2 = label.new(x = bar_index,y = close,text=str.tostring(red)+ " %",color=color.red,textcolor=color.white,style=label.style_label_down) 55 | label.set_yloc(l2,yloc = yloc.abovebar) 56 | strategy.entry("Enter Short", strategy.short) 57 | 58 | ``` 59 | 60 | > 策略出处 61 | 62 | https://www.fmz.com/strategy/380219 63 | 64 | > 更新时间 65 | 66 | 2022-08-27 12:03:45 67 | -------------------------------------------------------------------------------- /Darvas-Box-Buy-Sell.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Darvas-Box-Buy-Sell 5 | 6 | > 策略作者 7 | 8 | 张超 9 | 10 | > 策略描述 11 | 12 | 13 | 14 | **backtest** 15 | ![IMG](https://www.fmz.com/upload/asset/10e8695aa04c6866260.png) 16 | 17 | > 策略参数 18 | 19 | 20 | 21 | |参数|默认值|描述| 22 | |----|----|----| 23 | |v_input_1|5|Length| 24 | 25 | 26 | > 源码 (PineScript) 27 | 28 | ``` javascript 29 | /*backtest 30 | start: 2022-04-30 00:00:00 31 | end: 2022-05-29 23:59:00 32 | period: 45m 33 | basePeriod: 5m 34 | exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] 35 | */ 36 | 37 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 38 | // © ceyhun 39 | 40 | //@version=4 41 | 42 | study("Darvas Box Buy Sell", overlay=true) 43 | 44 | boxp = input(defval=5, title="Length", minval=1, maxval=500) 45 | 46 | LL = lowest(low, boxp) 47 | k1 = highest(high, boxp) 48 | k2 = highest(high, boxp - 1) 49 | k3 = highest(high, boxp - 2) 50 | 51 | NH = valuewhen(high > k1[1], high, 0) 52 | box1 = k3 < k2 53 | TopBox = valuewhen(barssince(high > k1[1]) == boxp - 2 and box1, NH, 0) 54 | BottomBox = valuewhen(barssince(high > k1[1]) == boxp - 2 and box1, LL, 0) 55 | 56 | plot(TopBox, linewidth=2, color=#4CAF50, title="TBbox") 57 | plot(BottomBox, linewidth=2, color=#FF0000, title="BBbox") 58 | 59 | Buy = crossover(close, TopBox) 60 | Sell = crossunder(close, BottomBox) 61 | 62 | alertcondition(Buy, title="Buy Signal", message="Buy") 63 | alertcondition(Sell, title="Sell Signal", message="Sell") 64 | 65 | plotshape(Buy, style=shape.labelup, location=location.belowbar, color=#4CAF50, size=size.tiny, title="Buy Signal", text="Buy", textcolor=color.black) 66 | plotshape(Sell, style=shape.labeldown, location=location.abovebar, color=#FF0000, size=size.tiny, title="Sell Signal", text="Sell", textcolor=color.white) 67 | 68 | 69 | if Buy 70 | strategy.entry("Enter Long", strategy.long) 71 | else if Sell 72 | strategy.entry("Enter Short", strategy.short) 73 | ``` 74 | 75 | > 策略出处 76 | 77 | https://www.fmz.com/strategy/366948 78 | 79 | > 更新时间 80 | 81 | 2022-05-31 19:31:56 82 | -------------------------------------------------------------------------------- /Demo如何利用策略交互动态调整策略参数.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Demo如何利用策略交互动态调整策略参数 5 | 6 | > 策略作者 7 | 8 | momox 9 | 10 | > 策略描述 11 | 12 | 策略需要不断的测试调整,参数也经常改来改去,每次都停止再重启,费事费力,还会丢失原来的盈利进度(虽然也可以通过全局参数来恢复),其实botvs已经提供了动态调整参数的途径--”策略交互“ 13 | 14 | > 策略参数 15 | 16 | 17 | 18 | 19 | 20 | |按钮|默认值|描述| 21 | |----|----|----| 22 | |A3|999|AAA的参数| 23 | |B3|Botvs|BBB的参数| 24 | 25 | 26 | > 源码 (javascript) 27 | 28 | ``` javascript 29 | var Interval=2000; 30 | 31 | //AAA,BBB为策略中希望动态调整的参数 32 | var AAA=0; 33 | var BBB="hello world"; 34 | 35 | function main() { 36 | while(true){ 37 | onTick(); 38 | Sleep(Interval); 39 | } 40 | } 41 | 42 | function onTick(){ 43 | set_command(); 44 | Log("AAA="+AAA," BBB="+BBB); 45 | } 46 | 47 | //获取动态参数(策略交互内容) 48 | function set_command() { 49 | 50 | var get_command = GetCommand();// GetCommand方法是获取参数方法,获取的参数是字符串形式 格式为 "参数名:参数值" 参见BotVS API文档 51 | if (get_command != null) { 52 | if (get_command.indexOf("A3:") == 0) { //如果传入的参数名为A3(以“A3:”打头,即表明是A3参数) 53 | 54 | AAA = (get_command.replace("A3:", "")); //赋值给策略里面的AAA(将打头字符串替换为空,剩下就是我们的参数值) 55 | 56 | Log("AAA变成:" + AAA); 57 | } 58 | 59 | if (get_command.indexOf("B3:") == 0) { //如果传入的参数名为B3(以“B3:”打头,即表明是B3参数) 60 | 61 | BBB = (get_command.replace("B3:", "")); //赋值给策略里面的BBB(将打头字符串替换为空,剩下就是我们的参数值) 62 | 63 | Log("BBB变成:" + BBB); 64 | } 65 | 66 | } 67 | } 68 | ``` 69 | 70 | > 策略出处 71 | 72 | https://www.fmz.com/strategy/8379 73 | 74 | > 更新时间 75 | 76 | 2016-01-09 21:18:07 77 | -------------------------------------------------------------------------------- /Diamond-Trend.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Diamond-Trend 5 | 6 | > 策略作者 7 | 8 | 张超 9 | 10 | > 策略描述 11 | 12 | Diamond Trend is an indicator clearly way to catch the trend in the begining $$ 13 | 14 | **backtest** 15 | 16 | ![IMG](https://www.fmz.com/upload/asset/f6a5f43fe714bdae29.png) 17 | 18 | > 策略参数 19 | 20 | 21 | 22 | |参数|默认值|描述| 23 | |----|----|----| 24 | |v_input_1|0.02|start| 25 | |v_input_2|0.02|increment| 26 | |v_input_3|0.2|maximum| 27 | |v_input_4|100|len| 28 | |v_input_5|1.9|Deviation| 29 | 30 | 31 | > 源码 (PineScript) 32 | 33 | ``` javascript 34 | /*backtest 35 | start: 2022-04-09 00:00:00 36 | end: 2022-05-08 23:59:00 37 | period: 15m 38 | basePeriod: 5m 39 | exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] 40 | */ 41 | 42 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 43 | // © meer2019 44 | //@version=4 45 | study(title="PSAR x", overlay=true) 46 | start = input(0.02) 47 | increment = input(0.02) 48 | maximum = input(0.2) 49 | c=close 50 | 51 | psar = sar(start, increment, maximum) 52 | cp = psar 53 | len = input(100, minval=1),off= 0,dev= input(1.9, "Deviation") 54 | lreg = linreg(cp, len, off), lreg_x =linreg(cp, len, off+1) 55 | b = bar_index, s = lreg - lreg_x,intr = lreg - b*s 56 | dS = 0.0 57 | for i=0 to len-1 58 | dS:= dS + pow(cp[i]-(s*(b-i)+intr), 2) 59 | de = sqrt(dS/(len)) 60 | up = (-de*dev) + psar 61 | down= (de*dev) + psar 62 | 63 | up_t = 0.0 64 | up_t := c[1] > up_t[1] ? max(up, up_t[1]) : up 65 | down_t = 0.0 66 | down_t := c[1] < down_t[1] ? min(down, down_t[1]) : down 67 | trend = 0 68 | trend := c > down_t[1] ? 1: c < up_t[1] ? -1 : nz(trend[1], 1) 69 | 70 | // 71 | r_line = trend ==1 ? up_t : down_t 72 | plot(r_line) 73 | buy=crossover( c, r_line) 74 | sell=crossunder(c, r_line) 75 | 76 | if buy 77 | strategy.entry("Enter Long", strategy.long) 78 | else if sell 79 | strategy.entry("Enter Short", strategy.short) 80 | 81 | ``` 82 | 83 | > 策略出处 84 | 85 | https://www.fmz.com/strategy/362178 86 | 87 | > 更新时间 88 | 89 | 2022-05-10 14:47:48 90 | -------------------------------------------------------------------------------- /Directional-Movement-Oscillator-DMI.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Directional-Movement-Oscillator-DMI 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |v_input_1|10|DI Length| 19 | |v_input_2|8|DI Smoothing Length| 20 | 21 | 22 | > 源码 (PineScript) 23 | 24 | ``` javascript 25 | /*backtest 26 | start: 2021-05-08 00:00:00 27 | end: 2022-05-07 23:59:00 28 | period: 4h 29 | basePeriod: 15m 30 | exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] 31 | */ 32 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 33 | // © prince_ond 34 | 35 | //@version=4 36 | study("Directional Movement Oscillator", shorttitle="DMI_oscilattor") 37 | 38 | // === INPUTS === 39 | 40 | len = input(10, title="DI Length") 41 | avlength=input(8, title="DI Smoothing Length") 42 | up = change(high) 43 | down = -change(low) 44 | truerange = rma(tr, len) 45 | plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, len) / truerange) 46 | minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, len) / truerange) 47 | diosc = plus-minus 48 | signal= sma(diosc,avlength) 49 | 50 | p1 = plot(diosc, linewidth=1, color=color.red, title="DIOSC", transp=100) 51 | p2 = plot(signal, linewidth=2, color=color.blue, title="Signal") 52 | p3 = plot(0, color=color.black) 53 | 54 | plot(diosc, color = diosc <= 0 ? color.red : color.green, style=plot.style_columns, transp=20) 55 | fill(p2, p3, color= signal > 0 ? color.green : color.red, transp=30, title='DMI_signal') 56 | if diosc 57 | strategy.entry("buy", strategy.long) 58 | else if p2 59 | strategy.entry("sell", strategy.short) 60 | 61 | ``` 62 | 63 | > 策略出处 64 | 65 | https://www.fmz.com/strategy/369999 66 | 67 | > 更新时间 68 | 69 | 2022-06-20 21:26:14 70 | -------------------------------------------------------------------------------- /EMA-2155200.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | EMA-2155200 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (PineScript) 15 | 16 | ``` javascript 17 | /*backtest 18 | start: 2021-08-20 00:00:00 19 | end: 2022-08-26 00:00:00 20 | period: 1d 21 | basePeriod: 1h 22 | */ 23 | 24 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 25 | // © BrendanW98 26 | 27 | //@version=4 28 | strategy("EMA 21,55,200", overlay=true) 29 | 30 | ema5 = ema(close, 21) 31 | ema20 = ema(close, 55) 32 | ema50 = ema(close, 200) 33 | 34 | //RSI Signals 35 | // Get user input 36 | rsiSource = close 37 | rsiLength = 14 38 | rsiOverbought = 70 39 | rsiOversold = 30 40 | rsiMid = 50 41 | // Get RSI value 42 | rsiValue = rsi(rsiSource, rsiLength) 43 | 44 | //See if RSI crosses 50 45 | doBuy = crossover(rsiValue, rsiOversold) and rsiValue < 50 46 | doSell = crossunder(rsiValue, rsiOverbought) and rsiValue > 50 47 | 48 | emacrossover = crossover(ema5, ema20) and ema5 > ema50 and ema20 > ema50 and close > ema50 49 | emacrossunder = crossunder(ema5, ema20) and ema5 < ema50 and ema20 < ema50 and close < ema50 50 | 51 | //Entry and Exit 52 | longCondition = emacrossover 53 | closelongCondition = doSell 54 | 55 | strategy.entry("Long", strategy.long, 100, when=longCondition) 56 | strategy.close("Long", when=closelongCondition) 57 | 58 | 59 | shortCondition = emacrossunder 60 | closeshortCondition = doBuy 61 | 62 | strategy.entry("Short", strategy.short, 100, when=shortCondition) 63 | strategy.close("Short", when=closeshortCondition) 64 | 65 | ``` 66 | 67 | > 策略出处 68 | 69 | https://www.fmz.com/strategy/380291 70 | 71 | > 更新时间 72 | 73 | 2022-08-27 21:56:34 74 | -------------------------------------------------------------------------------- /Exit-from-specific-entries.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Exit-from-specific-entries 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (PineScript) 15 | 16 | ``` javascript 17 | //@version=4 18 | strategy(title="Exit from specific entries", overlay=true, 19 | pyramiding=2, close_entries_rule="ANY") 20 | 21 | // Determine trading conditions 22 | newDay = (dayofmonth != dayofmonth[1]) 23 | 24 | firstEntry = newDay and (dayofweek == dayofweek.monday) 25 | secondEntry = newDay and (dayofweek == dayofweek.tuesday) 26 | 27 | firstExit = newDay and (dayofweek == dayofweek.thursday) 28 | secondExit = newDay and (dayofweek == dayofweek.friday) 29 | 30 | // Submit entry orders 31 | if (firstEntry) 32 | strategy.entry(id="EL 1", long=true) 33 | 34 | if (secondEntry) 35 | strategy.entry(id="EL 2", long=true) 36 | 37 | // Generate exit orders 38 | if (firstExit) 39 | strategy.close(id="EL 2") 40 | 41 | if (secondExit) 42 | strategy.close(id="EL 1") 43 | ``` 44 | 45 | > 策略出处 46 | 47 | https://www.fmz.com/strategy/395966 48 | 49 | > 更新时间 50 | 51 | 2023-01-07 21:20:36 52 | -------------------------------------------------------------------------------- /Gann-High-Low.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Gann-High-Low 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |v_input_1|13|HIGH Period| 19 | |v_input_2|21|LOW Period| 20 | 21 | 22 | > 源码 (PineScript) 23 | 24 | ``` javascript 25 | /*backtest 26 | start: 2021-05-08 00:00:00 27 | end: 2022-05-07 23:59:00 28 | period: 4h 29 | basePeriod: 15m 30 | exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] 31 | */ 32 | //@version=5 33 | indicator('Gann High Low', overlay=true) 34 | HPeriod = input(13, 'HIGH Period') 35 | LPeriod = input(21, 'LOW Period') 36 | iff_1 = close < nz(ta.sma(low, LPeriod))[1] ? -1 : 0 37 | HLd = close > nz(ta.sma(high, HPeriod))[1] ? 1 : iff_1 38 | HLv = ta.valuewhen(HLd != 0, HLd, 0) 39 | sma_1 = ta.sma(high, HPeriod) 40 | sma_2 = ta.sma(low, LPeriod) 41 | HiLo = HLv == -1 ? sma_1 : sma_2 42 | HLcolor = HLv == -1 ? color.maroon : color.blue 43 | plot(HiLo, linewidth=2, color=HLcolor) 44 | 45 | alertcondition(ta.cross(close, HiLo), title='Price Cross Alert', message='Price - HiLo Crossing!') 46 | alertcondition(ta.crossover(close, HiLo), title='PRICE CrossOver Alarm', message='LAST PRICE is ABOVE HiLo') 47 | alertcondition(ta.crossunder(close, HiLo), title='PRICE CrossUnder Alarm', message='LAST PRICE is BELOW HiLo!') 48 | buySignal=ta.crossover(close, HiLo) 49 | sellSignal=ta.crossunder(close, HiLo) 50 | if buySignal 51 | strategy.entry("buy", strategy.long) 52 | else if sellSignal 53 | strategy.entry("sell", strategy.short) 54 | ``` 55 | 56 | > 策略出处 57 | 58 | https://www.fmz.com/strategy/370655 59 | 60 | > 更新时间 61 | 62 | 2022-06-25 10:00:25 63 | -------------------------------------------------------------------------------- /Get-cryptocurrency-current-and-max-supply获取币种供应量.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Get-cryptocurrency-current-and-max-supply获取币种供应量 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | 使用coinmarketcap提供的API接口获取币种供应量和流通量,可用于计算总市值 13 | 14 | 15 | 16 | > 源码 (javascript) 17 | 18 | ``` javascript 19 | function GetSupply(symbol, max){ 20 | var ids = null 21 | if(_G('ids')){ 22 | ids = _G('ids') 23 | }else{ 24 | ids = JSON.parse(HttpQuery('https://api.coinmarketcap.com/v2/listings/')).data 25 | _G('ids', ids) 26 | } 27 | var coinId = null 28 | for (var i=0; i 策略出处 48 | 49 | https://www.fmz.com/strategy/122370 50 | 51 | > 更新时间 52 | 53 | 2019-07-03 16:33:08 54 | -------------------------------------------------------------------------------- /Gooners-BTC-Weekly-RSI-Hack-Strategy.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Gooners-BTC-Weekly-RSI-Hack-Strategy 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |v_input_1|14|length| 19 | |v_input_2|52|buylevel| 20 | |v_input_3|52|selllevel| 21 | 22 | 23 | > 源码 (PineScript) 24 | 25 | ``` javascript 26 | /*backtest 27 | start: 2015-05-08 00:00:00 28 | end: 2022-05-07 23:59:00 29 | period: 4h 30 | basePeriod: 15m 31 | exchanges: [{"eid":"Binance","currency":"BTC_USDT"}] 32 | */ 33 | //@version=5 34 | strategy("Gooners BTC Weekly RSI Hack Strategy", overlay = true, default_qty_value = 100, default_qty_type = strategy.percent_of_equity, initial_capital = 1000000) 35 | length = input( 14 ) 36 | buylevel = input( 52 ) 37 | selllevel = input( 52 ) 38 | price = close 39 | rsi = ta.rsi(price, length) 40 | co = ta.crossover(rsi, buylevel) 41 | cu = ta.crossunder(rsi, selllevel) 42 | if (not na(rsi)) 43 | if (co) 44 | strategy.entry("RsiLE", strategy.long, comment="RsiLE") 45 | if (cu) 46 | strategy.close("RsiLE", comment="RsiLC") 47 | ``` 48 | 49 | > 策略出处 50 | 51 | https://www.fmz.com/strategy/380277 52 | 53 | > 更新时间 54 | 55 | 2022-08-27 21:19:13 56 | -------------------------------------------------------------------------------- /GuoJian_First.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | GuoJian_First 5 | 6 | > 策略作者 7 | 8 | liuguojian 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |min|0.0085|买入最小值| 19 | |max|0.008534|卖出最大值| 20 | 21 | 22 | > 源码 (javascript) 23 | 24 | ``` javascript 25 | /*backtest 26 | start: 2018-08-27 00:00:00 27 | end: 2018-08-28 20:00:00 28 | period: 1m 29 | exchanges: [{"eid":"Huobi","currency":"LTC_BTC"}] 30 | */ 31 | 32 | function main() { 33 | Log(max); 34 | Log(min); 35 | var a = 1; 36 | while(true){ 37 | Log(exchange.GetAccount()); 38 | var ticker = exchange.GetTicker(); 39 | Log(ticker); 40 | if(ticker.High >= max){ 41 | //Log("当前最高价"+ticker.High); 42 | //Log("将所有USDT换成BTC"); 43 | Log("卖出1"); 44 | exchange.Sell(-1, 1); 45 | Log(exchange.GetAccount()); 46 | 47 | } 48 | if(ticker.Low <= min){ 49 | Log("买入1"); 50 | exchange.Buy(-1, 1); 51 | Log(exchange.GetAccount()); 52 | break; 53 | } 54 | a++; 55 | Sleep(60000); // 一分钟 56 | } 57 | 58 | } 59 | 60 | function onexit(){ 61 | Log("onexit"); 62 | } 63 | 64 | function onerror(){ 65 | Log("onerror"); 66 | } 67 | 68 | function init(){ 69 | Log("init"); 70 | } 71 | 72 | 73 | 74 | 75 | 76 | 77 | ``` 78 | 79 | > 策略出处 80 | 81 | https://www.fmz.com/strategy/113871 82 | 83 | > 更新时间 84 | 85 | 2018-08-28 21:43:15 86 | -------------------------------------------------------------------------------- /Highest-high-lowest-low-stop.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Highest-high-lowest-low-stop 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |v_input_1|20|Highest High Lookback| 19 | |v_input_2|20|Lowest Low Lookback| 20 | 21 | 22 | > 源码 (PineScript) 23 | 24 | ``` javascript 25 | //@version=3 26 | strategy(title="Highest high/lowest low stop", overlay=true) 27 | 28 | // STEP 1: 29 | // Make inputs for length of highest high and lowest low 30 | hiLen = input(title="Highest High Lookback", type=input.integer, 31 | defval=20, minval=2) 32 | 33 | loLen = input(title="Lowest Low Lookback", type=input.integer, 34 | defval=20, minval=2) 35 | 36 | // STEP 2: 37 | // Calculate recent extreme high and low 38 | hiHighs = highest(high, hiLen)[1] 39 | loLows = lowest(low, loLen)[1] 40 | 41 | // Plot stop values for visual confirmation 42 | plot(series=(strategy.position_size > 0) ? loLows : na, 43 | style=circles, color=green, linewidth=3, 44 | title="Lowest Low Stop") 45 | 46 | plot(series=(strategy.position_size < 0) ? hiHighs : na, 47 | style=circles, color=red, linewidth=3, 48 | title="Highest High Stop") 49 | 50 | // Trading conditions for this example strategy 51 | higherCloses = (close > close[1]) and 52 | (close[1] > close[2]) and (close[2] > close[3]) 53 | lowerCloses = (close < close[1]) and 54 | (close[1] < close[2]) and (close[2] < close[3]) 55 | isFlat = (strategy.position_size == 0) 56 | 57 | // Submit entry orders 58 | if (isFlat and higherCloses) 59 | strategy.entry(id="EL", long=true) 60 | 61 | if (isFlat and lowerCloses) 62 | strategy.entry(id="ES", long=false) 63 | 64 | // STEP 3: 65 | // Submit stops based on highest high and lowest low 66 | if (strategy.position_size > 0) 67 | strategy.exit(id="XL HH", stop=loLows) 68 | 69 | if (strategy.position_size < 0) 70 | strategy.exit(id="XS LL", stop=hiHighs) 71 | ``` 72 | 73 | > 策略出处 74 | 75 | https://www.fmz.com/strategy/395962 76 | 77 | > 更新时间 78 | 79 | 2023-01-07 21:10:04 80 | -------------------------------------------------------------------------------- /KLineChart-演示KLineChart-Demo.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | KLineChart-演示KLineChart-Demo 5 | 6 | > 策略作者 7 | 8 | 发明者量化 9 | 10 | > 策略描述 11 | 12 | 平台(Javascript/Python语言)开通KLineChart支持, 支持Pine语言全部画图功能(参数保持一致), 支持自定义买卖信号 13 | 下面是一个演示的例子 14 | 15 | 参考文档 https://www.fmz.com/api#klinechart 16 | 17 | 18 | ![IMG](https://www.fmz.com/upload/asset/bb180d6a028bcc6993.png) 19 | 20 | 21 | 22 | 23 | 24 | 25 | > 源码 (javascript) 26 | 27 | ``` javascript 28 | /*backtest 29 | start: 2022-05-31 00:00:00 30 | end: 2022-06-29 23:59:00 31 | period: 1h 32 | basePeriod: 15m 33 | exchanges: [{"eid":"Binance","currency":"BTC_USDT"}] 34 | */ 35 | 36 | function main() { 37 | let c = KLineChart({overlay: true}) 38 | let bars = exchange.GetRecords() 39 | if (!bars) { 40 | return 41 | } 42 | bars.forEach(function(bar) { 43 | c.begin(bar) 44 | c.barcolor(bar.Close > bar.Open ? 'rgba(255, 0, 0, 0.2)' : 'rgba(0, 0, 0, 0.2)') 45 | if (bar.Close > bar.Open) { 46 | c.bgcolor('rgba(0, 255, 0, 0.5)') 47 | } 48 | let h = c.plot(bar.High, 'high') 49 | let l = c.plot(bar.Low, 'low') 50 | 51 | c.fill(h, l, { 52 | color: bar.Close > bar.Open ? 'rgba(255, 0, 0, 0.2)' : 'rgba(255, 0, 0, 0.2)' 53 | }) 54 | c.hline(bar.High) 55 | c.plotarrow(bar.Close - bar.Open) 56 | c.plotshape(bar.Low, { 57 | style: 'diamond' 58 | }) 59 | c.plotchar(bar.Close, { 60 | char: 'X' 61 | }) 62 | c.plotcandle(bar.Open*0.9, bar.High*0.9, bar.Low*0.9, bar.Close*0.9) 63 | if (bar.Close > bar.Open) { 64 | // long/short/closelong/closeshort 65 | c.signal("long", bar.High, 1.5) 66 | } else if (bar.Close < bar.Open) { 67 | c.signal("closelong", bar.Low, 1.5) 68 | } 69 | c.close() 70 | }) 71 | } 72 | ``` 73 | 74 | > 策略出处 75 | 76 | https://www.fmz.com/strategy/362951 77 | 78 | > 更新时间 79 | 80 | 2022-07-01 17:57:22 81 | -------------------------------------------------------------------------------- /KRT凯尔特纳通道.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | KRT凯尔特纳通道 5 | 6 | > 策略作者 7 | 8 | cyberking 9 | 10 | > 策略描述 11 | 12 | ZF:=H-C; //振幅 13 | DX:=H+L+C)/3; //典型价格 14 | KRTHR^^EMA(DX,10)+EMA(ZF,10); //凯尔特纳上轨 15 | KRTXR^^EMA(DX,10)-EMA(ZF,10); //凯尔特纳下轨 16 | 17 | 18 | 19 | > 源码 (麦语言) 20 | 21 | ``` pascal 22 | (*backtest 23 | start: 2019-02-04 00:00:00 24 | end: 2020-03-04 00:00:00 25 | period: 1d 26 | exchanges: [{"eid":"Huobi","currency":"BTC_USDT"}] 27 | *) 28 | 29 | 30 | ZF:=H-C; //振幅 31 | DX:=H+L+C)/3; //典型价格 32 | KRTHR^^EMA(DX,10)+EMA(ZF,10); //凯尔特纳上轨 33 | KRTXR^^EMA(DX,10)-EMA(ZF,10); //凯尔特纳下轨 34 | C>KRTHR,BPK; 35 | C 策略出处 40 | 41 | https://www.fmz.com/strategy/188499 42 | 43 | > 更新时间 44 | 45 | 2020-03-05 11:41:52 46 | -------------------------------------------------------------------------------- /KijunSen-Line-With-Cross.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | KijunSen-Line-With-Cross 5 | 6 | > 策略作者 7 | 8 | 张超 9 | 10 | > 策略描述 11 | 12 | Kijen Sen Independent Line of Ichimoku Trading System 13 | 14 | 15 | Many traders in the financial markets use Ichimoku components to detect trends, which is why I published this indicator. 16 | 17 | **backtest** 18 | 19 | ![IMG](https://www.fmz.com/upload/asset/159637efb31d4192cce.png) 20 | 21 | > 策略参数 22 | 23 | 24 | 25 | |参数|默认值|描述| 26 | |----|----|----| 27 | |v_input_1|26|Length| 28 | |v_input_2|true|Show Candle Cross?| 29 | 30 | 31 | > 源码 (PineScript) 32 | 33 | ``` javascript 34 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 35 | // © dilan1999 36 | 37 | //@version=5 38 | indicator('KijunSen Line With Cross', overlay=true) 39 | n = input(26, 'Length') 40 | h = ta.highest(high, n) 41 | l = ta.lowest(low, n) 42 | value = (h + l) / 2 43 | 44 | 45 | 46 | showCross = input(true, title='Show Candle Cross?') 47 | crossUp = ta.crossover(hl2, value) 48 | crossDown = ta.crossunder(hl2, value) 49 | 50 | //Show Cross 51 | plotshape(showCross and crossUp, text='*', style=shape.labelup, location=location.belowbar, color=color.new(color.green, 0), textcolor=color.new(color.white, 0), size=size.small) 52 | plotshape(showCross and crossDown, text='*', style=shape.labeldown, location=location.abovebar, color=color.new(color.red, 0), textcolor=color.new(color.white, 0), size=size.small) 53 | 54 | //Drawline 55 | plot(value, color=(hl2 > value ? color.lime : color.red), linewidth=2) 56 | if showCross and crossUp 57 | strategy.entry("Enter Long", strategy.long) 58 | else if showCross and crossDown 59 | strategy.entry("Enter Short", strategy.short) 60 | 61 | ``` 62 | 63 | > 策略出处 64 | 65 | https://www.fmz.com/strategy/362223 66 | 67 | > 更新时间 68 | 69 | 2022-05-10 18:56:36 70 | -------------------------------------------------------------------------------- /Larry-Connors-RSI2均值回归策略.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Larry-Connors-RSI2均值回归策略 5 | 6 | > 策略作者 7 | 8 | homily 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |Y|70|Y| 19 | 20 | 21 | > 源码 (麦语言) 22 | 23 | ``` pascal 24 | (*backtest 25 | start: 2018-01-01 00:00:00 26 | end: 2020-05-12 00:00:00 27 | period: 15m 28 | basePeriod: 15m 29 | exchanges: [{"eid":"Futures_OKCoin","currency":"BTC_USD"}] 30 | args: [["TradeAmount",5000,126961],["MaxAmountOnce",5000,126961],["ContractType","quarter",126961]] 31 | *) 32 | 33 | 34 | //https://school.stockcharts.com/doku.php?id=trading_strategies:rsi2 35 | //http://gbeced.github.io/pyalgotrade/docs/v0.20/html/sample_rsi2.html 36 | 37 | 38 | liang:=INTPART(1*MONEYTOT*REF(C,1)/100); 39 | 40 | LC := REF(CLOSE,1); 41 | RSI2: SMA(MAX(CLOSE-LC,0),2,1)/SMA(ABS(CLOSE-LC),2,1)*100; 42 | 43 | ma1:=MA(CLOSE,Y); 44 | 45 | CLOSE>ma1 AND RSI2>90,SK(liang); 46 | CLOSE>ma1 AND RSI2<10,BP(SKVOL); 47 | 48 | CLOSE90,SP(BKVOL); 50 | 51 | 52 | AUTOFILTER; 53 | ``` 54 | 55 | > 策略出处 56 | 57 | https://www.fmz.com/strategy/207157 58 | 59 | > 更新时间 60 | 61 | 2020-05-14 09:50:47 62 | -------------------------------------------------------------------------------- /Lbuy_Hsell-低买高卖.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Lbuy_Hsell-低买高卖 5 | 6 | > 策略作者 7 | 8 | sltrain 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | '''backtest 18 | start: 2020-05-31 00:00:00 19 | end: 2020-08-28 00:00:00 20 | period: 1day 21 | exchanges: [{"eid":"huobi","currency":"BTC_USDT"}] 22 | ''' 23 | 24 | ratio = 0.01 25 | acc = 0 26 | minStock = 0.01 27 | 28 | def main(): 29 | global ratio,acc,minStock 30 | exchanges[0].SetPrecision(2, 3) 31 | Log('hello sltrain@') 32 | #Log(exchanges[0].GetAccount()) 33 | tickers = _C(exchanges[0].GetTicker) 34 | #Log(tickers) 35 | while(True): 36 | tickers_new = _C(exchanges[0].GetTicker) 37 | if tickers_new.Last > tickers.Last * (1 + ratio): 38 | acc = _C(exchanges[0].GetAccount) 39 | id = exchanges[0].Sell(tickers_new.Last, acc.Stocks * ratio) 40 | Log("id:", id) 41 | elif tickers_new.Last < tickers.Last * (1 + ratio): 42 | acc = _C(exchanges[0].GetAccount) 43 | id = exchanges[0].Buy(tickers_new.Last, (acc.Balance * ratio)/tickers_new.Last) 44 | Log("id:", id) 45 | if tickers_new.Last == tickers.Last: 46 | continue 47 | tickers = tickers_new 48 | Sleep(20*60*1000) 49 | 50 | 51 | 52 | ``` 53 | 54 | > 策略出处 55 | 56 | https://www.fmz.com/strategy/224579 57 | 58 | > 更新时间 59 | 60 | 2020-08-29 21:22:50 61 | -------------------------------------------------------------------------------- /Linear-trend.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Linear-trend 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |v_input_1_close|0|c: close|high|low|open|hl2|hlc3|hlcc4|ohlc4| 19 | |v_input_2|200|len| 20 | |v_input_3|4|Deviation| 21 | 22 | 23 | > 源码 (PineScript) 24 | 25 | ``` javascript 26 | /*backtest 27 | start: 2021-05-08 00:00:00 28 | end: 2022-05-07 23:59:00 29 | period: 4h 30 | basePeriod: 15m 31 | exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] 32 | */ 33 | 34 | // © RafaelZioni 35 | 36 | //@version=4 37 | strategy(title = "Linear trend", overlay = true) 38 | // 39 | 40 | c = input(close) 41 | len = input(200, minval=1),off= 0,dev= input(4, "Deviation") 42 | lreg = linreg(c, len, off), lreg_x =linreg(c, len, off+1) 43 | b = bar_index, s = lreg - lreg_x,intr = lreg - b*s 44 | dS = 0.0 45 | for i=0 to len-1 46 | dS:= dS + pow(c[i]-(s*(b-i)+intr), 2) 47 | de = sqrt(dS/(len)) 48 | up = (-de*dev) + lreg 49 | down= (de*dev) + lreg 50 | 51 | up_t = 0.0 52 | up_t := c[1] > up_t[1] ? max(up, up_t[1]) : up 53 | down_t = 0.0 54 | down_t := c[1] < down_t[1] ? min(down, down_t[1]) : down 55 | trend = 0 56 | trend := c > down_t[1] ? 1: c < up_t[1] ? -1 : nz(trend[1], 1) 57 | 58 | // 59 | r_line = trend ==1 ? up_t : down_t 60 | plot(r_line) 61 | buy=crossover( c, r_line) 62 | sell=crossunder(c, r_line) 63 | 64 | plotshape(buy, style=shape.triangleup, size=size.normal, location=location.belowbar, color=color.lime) 65 | plotshape(sell, style=shape.triangledown, size=size.normal, location=location.abovebar, color=color.red) 66 | 67 | /////// Alerts ///// 68 | alertcondition(buy,title="buy") 69 | alertcondition(sell,title="sell") 70 | if buy 71 | strategy.entry("long", strategy.long) 72 | else if sell 73 | strategy.entry("short", strategy.short) 74 | ``` 75 | 76 | > 策略出处 77 | 78 | https://www.fmz.com/strategy/367476 79 | 80 | > 更新时间 81 | 82 | 2022-06-03 16:09:05 83 | -------------------------------------------------------------------------------- /Low-finder.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Low-finder 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |v_input_1|21|length| 19 | |v_input_2|false|Highdetector| 20 | 21 | 22 | > 源码 (PineScript) 23 | 24 | ``` javascript 25 | /*backtest 26 | start: 2021-05-08 00:00:00 27 | end: 2022-05-07 23:59:00 28 | period: 4h 29 | basePeriod: 15m 30 | exchanges: [{"eid":"Binance","currency":"BTC_USDT"}] 31 | */ 32 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 33 | // © RafaelZioni 34 | 35 | //@version=4 36 | study(title = "Low finder ", overlay = true) 37 | length=input(21) 38 | // 39 | p = close 40 | vrsi = rsi(p, length) 41 | pp=ema(vrsi,length) 42 | d=(vrsi-pp)*5 43 | cc=(vrsi+d+pp)/2 44 | // 45 | low1=crossover(cc,0) 46 | plotshape(low1 , title="Low", text="Low", color=color.green, style=shape.labelup, location=location.belowbar, size=size.small, textcolor=color.white, transp=0) 47 | /////// Alerts ///// 48 | alertcondition(low1,title="Low detected") 49 | // 50 | bb=(vrsi-d+pp)/2 51 | // 52 | Highdetector=input(false) 53 | high1=crossunder(bb,90) 54 | plotshape(Highdetector and high1, title="High", text="High", color=color.red, style=shape.labeldown, location=location.abovebar, size=size.small, textcolor=color.white, transp=0) 55 | /////// Alerts ///// 56 | alertcondition(high1,title="High detected") 57 | if low1 58 | strategy.entry("buy", strategy.long) 59 | else if high1 60 | strategy.entry("sell", strategy.short) 61 | 62 | ``` 63 | 64 | > 策略出处 65 | 66 | https://www.fmz.com/strategy/366391 67 | 68 | > 更新时间 69 | 70 | 2022-05-29 07:41:54 71 | -------------------------------------------------------------------------------- /MACD-Pine简单策略.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | MACD-Pine简单策略 5 | 6 | > 策略作者 7 | 8 | 发明者量化 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |v_input_1|12|fast| 19 | |v_input_int_1|26|slow| 20 | |v_input_float_1|9|signal| 21 | 22 | 23 | > 源码 (PineScript) 24 | 25 | ``` javascript 26 | /*backtest 27 | start: 2021-05-04 00:00:00 28 | end: 2022-05-03 23:59:00 29 | period: 1d 30 | basePeriod: 1h 31 | exchanges: [{"eid":"Bitfinex","currency":"BTC_USD"}] 32 | */ 33 | 34 | 35 | fastPeriod = input(12, "fast") 36 | slowPeriod = input.int(26, "slow") 37 | singnalPeriod = input.float(9, "signal") 38 | 39 | 40 | [fast, slow, _] = ta.macd(close, fastPeriod, slowPeriod, singnalPeriod) 41 | plot(fast, 'fast') 42 | plot(slow, 'slow') 43 | 44 | if fast>slow and fast[1]slow[1] 47 | strategy.entry("Enter Short", strategy.short) 48 | 49 | 50 | ``` 51 | 52 | > 策略出处 53 | 54 | https://www.fmz.com/strategy/356844 55 | 56 | > 更新时间 57 | 58 | 2022-05-23 18:08:17 59 | -------------------------------------------------------------------------------- /MAHL-Band.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | MAHL-Band 5 | 6 | > 策略作者 7 | 8 | 张超 9 | 10 | > 策略描述 11 | 12 | The channel composed of the high price and low price moving average 13 | 14 | **backtest** 15 | 16 | ![IMG](https://www.fmz.com/upload/asset/ec8392508188c41741.png) 17 | 18 | > 策略参数 19 | 20 | 21 | 22 | |参数|默认值|描述| 23 | |----|----|----| 24 | |v_input_int_1|3|MA Length| 25 | 26 | 27 | > 源码 (PineScript) 28 | 29 | ``` javascript 30 | /*backtest 31 | start: 2022-04-10 00:00:00 32 | end: 2022-05-09 23:59:00 33 | period: 10m 34 | basePeriod: 1m 35 | exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] 36 | */ 37 | 38 | //@version=5 39 | indicator(title="MAHL Band", overlay=true, timeframe="", timeframe_gaps=true) 40 | malen = input.int(3, "MA Length", minval=1) 41 | mahv = ta.sma(high, malen) 42 | malv = ta.sma(low, malen) 43 | mamv = (mahv + malv) / 2 44 | mah = plot(mahv, color = #FF6D00, style = plot.style_line) 45 | mal = plot(malv, color = #43A047) 46 | mam = plot(mamv, color = color.blue) 47 | 48 | upperv = ta.highest(mahv, 60) 49 | lowerv = ta.lowest(malv, 60) 50 | middlev = (upperv + lowerv) / 2 51 | 52 | upper = plot(upperv, color = color.red, linewidth = 2) 53 | lower = plot(lowerv, color = color.green, linewidth = 2) 54 | middle = plot(middlev, color = color.yellow, linewidth = 2) 55 | 56 | 57 | [diplus, diminus, adx] = ta.dmi(17, 14) 58 | 59 | up = (open < (malv - low / 3 + open / 3)) and (diplus[1] > diminus[1]) and mamv[1] > mamv[2] 60 | down = (open > (mahv - high / 3 + open / 3)) and (diplus[1] < diminus[1]) and mamv[1] < mamv[2] 61 | plotshape(up, style=shape.arrowup, location=location.belowbar, color=color.red) 62 | plotshape(down, style=shape.arrowdown, location=location.abovebar, color=color.green) 63 | 64 | if up 65 | strategy.entry("Enter Long", strategy.long) 66 | else if down 67 | strategy.entry("Enter Short", strategy.short) 68 | ``` 69 | 70 | > 策略出处 71 | 72 | https://www.fmz.com/strategy/362497 73 | 74 | > 更新时间 75 | 76 | 2022-05-11 20:48:53 77 | -------------------------------------------------------------------------------- /My语言仓位变化推送通知.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | My语言仓位变化推送通知 5 | 6 | > 策略作者 7 | 8 | 发明者量化 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (麦语言) 15 | 16 | ``` pascal 17 | 18 | C>HV(H, 10),SPK; 19 | C 策略出处 36 | 37 | https://www.fmz.com/strategy/305745 38 | 39 | > 更新时间 40 | 41 | 2021-08-09 14:01:30 42 | -------------------------------------------------------------------------------- /Nik-Stoch.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Nik-Stoch 5 | 6 | > 策略作者 7 | 8 | 张超 9 | 10 | > 策略描述 11 | 12 | Stochastics Oscillator with settings of 5,3,3 13 | Levels : 15, 85, 30, 70 14 | 15 | **backtest** 16 | ![IMG](https://www.fmz.com/upload/asset/141e589f5b00c84de34.png) 17 | 18 | > 策略参数 19 | 20 | 21 | 22 | |参数|默认值|描述| 23 | |----|----|----| 24 | |v_input_int_1|14|lookback_period| 25 | |v_input_int_2|3|m1| 26 | |v_input_int_3|3|m2| 27 | |v_input_int_4|5|lookback_period1| 28 | |v_input_int_5|3|m3| 29 | |v_input_int_6|3|m4| 30 | 31 | 32 | > 源码 (PineScript) 33 | 34 | ``` javascript 35 | /*backtest 36 | start: 2022-04-09 00:00:00 37 | end: 2022-05-08 23:59:00 38 | period: 1h 39 | basePeriod: 15m 40 | exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] 41 | */ 42 | 43 | //@version=5 44 | indicator('Nik Stoch') 45 | lookback_period = input.int(14, minval=1) 46 | m1 = input.int(3, minval=1) 47 | m2 = input.int(3, minval=1) 48 | 49 | k = ta.sma(ta.stoch(close, high, low, lookback_period), m1) 50 | d = ta.sma(k, m2) 51 | //plot(k) 52 | //plot(d, color=color.red) 53 | h0 = hline(15) 54 | h1 = hline(85) 55 | h2 = hline(50) 56 | h3 = hline(30) 57 | h4 = hline(70) 58 | 59 | fill(h0, h1, color=color.new(color.purple, 95)) 60 | 61 | /////stoch fast 62 | lookback_period1 = input.int(5, minval=1) 63 | m3 = input.int(3, minval=1) 64 | m4 = input.int(3, minval=1) 65 | 66 | k1 = ta.sma(ta.stoch(close, high, low, lookback_period1), m3) 67 | d1 = ta.sma(k1, m4) 68 | plot(k1, color=color.new(color.aqua, 0)) 69 | plot(d1, color=color.new(color.red, 0)) 70 | 71 | 72 | if k1[1] < d1[1] and k1 > d1 73 | strategy.entry("Enter Short", strategy.short) 74 | else if k1[1] > d1[1] and k1 < d1 75 | strategy.entry("Enter Long", strategy.long) 76 | 77 | ``` 78 | 79 | > 策略出处 80 | 81 | https://www.fmz.com/strategy/362172 82 | 83 | > 更新时间 84 | 85 | 2022-05-10 14:08:03 86 | -------------------------------------------------------------------------------- /OK确认无法提币交易对.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | OK确认无法提币交易对 5 | 6 | > 策略作者 7 | 8 | daniaoren 9 | 10 | > 策略描述 11 | 12 | 自用的,简单列出所有目前OKEX无法提现的币,有时候挺有用的,需要自取 13 | 14 | 15 | 16 | > 源码 (javascript) 17 | 18 | ``` javascript 19 | function main() { 20 | var results = exchange.IO("api", "GET", "/api/account/v3/currencies", "" , ""); 21 | var blacklist = [] 22 | i = 0; 23 | var statusMsg = ''; 24 | while (true) 25 | { 26 | if (results[i]["can_withdraw"] == "0"){ 27 | Log(results[i]["currency"],"|",results[i]["name"], results[i]["can_deposit"]); 28 | statusMsg += results[i]["currency"] + " | " + results[i]["name"] + ' ' + results[i]["can_deposit"] + '\n'; 29 | blacklist.push(results[i]); 30 | } 31 | i++; 32 | if (i >= results.length){ 33 | break; 34 | } 35 | } 36 | Log(blacklist.length); 37 | statusMsg = blacklist.length + '\n' + statusMsg; 38 | LogStatus(statusMsg); 39 | return blacklist; 40 | 41 | } 42 | ``` 43 | 44 | > 策略出处 45 | 46 | https://www.fmz.com/strategy/253278 47 | 48 | > 更新时间 49 | 50 | 2021-02-10 15:29:08 51 | -------------------------------------------------------------------------------- /Push-Binance-deal-order-to-WeChat实时推送币安成交到微信wss协议练习.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Push-Binance-deal-order-to-WeChat实时推送币安成交到微信wss协议练习 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | 通过websocket协议,将币安成交信息推送到微信,可以作为wss协议的练习。 13 | 具体原理是30分钟更新一次listenKey,然后订阅账户订阅的datastream。 14 | 15 | > 策略参数 16 | 17 | 18 | 19 | |参数|默认值|描述| 20 | |----|----|----| 21 | |APIKEY||your binance API Key| 22 | 23 | 24 | > 源码 (javascript) 25 | 26 | ``` javascript 27 | function main() { 28 | var listenKey = JSON.parse(HttpQuery('https://api.binance.com/api/v1/userDataStream','',null,'X-MBX-APIKEY:'+APIKEY)).listenKey; 29 | HttpQuery('https://api.binance.com/api/v1/userDataStream', {method:'DELETE',data:'listenKey='+listenKey}, null,'X-MBX-APIKEY:'+ APIKEY); 30 | listenKey = JSON.parse(HttpQuery('https://api.binance.com/api/v1/userDataStream','',null,'X-MBX-APIKEY:'+ APIKEY)).listenKey; 31 | var datastream = Dial("wss://stream.binance.com:9443/ws/"+listenKey, 100); 32 | var update_listenKey_time = Date.now()/1000; 33 | while (true){ 34 | if (Date.now()/1000 - update_listenKey_time > 1800){ 35 | update_listenKey_time = Date.now()/1000; 36 | HttpQuery('https://api.binance.com/api/v1/userDataStream', {method:'PUT',data:'listenKey='+listenKey}, null,'X-MBX-APIKEY:'+ APIKEY); 37 | Log('keep listenKey alive'); 38 | } 39 | var data = datastream.read(); 40 | if(data){ 41 | data = JSON.parse(data); 42 | if(data.e == 'executionReport' && data.x == 'TRADE'){ 43 | Log(data.S, data.s, 'amount is ', data.l, 'at price:', data.p, '@'); 44 | } 45 | } 46 | } 47 | } 48 | ``` 49 | 50 | > 策略出处 51 | 52 | https://www.fmz.com/strategy/122649 53 | 54 | > 更新时间 55 | 56 | 2019-07-03 16:27:05 57 | -------------------------------------------------------------------------------- /Python-KLineChart.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Python-KLineChart 5 | 6 | > 策略作者 7 | 8 | 发明者量化 9 | 10 | > 策略描述 11 | 12 | 平台(Javascript/Python语言)开通KLineChart支持, 支持Pine语言全部画图功能(参数保持一致), 支持自定义买卖信号 13 | 下面是一个演示的例子 14 | 15 | 参考文档 https://www.fmz.com/api#klinechart 16 | 17 | 18 | ![IMG](https://www.fmz.com/upload/asset/bb180d6a028bcc6993.png) 19 | 20 | 21 | 22 | 23 | 24 | > 源码 (python) 25 | 26 | ``` python 27 | '''backtest 28 | start: 2022-03-30 09:00:00 29 | end: 2022-06-30 15:00:00 30 | period: 1h 31 | basePeriod: 15m 32 | exchanges: [{"eid":"Binance","currency":"BTC_USDT"}] 33 | ''' 34 | 35 | 36 | import sys 37 | def main(): 38 | Log(sys.version) 39 | c = KLineChart() 40 | c.reset(0) 41 | 42 | bars = exchange.GetRecords() 43 | for bar in bars: 44 | c.begin(bar) 45 | c.barcolor('rgba(255, 0, 0, 0.2)' if bar.Close > bar.Open else 'rgba(0, 0, 0, 0.2)') 46 | if bar.Close > bar.Open: 47 | c.bgcolor('rgba(0, 255, 0, 0.5)') 48 | 49 | h = c.plot(bar.High, 'high') 50 | l = c.plot(bar.Low, 'low') 51 | c.fill(h, l, 'rgba(255, 0, 0, 1)' if bar.Close > bar.Open else '#000000') 52 | c.hline(bar.High) 53 | c.plotarrow(bar.Close - bar.Open) 54 | c.plotshape(bar.Low, style = 'diamond') 55 | c.plotchar(bar.Close, char = 'X') 56 | c.plotcandle(bar.Open*0.9, bar.High*0.9, bar.Low*0.9, bar.Close*0.9) 57 | if bar.Close > bar.Open: 58 | c.signal("long", bar.High, 1.5, "LONG") 59 | elif bar.Close < bar.Open: 60 | c.signal("closelong", bar.Low, 1.5) 61 | c.close() 62 | ``` 63 | 64 | > 策略出处 65 | 66 | https://www.fmz.com/strategy/371600 67 | 68 | > 更新时间 69 | 70 | 2022-07-01 17:57:42 71 | -------------------------------------------------------------------------------- /Python版追涨杀跌策略教学.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Python版追涨杀跌策略教学 5 | 6 | > 策略作者 7 | 8 | 小小梦 9 | 10 | > 策略描述 11 | 12 | https://www.fmz.com/bbs-topic/4908 13 | 14 | 15 | 16 | > 源码 (python) 17 | 18 | ``` python 19 | '''backtest 20 | start: 2019-02-20 00:00:00 21 | end: 2020-01-10 00:00:00 22 | period: 1m 23 | exchanges: [{"eid":"OKEX","currency":"BTC_USDT"}] 24 | ''' 25 | 26 | import time 27 | 28 | basePrice = -1 29 | ratio = 0.05 30 | acc = _C(exchange.GetAccount) 31 | lastCancelAll = 0 32 | minStocks = 0.01 33 | 34 | def CancelAll(): 35 | while True : 36 | orders = _C(exchange.GetOrders) 37 | for i in range(len(orders)) : 38 | exchange.CancelOrder(orders[i]["Id"], orders[i]) 39 | if len(orders) == 0 : 40 | break 41 | Sleep(1000) 42 | 43 | def main(): 44 | global basePrice, acc, lastCancelAll 45 | exchange.SetPrecision(2, 3) 46 | while True: 47 | ticker = _C(exchange.GetTicker) 48 | if basePrice == -1 : 49 | basePrice = ticker.Last 50 | if ticker.Last - basePrice > 0 and (ticker.Last - basePrice) / basePrice > ratio : 51 | acc = _C(exchange.GetAccount) 52 | if acc.Balance * ratio / ticker.Last > minStocks : 53 | exchange.Buy(ticker.Last, acc.Balance * ratio / ticker.Last) 54 | basePrice = ticker.Last 55 | if ticker.Last - basePrice < 0 and (basePrice - ticker.Last) / basePrice > ratio : 56 | acc = _C(exchange.GetAccount) 57 | if acc.Stocks * ratio > minStocks : 58 | exchange.Sell(ticker.Last, acc.Stocks * ratio) 59 | basePrice = ticker.Last 60 | ts = time.time() 61 | if ts - lastCancelAll > 60 * 5 : 62 | CancelAll() 63 | lastCancelAll = ts 64 | LogStatus(_D(), "\n", "行情信息:", ticker, "\n", "账户信息:", acc) 65 | Sleep(500) 66 | ``` 67 | 68 | > 策略出处 69 | 70 | https://www.fmz.com/strategy/181185 71 | 72 | > 更新时间 73 | 74 | 2020-01-11 15:15:01 75 | -------------------------------------------------------------------------------- /RAVI-FX-Fisher.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | RAVI-FX-Fisher 5 | 6 | > 策略作者 7 | 8 | 张超 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |v_input_source_1_close|0|(?Basic Settings)Source: close|high|low|open|hl2|hlc3|hlcc4|ohlc4| 19 | |v_input_int_1|4|Fast MA Length| 20 | |v_input_int_2|49|Slow MA Length| 21 | |v_input_float_1|0.07|Trigger| 22 | |v_input_bool_1|false|(?UI Options)Color bars?| 23 | 24 | 25 | > 源码 (PineScript) 26 | 27 | ``` javascript 28 | /*backtest 29 | start: 2021-06-15 00:00:00 30 | end: 2022-06-14 23:59:00 31 | period: 1d 32 | basePeriod: 1h 33 | exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] 34 | */ 35 | 36 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 37 | // © loxx 38 | 39 | //@version=5 40 | indicator("RAVI FX Fisher [Loxx]", shorttitle="RAVIFXF [Loxx]", timeframe="", overlay = false, timeframe_gaps=true, max_bars_back = 3000) 41 | 42 | greencolor = #2DD204 43 | redcolor = #D2042D 44 | 45 | src = input.source(close, "Source", group = "Basic Settings") 46 | maf = input.int(4, "Fast MA Length", minval = 1, group = "Basic Settings") 47 | mas = input.int(49, "Slow MA Length", minval = 1, group = "Basic Settings") 48 | trigger = input.float(0.07, "Trigger", minval = 0, group = "Basic Settings") 49 | 50 | colorbars = input.bool(false, "Color bars?", group = "UI Options") 51 | 52 | maval = (ta.wma(src, maf) - ta.wma(src, mas)) * ta.atr(maf) / ta.wma(src, mas) / ta.atr(mas) 53 | maval := 100 * maval 54 | fish = (math.exp(2 * maval) - 1) / (math.exp(2 * maval) + 1) 55 | 56 | plot(fish,color = fish >=0 ? greencolor : redcolor, style = plot.style_histogram, linewidth = 2) 57 | 58 | plot(trigger, color = color.white, linewidth = 1 ) 59 | plot(-trigger, color = color.white, linewidth = 1 ) 60 | 61 | barcolor(colorbars ? fish >=0 ? greencolor : redcolor : na) 62 | 63 | if fish >=0 64 | strategy.entry("Enter Long", strategy.long) 65 | else 66 | strategy.entry("Enter Short", strategy.short) 67 | ``` 68 | 69 | > 策略出处 70 | 71 | https://www.fmz.com/strategy/369392 72 | 73 | > 更新时间 74 | 75 | 2022-06-16 15:15:28 76 | -------------------------------------------------------------------------------- /Renko-Reversal-Alert.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Renko-Reversal-Alert 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (PineScript) 15 | 16 | ``` javascript 17 | /*backtest 18 | start: 2021-05-08 00:00:00 19 | end: 2022-05-07 23:59:00 20 | period: 4h 21 | basePeriod: 15m 22 | exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] 23 | */ 24 | //@version=2 25 | study("Renko Reversal alert", overlay=true) 26 | //Buy entry if a bearish renko brick is followed by a bullish brick 27 | //Sell entry if a bullish brick is followed by a bearish brick 28 | long = close > open[1] and close[1] < open[2] 29 | short = close < open[1] and close[1] > open[2] 30 | 31 | //Use these alerts to create server-side alerts (right-click on one of the buy or sell arrows on the chart and choose "add alert") 32 | alertcondition(long, title='Long opportunity', message='Renko reversal') 33 | alertcondition(short, title='Short opportunity', message='Renko reversal') 34 | 35 | //Use this to customize the look of the arrows to suit your needs. 36 | plotshape(long, location=location.belowbar, color=lime, style=shape.arrowup, text="Buy") 37 | plotshape(short, location=location.abovebar, color=red, style=shape.arrowdown, text="Sell") 38 | if long 39 | strategy.entry("buy", strategy.long) 40 | else if short 41 | strategy.entry("sell", strategy.short) 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | ``` 64 | 65 | > 策略出处 66 | 67 | https://www.fmz.com/strategy/368749 68 | 69 | > 更新时间 70 | 71 | 2022-06-12 18:32:42 72 | -------------------------------------------------------------------------------- /SMA-pine语言教学策略脚本.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | SMA-pine语言教学策略脚本 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (PineScript) 15 | 16 | ``` javascript 17 | 18 | //@version=4 19 | study("SMA Cross", overlay=true) 20 | //strategy("strategy.percent_of_equity", overlay = false, default_qty_value = 100, default_qty_type = strategy.percent_of_equity, initial_capital = 1000000) 21 | 22 | //SMA 23 | fastSMA = sma(close, 10) 24 | slowSMA = sma(close, 200) 25 | 26 | //Buy 27 | longCondition = crossover(fastSMA, slowSMA) 28 | longStop = strategy.position_avg_price * 0.95 29 | longEntry = strategy.position_avg_price * 1.05 30 | 31 | //Sell 32 | shortCondition = crossunder(fastSMA, slowSMA) 33 | shortStop = strategy.position_avg_price * 1.05 34 | shortEntry = strategy.position_avg_price * 0.95 35 | 36 | //Alert 37 | alertcondition(longCondition, title="SMA Cross", message="Buy Signal") 38 | alertcondition(shortCondition, title="SMA Cross", message="Sell Signal") 39 | 40 | //Plot 41 | plotshape(longCondition, style=shape.triangleup, location=location.belowbar, color=color.green, text="Buy") 42 | plotshape(shortCondition, style=shape.triangledown, location=location.abovebar, color=color.red, text="Sell") 43 | 44 | //Strategy 45 | strategy.entry("Long", strategy.long, when=longCondition) 46 | strategy.entry("Short", strategy.short, when=shortCondition) 47 | // StopLoss/Takeprofit 48 | if (strategy.position_size > 0) 49 | strategy.exit("stoploss/takeprofit","Long",stop=longStop, limit=longEntry) 50 | if (strategy.position_size < 0) 51 | strategy.exit("stoploss/takeprofit","Short", stop=shortStop, limit=shortEntry) 52 | ``` 53 | 54 | > 策略出处 55 | 56 | https://www.fmz.com/strategy/400134 57 | 58 | > 更新时间 59 | 60 | 2023-02-15 18:19:03 61 | -------------------------------------------------------------------------------- /Shannons-Demon.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Shannons-Demon 5 | 6 | > 策略作者 7 | 8 | FawkesPan 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |DELAY|30|平衡间隔| 19 | |DS|1.04|Sell| 20 | |DB|1.08|Buy| 21 | |RSIB|80|RSI Buy| 22 | |RSIS|20|RSI Sell| 23 | 24 | 25 | > 源码 (javascript) 26 | 27 | ``` javascript 28 | /* 29 | 30 | Shannon's Demon Demo Code 31 | 32 | Copyright 2018 FawkesPan 33 | Contact : i@fawkex.me / Telegram@FawkesPan 34 | 35 | Do What the Fuck You Want To Public License 36 | 37 | */ 38 | 39 | 40 | function onTick(){ 41 | var Account = exchange.GetAccount(); 42 | var Depth = exchange.GetDepth(); 43 | var Buy = Depth.Asks[1].Price; 44 | var Sell = Depth.Bids[1].Price; 45 | var StockValue = Account.Stocks * Buy; 46 | var TotalValue = Account.Balance + StockValue; 47 | var Half = TotalValue / 2; 48 | var Records = exchange.GetRecords(PERIOD_M1); 49 | var RSI = TA.RSI(Records, 14); 50 | //Log("StockValue:", StockValue ," TotalValue:", TotalValue); 51 | var LastRSI = RSI[RSI.length -1]; 52 | //Log(LastRSI); 53 | if (StockValue / Half > DS && LastRSI > RSIS) { 54 | Log("StockValue:", StockValue ," TotalValue:", TotalValue); 55 | Log("StockValue Too High. Re Balancing..."); 56 | var ToBeSold = (Account.Stocks * Buy - Account.Balance) / 2 / Buy; 57 | Log(exchange.Sell(Buy,ToBeSold)); 58 | Sleep(DELAY*1000*5); 59 | } 60 | if (Half / StockValue > DB && LastRSI < RSIB) { 61 | Log("StockValue:", StockValue ," TotalValue:", TotalValue); 62 | Log("StockValue Too Low. Re Balancing..."); 63 | var ToBeBought = (Account.Balance - Account.Stocks * Buy) / 2 / Sell; 64 | Log(exchange.Buy(Sell,ToBeBought)); 65 | Sleep(DELAY*1000*5); 66 | } 67 | } 68 | function main(){ 69 | while(true){ 70 | onTick(); 71 | Sleep(DELAY*1000); 72 | } 73 | } 74 | ``` 75 | 76 | > 策略出处 77 | 78 | https://www.fmz.com/strategy/64455 79 | 80 | > 更新时间 81 | 82 | 2018-08-30 03:04:37 83 | -------------------------------------------------------------------------------- /Simple-Buy-Sell-Signals.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Simple-Buy-Sell-Signals 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (PineScript) 15 | 16 | ``` javascript 17 | /*backtest 18 | start: 2021-05-08 00:00:00 19 | end: 2022-05-07 23:59:00 20 | period: 4h 21 | basePeriod: 15m 22 | exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] 23 | */ 24 | // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ 25 | // © mayurssupe 26 | 27 | //@version=5 28 | indicator("Simple Buy Sell Signals",overlay=true,format=format.price,shorttitle="SBS") 29 | 30 | [dp,dm,adx] =ta.dmi(14,14) 31 | 32 | rsi = ta.rsi(close,9) 33 | rsiOB = rsi > 60 and not(rsi[1] < 40) 34 | rsiOS = rsi < 40 and not(rsi[1] > 60) 35 | 36 | ma1 = math.avg(ta.sma(close,21),ta.ema(close,50)) 37 | ma2 = ta.ema(close,35) 38 | 39 | nmL = ta.crossover(ma1,ma2) and rsiOB 40 | nmS = ta.crossover(ma1,ma2) and rsiOS 41 | 42 | plotshape(nmL ? nmL : 0,title="Long",style=shape.labelup,text="Buy",textcolor=color.white,color=color.aqua,location=location.belowbar) 43 | plotshape(nmS ? nmS : 0,title="Short",style=shape.labeldown,text="Sell",textcolor=color.white,color=color.orange,location=location.abovebar) 44 | 45 | // plot(ma1,color=color.green,linewidth=4) 46 | // plot(ma2,color=color.red,linewidth=4) 47 | 48 | //Strategy Tester 49 | if nmL 50 | strategy.entry("Enter Long", strategy.long) 51 | else if nmS 52 | strategy.entry("Enter Short", strategy.short) 53 | // strategy.close("Long",when=nmS) 54 | // strategy.close("Short",when=nmL) 55 | ``` 56 | 57 | > 策略出处 58 | 59 | https://www.fmz.com/strategy/380396 60 | 61 | > 更新时间 62 | 63 | 2022-08-28 18:30:25 64 | -------------------------------------------------------------------------------- /T-Step-LSMA.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | T-Step-LSMA 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |v_input_1|100|length| 19 | |v_input_2|0.5|sc| 20 | |v_input_3|false|No Smoothing| 21 | 22 | 23 | > 源码 (PineScript) 24 | 25 | ``` javascript 26 | /*backtest 27 | start: 2021-05-08 00:00:00 28 | end: 2022-05-07 23:59:00 29 | period: 4h 30 | basePeriod: 15m 31 | exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] 32 | */ 33 | //@version=4 34 | study("T-Step LSMA",overlay=true) 35 | length = input(100),sc = input(.5),ns = input(false,"No Smoothing") 36 | //---- 37 | b = 0.,ls = 0. 38 | src = sc*close+(1-sc)*nz(ls[1],close) 39 | //---- 40 | er = 1 - abs(change(src,length))/sum(abs(change(src)),length) 41 | n = cum(1)-1 42 | a = cum(abs(src - nz(b[1],src)))/n*(1+er) 43 | b := src > nz(b[1],src) + a ? src : src < nz(b[1],src) - a ? src : nz(b[1],src) 44 | //---- 45 | alpha = fixnan(correlation(src,b,length) * (stdev(src,length)/stdev(b,length))) 46 | beta = sma(src,length) - alpha*sma(b,length) 47 | ls := alpha*b+beta 48 | //---- 49 | osc = 0 50 | osc := b > b[1] ? 1 : b < b[1] ? 0 : osc[1] 51 | css = osc == 1 ? color.blue :#e65100 52 | plot(ns ? b : fixnan(ls),color=css,linewidth=3,transp=0) 53 | alertcondition(change(osc)>0,title="Up",message="Up-trending Market Estimated") 54 | alertcondition(change(osc)<0,title="Dn",message="Down-trending Market Estimated") 55 | buySignal = change(osc)>0 56 | sellSignal= change(osc)<0 57 | if buySignal 58 | strategy.entry("buy", strategy.long) 59 | else if sellSignal 60 | strategy.entry("sell", strategy.short) 61 | ``` 62 | 63 | > 策略出处 64 | 65 | https://www.fmz.com/strategy/370711 66 | 67 | > 更新时间 68 | 69 | 2022-06-25 16:26:42 70 | -------------------------------------------------------------------------------- /TypeScript-演示.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | TypeScript-演示 5 | 6 | > 策略作者 7 | 8 | 发明者量化 9 | 10 | > 策略描述 11 | 12 | 平台加入原生TypeScript支持, 只需要在源码开头加入 (策略语言类型还是先JavaScript) 13 | 14 | ``` 15 | // @ts-check 16 | ``` 17 | 18 | 就可以自动识别为TypeScript 19 | 20 | 21 | 22 | 23 | > 源码 (javascript) 24 | 25 | ``` javascript 26 | // @ts-check 27 | 28 | class Greeter { 29 | greeting: string; 30 | 31 | constructor(message: string) { 32 | this.greeting = message; 33 | } 34 | 35 | greet() { 36 | return "Hello, " + this.greeting; 37 | } 38 | } 39 | 40 | 41 | function peopleName(firstName: string, ...restOfname: string[]) { 42 | return firstName + " " + restOfname.join(" "); 43 | } 44 | 45 | 46 | function main() { 47 | let greeter = new Greeter("world"); 48 | Log(greeter.greet()); 49 | 50 | 51 | Log(peopleName('xiaochuan', 'xiaoming', 'xiaohong')) 52 | } 53 | 54 | 55 | ``` 56 | 57 | > 策略出处 58 | 59 | https://www.fmz.com/strategy/405326 60 | 61 | > 更新时间 62 | 63 | 2023-03-23 16:09:47 64 | -------------------------------------------------------------------------------- /Utility-Ticker.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | Utility-Ticker 5 | 6 | > 策略作者 7 | 8 | btcvegas 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (javascript) 15 | 16 | ``` javascript 17 | 18 | 19 | function getPrice(exchange, pair){ 20 | 21 | var result = null 22 | 23 | if (exchange == 'polygon'){ 24 | ret = HttpQuery("https://api.polygon.io/v1/last_quote/currencies/USD/BRL?&apiKey=csjY6ZuXAO41EZlGzTCPGJH_7YgkXwrB") 25 | Log("Polygon", ret) 26 | if (ret){ 27 | parsed = JSON.parse(ret) 28 | Log("Parse", parsed) 29 | result = { 30 | Buy: parsed.last.bid, 31 | Sell: parsed.last.ask 32 | } 33 | } 34 | } 35 | else if (exchange.GetLabel() == "BitcoinTrade"){ 36 | depth = $.Bitcointrade_GetDepth(pair) 37 | if (depth){ 38 | result = { 39 | Buy: depth.Bids[0].Price, 40 | Sell: depth.Asks[0].Price 41 | } 42 | } 43 | else result = null 44 | } 45 | else { 46 | exchange.SetContractType(pair) 47 | result = exchange.GetTicker() 48 | _G(exchange.GetName()+pair, result) 49 | } 50 | 51 | Log("get price", pair, result) 52 | return result 53 | } 54 | 55 | $.updateTicker = function (exchange1, exchange2, contract1, contract2, graph, loc, conversionPrice, chart, timestamp){ 56 | exchangeTicker1 = getPrice(exchange1, contract1) 57 | exchangeTicker2 = getPrice(exchange2, contract2) 58 | 59 | var spread = _N((((exchangeTicker2.Sell / conversionPrice) / exchangeTicker1.Buy) - 1) * 100, 2) 60 | 61 | Log(graph.title.text, contract1, contract2, spread, conversionPrice) 62 | 63 | graph.subtitle = { 64 | text: 'Spread: ' + spread, 65 | }; 66 | 67 | if (spread < 50 && spread > -50){ 68 | chart.add([loc, [timestamp, spread]]); 69 | } 70 | Sleep(2000) 71 | 72 | return exchangeTicker1.Buy 73 | 74 | } 75 | ``` 76 | 77 | > 策略出处 78 | 79 | https://www.fmz.com/strategy/268995 80 | 81 | > 更新时间 82 | 83 | 2021-07-07 23:23:50 84 | -------------------------------------------------------------------------------- /boll傻瓜版.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | boll傻瓜版 5 | 6 | > 策略作者 7 | 8 | sabar 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (javascript) 15 | 16 | ``` javascript 17 | function main (){ 18 | $.CTA("BTC_USDT", function(st){ 19 | var r = st.records; //获取K线数组 20 | if (r.Length <20) return; // 过滤K线长度 21 | var close = r[r.length - 2].close; //获取上根K线收盘价 22 | var mp = st. positLon.amount; //获取持仓信息 23 | 24 | var boll = TA.BOLL(r, 20, 2); // 计算布林带指标 25 | var upLine = boll[0]; 26 | //获取上轨数组 27 | var midLine = boll[1]; //获取中轨数组 28 | var downLine = boll[2];//获取下轨数组 29 | var upPrice = upLine [upLine.length -2]; 30 | //获取上根K线的上轨数组 31 | var midPrice = midLine[midLine.length -2]; 32 | //获取上根K线的中轨数姐 33 | var downPrice = downLine[ downLine.length -2]; 34 | //获取上根K线的下轨数组 35 | if(mp == 1 && (close < midPrice)) return -1; //如果持多单,并且收盘价小于中轨。平多 36 | if (mp == -1 && (close > midPrice)) return 1; //如果持空单, 并且收盘价大于中轨。 平空 37 | if (mp == 0 && close > midPrice) return 1; //如果无持仓,井且收盘价大于上轨。 开多 38 | if (mp == 0 && close < midPrice) return -1; //如果无持仓, 并且收盘价小于 下轨。 开空 39 | }); 40 | } 41 | ``` 42 | 43 | > 策略出处 44 | 45 | https://www.fmz.com/strategy/318249 46 | 47 | > 更新时间 48 | 49 | 2021-09-23 09:43:52 50 | -------------------------------------------------------------------------------- /coingecko_crawler.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | coingecko_crawler 5 | 6 | > 策略作者 7 | 8 | linsilence 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |isDebug|false|debug| 19 | 20 | 21 | > 源码 (javascript) 22 | 23 | ``` javascript 24 | 25 | 26 | const URL_API = 'https://api.coingecko.com/api/v3/coins/markets'; 27 | 28 | $.Grab_Symbols_Marketcap = function (count) { 29 | const param = `vs_currency=usd&order=market_cap_desc&per_page=${count}&page=1&sparkline=false`; 30 | const ret = JSON.parse(HttpQuery(URL_API + '?' + param)); 31 | if (isDebug) Log('grab_marketcap 1 ret: ', ret); 32 | 33 | let symbos = []; 34 | ret.forEach(e => { 35 | symbos.push(e.symbol.toUpperCase()); 36 | }); 37 | if (isDebug) Log('grab_marketcap 2 ret: ', symbos); 38 | return symbos; 39 | }; 40 | 41 | function main() { 42 | const s = $.Grab_Symbols_Marketcap(4); 43 | Log(s); 44 | } 45 | ``` 46 | 47 | > 策略出处 48 | 49 | https://www.fmz.com/strategy/279269 50 | 51 | > 更新时间 52 | 53 | 2021-05-08 20:58:24 54 | -------------------------------------------------------------------------------- /derbit-期权回测测试.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | derbit-期权回测测试 5 | 6 | > 策略作者 7 | 8 | 发明者量化 9 | 10 | > 策略描述 11 | 12 | - 模拟derbit的期权买卖逻辑 13 | - 支持买入卖入期权 14 | - 因为行权需要与期货价格结合,暂不支持行权,实盘可通过IO接口进行行权 15 | 16 | 17 | 18 | > 源码 (javascript) 19 | 20 | ``` javascript 21 | /*backtest 22 | start: 2020-06-08 00:00:00 23 | end: 2020-08-05 00:00:00 24 | period: 1h 25 | basePeriod: 1h 26 | exchanges: [{"eid":"Futures_Deribit","currency":"BTC_USD"}] 27 | */ 28 | 29 | function main() { 30 | exchange.SetContractType('BTC-7AUG20-12750-C'); 31 | var ticker = exchange.GetTicker(); 32 | Log(ticker); 33 | exchange.SetDirection("sell"); 34 | var orderId = exchange.Sell(ticker.Sell, 10); 35 | Log(exchange.GetAccount()); 36 | Log(exchange.GetOrders()); 37 | exchange.CancelOrder(orderId); 38 | Log(exchange.GetAccount()); 39 | 40 | 41 | exchange.Sell(ticker.Buy, 10); 42 | Log(exchange.GetAccount()); 43 | Log(exchange.GetPosition()); 44 | ticker = exchange.GetTicker(); 45 | exchange.SetDirection("closesell"); 46 | exchange.Buy(ticker.Sell, 10); 47 | Log(exchange.GetAccount()); 48 | Log(exchange.GetPosition()); 49 | 50 | 51 | 52 | ticker = exchange.GetTicker(); 53 | Log(ticker); 54 | exchange.SetDirection("buy"); 55 | orderId = exchange.Buy(ticker.Buy, 10); 56 | Log(exchange.GetAccount()); 57 | exchange.CancelOrder(orderId); 58 | Log(exchange.GetAccount()); 59 | 60 | 61 | exchange.Buy(ticker.Sell, 10); 62 | Log(exchange.GetAccount()); 63 | Log(exchange.GetPosition()); 64 | ticker = exchange.GetTicker(); 65 | exchange.SetDirection("closebuy"); 66 | exchange.Sell(ticker.Buy, 10); 67 | Log(exchange.GetAccount()); 68 | Log(exchange.GetPosition()); 69 | } 70 | ``` 71 | 72 | > 策略出处 73 | 74 | https://www.fmz.com/strategy/222436 75 | 76 | > 更新时间 77 | 78 | 2020-08-07 15:31:28 79 | -------------------------------------------------------------------------------- /grid.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | grid 5 | 6 | > 策略作者 7 | 8 | CYZWX 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | last_tick = [] 18 | line = [] 19 | grid_buy_list = [] 20 | 21 | def net(now_price): 22 | global line 23 | print(now_price) 24 | line = [now_price*(1+0.003*i) for i in range(-1000,1000)] 25 | Log(line) 26 | 27 | def ontick(): 28 | global last_tick 29 | global line 30 | global grid_buy_list 31 | account = exchange.GetAccount() 32 | ticker = exchange.GetTicker() 33 | last_tick.append(ticker['Last']) 34 | if len(last_tick) == 1:return 35 | elif len(last_tick) == 100:del last_tick[0] 36 | for i in range(len(line)): 37 | if last_tick[-1] > line[i] and last_tick[-2] < line[i] and len(grid_buy_list)!= 0 and i > min(grid_buy_list) and account['Stocks'] >= 0.001: 38 | exchange.Sell(last_tick[-1],0.01) 39 | del grid_buy_list[grid_buy_list.index(min(grid_buy_list))] 40 | Log(exchange.GetAccount()) 41 | elif last_tick[-1] < line[i] and last_tick[-2] > line[i] and i not in grid_buy_list: 42 | exchange.Buy(last_tick[-1],0.01) 43 | grid_buy_list.append(i) 44 | Log(exchange.GetAccount()) 45 | 46 | def main(): 47 | net(exchange.GetTicker()['Last']) 48 | Log(exchange.GetAccount()) 49 | while(True): 50 | ontick() 51 | Sleep(1000) 52 | 53 | ``` 54 | 55 | > 策略出处 56 | 57 | https://www.fmz.com/strategy/291160 58 | 59 | > 更新时间 60 | 61 | 2021-06-17 02:43:52 62 | -------------------------------------------------------------------------------- /pine语言学习脚本.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | pine语言学习脚本 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |v_input_1|10|Fast Length| 19 | |v_input_2|20|Slow Length| 20 | 21 | 22 | > 源码 (PineScript) 23 | 24 | ``` javascript 25 | //@version=4 26 | study("SMA Trend Strategy") 27 | 28 | // 设置参数 29 | fastLength = input(title="Fast Length", type=input.integer, defval=10) 30 | slowLength = input(title="Slow Length", type=input.integer, defval=20) 31 | 32 | // 计算指标 33 | fastSMA = sma(close, fastLength) 34 | slowSMA = sma(close, slowLength) 35 | 36 | // 设置止盈止损 37 | longStop = strategy.position_avg_price * (1 - 0.01) 38 | shortStop = strategy.position_avg_price * (1 + 0.01) 39 | longlimit = strategy.position_avg_price * (1 + 0.01) 40 | shortlimit = strategy.position_avg_price * (1 - 0.01) 41 | 42 | // 开仓条件 43 | longCondition = crossover(fastSMA, slowSMA) 44 | shortCondition = crossunder(fastSMA, slowSMA) 45 | 46 | // 开仓 47 | strategy.entry("Long", strategy.long, when=longCondition) 48 | strategy.entry("Short", strategy.short, when=shortCondition) 49 | 50 | // 止盈止损 51 | strategy.exit("Long Stop", "Long", stop=longStop,limit=longlimit) 52 | strategy.exit("Short Stop", "Short", stop=shortStop,limit=shortlimit) 53 | 54 | ``` 55 | 56 | > 策略出处 57 | 58 | https://www.fmz.com/strategy/395433 59 | 60 | > 更新时间 61 | 62 | 2023-01-28 14:58:19 63 | -------------------------------------------------------------------------------- /python-状态栏表格-显示按钮范例.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | python-状态栏表格-显示按钮范例 5 | 6 | > 策略作者 7 | 8 | 小小梦 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | import json 18 | 19 | def main(): 20 | tab = { 21 | "type" : "table", 22 | "title" : "demo", 23 | "cols" : ["a", "b", "c"], 24 | "rows" : [["1", "2", {"type" : "button", "cmd" : "coverAll", "name" : "平仓"}]] # 在状态栏表格 第一行,第三列上配置一个按钮 名字是平仓 25 | } 26 | 27 | LogStatus("`" + json.dumps(tab) + "`") 28 | 29 | ``` 30 | 31 | > 策略出处 32 | 33 | https://www.fmz.com/strategy/147155 34 | 35 | > 更新时间 36 | 37 | 2019-05-10 11:35:13 38 | -------------------------------------------------------------------------------- /talib简单应用之查找三只乌鸦.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | talib简单应用之查找三只乌鸦 5 | 6 | > 策略作者 7 | 8 | Zero 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (javascript) 15 | 16 | ``` javascript 17 | /*backtest 18 | start: 2017-12-05 00:00:00 19 | end: 2017-12-06 12:00:00 20 | period: 5m 21 | exchanges: [{"eid":"OKCoin_EN","currency":"BTC"}] 22 | */ 23 | 24 | function main() { 25 | while (true) { 26 | var r = exchange.GetRecords(); 27 | var pos = _.indexOf(talib.CDL3BLACKCROWS(r), -100); 28 | // 找到三只乌鸦的形态而且是在当前最后一个K线形成的 29 | if (pos != -1 && pos == r.length - 1) { 30 | Log("K线索引:", pos, r.length, "时间:", _D(r[pos].Time)); 31 | // 下个卖单, 这们回测图表会有一个买单的标志 32 | exchange.Sell(_C(exchange.GetTicker).Buy, 0.1); 33 | throw "找到三只乌鸦"; 34 | } 35 | Sleep(1000); 36 | } 37 | } 38 | ``` 39 | 40 | > 策略出处 41 | 42 | https://www.fmz.com/strategy/62163 43 | 44 | > 更新时间 45 | 46 | 2018-04-07 11:47:38 47 | -------------------------------------------------------------------------------- /三行代码实现阿尔戈斯机器学习快速解读行业新闻的反指策略.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 三行代码实现阿尔戈斯机器学习快速解读行业新闻的反指策略 5 | 6 | > 策略作者 7 | 8 | Zero 9 | 10 | > 策略描述 11 | 12 | > 阿尔戈斯 13 | 14 | https://www.quantinfo.com/Argus/ 15 | 16 | > 吹牛皮 17 | 18 | 阿尔戈斯 (Argus Ἄργος) 希腊神话中的百眼巨人 19 | 该系统是发明者旗下宽客在线的一个项目, 经过五年研发,全网监控期货、股票、期权、大宗商品、外汇等价格波动及相关资讯 20 | 使用目前科技最前沿的人工智能神经网络,经过上亿次训练 21 | 可实现预测股票有效挂单报价、预测金融资产价格变动、预测标普500指数波动性、优化投资组合、基于新闻头条预测价格波动 22 | 23 | ![IMG](https://www.fmz.com/upload/asset/18bc0cc19ceb00d6bc9.png) 24 | 25 | > 落地 26 | 27 | 虽然牛皮吹的可以,但尴尬的事实证明, 跟这个用了AI技术的阿尔戈斯做反指效果比较好,它预测涨咱就卖,预测跌咱就买 28 | 别人疯狂我恐惧别人恐惧我疯狂, 因为它预测的是大众情绪,想赚钱,得反着来 29 | 30 | > 策略 31 | 32 | 借助于发明者平台强大的语法支持,为了最直观的展示效果,选用了增强版的My语言, 数据源返回的是一个0到1的小数来描述涨的概率, 用户需要要获取其它品种的数据, 修改策略代码URL里的品种名称即可 33 | 34 | > 效果 35 | 36 | ![IMG](https://www.fmz.com/upload/asset/2440e3472cba14cd778.png) 37 | 38 | > 最后 39 | 40 | 如果想要定义自己的第三方数据源, 参考API https://www.fmz.com/api#exchange.getdata 41 | 此策略只做演示如何调用第三方数据源进行回测验证, 请勿实盘!!! 42 | 43 | 44 | 45 | 46 | > 源码 (麦语言) 47 | 48 | ``` pascal 49 | (*backtest 50 | start: 2019-10-01 00:00:00 51 | end: 2020-04-21 23:59:00 52 | period: 1h 53 | basePeriod: 1h 54 | exchanges: [{"eid":"Bitfinex","currency":"BTC_USD"}] 55 | *) 56 | 57 | 预测值:DATA('https://www.quantinfo.com/API/Argus/history?symbol=比特币'); 58 | 预测值>HV(预测值, 5)&&预测值>0.6,SPK; 59 | 预测值 策略出处 63 | 64 | https://www.fmz.com/strategy/201665 65 | 66 | > 更新时间 67 | 68 | 2020-04-23 19:50:41 69 | -------------------------------------------------------------------------------- /交易所上新币第一时间挂单机器人.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 交易所上新币第一时间挂单机器人 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | 会按固定间隔摆出挂单,用于交易所上新币第一时间挂单机器人。由于逻辑简单,未测试 13 | 14 | ## 原理: 15 | 16 | 添加交易对后开始运行,不断产尝试获取行情,如果能获取到行情,说明开始交易,策略会挂单,获取不到说明未开放,继续重试等待。 17 | 18 | > 策略参数 19 | 20 | 21 | 22 | |参数|默认值|描述| 23 | |----|----|----| 24 | |Type|0|下单类型: 买单|卖单| 25 | |Start_Price|7000|开始价格| 26 | |Spread|5|间隔| 27 | |N|5|挂单个数| 28 | |Amount|0.1|每单挂单量| 29 | |Amount_Step|false|挂单递增量| 30 | 31 | 32 | > 源码 (javascript) 33 | 34 | ``` javascript 35 | 36 | function main() { 37 | exchange.SetTimeout(500) //保证较快的返回null,继续重试获取行情 38 | while(true){ 39 | var ticker = exchange.GetTicker() 40 | if(!ticker){ 41 | continue 42 | }else{ 43 | Log('获取到行情,开始下单') 44 | for(var i=0;i 策略出处 60 | 61 | https://www.fmz.com/strategy/194206 62 | 63 | > 更新时间 64 | 65 | 2020-10-16 10:20:29 66 | -------------------------------------------------------------------------------- /交易终端插件范例.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 交易终端插件范例 5 | 6 | > 策略作者 7 | 8 | 小小梦 9 | 10 | > 策略描述 11 | 12 | 用于演示交易终端插件嵌入功能。 13 | https://www.fmz.com/api#%E4%BA%A4%E6%98%93%E6%8F%92%E4%BB%B6 14 | 15 | > 策略参数 16 | 17 | 18 | 19 | |参数|默认值|描述| 20 | |----|----|----| 21 | |TransactionTimes|5|交易次数| 22 | |Amount|0.02|每笔交易币数| 23 | |Side|0|交易方向: 买|卖| 24 | 25 | 26 | > 源码 (javascript) 27 | 28 | ``` javascript 29 | function main() { 30 | var initAcc = _C(exchange.GetAccount) 31 | var tbl = { 32 | "type" : "table", 33 | "title" : "表格", 34 | "cols" : ["项目", "内容"], 35 | "rows" : [], 36 | } 37 | 38 | for (var i = 0 ; i < TransactionTimes ; i++) { 39 | var info = null 40 | if (Side == 0) { 41 | info = $.Buy(Amount) 42 | } else if (Side == 1) { 43 | info = $.Sell(Amount) 44 | } else { 45 | throw "side error!" 46 | } 47 | 48 | tbl.rows.push([i + "号订单,成交情况:", JSON.stringify(info)]) 49 | Sleep(300) 50 | } 51 | 52 | var nowAcc = _C(exchange.GetAccount) 53 | delete initAcc.Info 54 | delete nowAcc.Info 55 | tbl.rows.push(["初始账户:", JSON.stringify(initAcc)]) 56 | tbl.rows.push(["执行后账户:", JSON.stringify(nowAcc)]) 57 | return tbl 58 | } 59 | ``` 60 | 61 | > 策略出处 62 | 63 | https://www.fmz.com/strategy/187708 64 | 65 | > 更新时间 66 | 67 | 2020-03-25 15:19:48 68 | -------------------------------------------------------------------------------- /仓位均衡策略.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 仓位均衡策略 5 | 6 | > 策略作者 7 | 8 | 春哥 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |TARGET_POSITION|0.5|固定仓位| 19 | |ACT_DIFF|0.1|仓位变化量| 20 | 21 | 22 | > 源码 (javascript) 23 | 24 | ``` javascript 25 | function main() { 26 | while (true) { 27 | Sleep(300000); 28 | 29 | var account = $.GetAccount(); 30 | var ticker = exchange.GetTicker(); 31 | var stockValue = account.Stocks * ticker.Last; 32 | var totalValue = stockValue + account.Balance; 33 | var position = stockValue / totalValue; 34 | var trade_amount = 0; 35 | if ( position > TARGET_POSITION + ACT_DIFF ) { 36 | trade_amount = (position - TARGET_POSITION) * totalValue / ticker.Buy; 37 | $.Sell(trade_amount); 38 | } else if ( position < TARGET_POSITION - ACT_DIFF ) { 39 | trade_amount = (TARGET_POSITION - position) * totalValue / ticker.Sell; 40 | $.Buy(trade_amount); 41 | } else { 42 | Sleep(60000); 43 | continue; 44 | } 45 | 46 | $.CancelPendingOrders(); 47 | account = $.GetAccount(); 48 | stockValue = account.Stocks * ticker.Last; 49 | LogProfit(account.Balance + stockValue); 50 | } 51 | } 52 | 53 | ``` 54 | 55 | > 策略出处 56 | 57 | https://www.fmz.com/strategy/54182 58 | 59 | > 更新时间 60 | 61 | 2017-09-06 21:57:31 62 | -------------------------------------------------------------------------------- /代替废弃的GetMinStock函数.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 代替废弃的GetMinStock函数 5 | 6 | > 策略作者 7 | 8 | hugo_zhou 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (javascript) 15 | 16 | ``` javascript 17 | /**************** 18 | 针对 火币pro 获取不同货币对的最小交易量 19 | 其他平台需要自行添加不同的错误解析代码 20 | ****************/ 21 | 22 | function main() { 23 | SetErrorFilter("limit order amount error"); 24 | //加入你想知道的货币对 25 | var huobipro = ["BTC_USDT","XRP_USDT","EOS_BTC","OMG_ETH"]; 26 | 27 | for(var i = 0;i= 0){ 34 | var min = parseFloat(error.split(": `")[1]); 35 | _G(exchange.GetName()+exchange.GetCurrency(),min); 36 | } 37 | } 38 | 39 | //从数据库中打印出来 40 | for(var j = 0;j 策略出处 47 | 48 | https://www.fmz.com/strategy/69436 49 | 50 | > 更新时间 51 | 52 | 2018-01-17 17:42:25 53 | -------------------------------------------------------------------------------- /使用画线类库画K线以及均线图表范例.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 使用画线类库画K线以及均线图表范例 5 | 6 | > 策略作者 7 | 8 | 小小梦 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |MaCyc|10|均线参数| 19 | 20 | 21 | > 源码 (javascript) 22 | 23 | ``` javascript 24 | var PreBarTime = 0 25 | function PlotMA_Kline(records, param, isFirst){ 26 | var ma = TA.MA(records, param) 27 | $.PlotRecords(records, "K") 28 | if(isFirst){ 29 | for(var i = records.length - 1; i >= 0; i--){ 30 | if(ma[i] !== null){ 31 | $.PlotLine("ma", ma[i], records[i].Time) 32 | } 33 | } 34 | PreBarTime = records[records.length - 1].Time 35 | } else { 36 | if(PreBarTime !== records[records.length - 1].Time){ 37 | $.PlotLine("ma", ma[ma.length - 2], records[records.length - 2].Time) 38 | PreBarTime = records[records.length - 1].Time 39 | } 40 | $.PlotLine("ma", ma[ma.length - 1], records[records.length - 1].Time) 41 | } 42 | 43 | 44 | } 45 | 46 | function main(){ 47 | var maCyc = MaCyc 48 | var isFirst = true 49 | 50 | while(1){ 51 | var records = exchange.GetRecords() 52 | if(records && records.length > maCyc){ 53 | PlotMA_Kline(records, maCyc, isFirst) 54 | isFirst = false 55 | } 56 | Sleep(1000) 57 | } 58 | } 59 | ``` 60 | 61 | > 策略出处 62 | 63 | https://www.fmz.com/strategy/125770 64 | 65 | > 更新时间 66 | 67 | 2018-11-12 11:39:09 68 | -------------------------------------------------------------------------------- /入门模板之各个平台余额.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 入门模板之各个平台余额 5 | 6 | > 策略作者 7 | 8 | Zero 9 | 10 | > 策略描述 11 | 12 | 查看各个平台的余额和货币数量 13 | 14 | > 策略参数 15 | 16 | 17 | 18 | |参数|默认值|描述| 19 | |----|----|----| 20 | |DisableRate|false|禁用汇率转换| 21 | 22 | 23 | > 源码 (javascript) 24 | 25 | ``` javascript 26 | function main() { 27 | for (var i = 0; i < exchanges.length; i++) { 28 | if (DisableRate) { 29 | exchanges[i].SetRate(1); 30 | } 31 | 32 | if (exchanges[i].GetName().indexOf('CTP') != -1) { 33 | while (!exchanges[i].IO("status")) { 34 | LogStatus("正在等待" + exchanges[i].GetLabel() + "连接到交易所服务器, 行情服务器: " + (exchanges[i].IO("status", 0) ? '正常' : '断开') + ', 交易服务器: ' + (exchanges[i].IO("status", 1) ? '正常' : '断开')); 35 | Sleep(1000); 36 | } 37 | LogStatus("连接成功"); 38 | } 39 | 40 | while (true) { 41 | var account = exchanges[i].GetAccount(); 42 | if (account) { 43 | Log(exchanges[i].GetName(), exchanges[i].GetLabel(), exchanges[i].GetCurrency(), exchanges[i].GetAccount()); 44 | break; 45 | } 46 | Sleep(3000); 47 | } 48 | } 49 | } 50 | ``` 51 | 52 | > 策略出处 53 | 54 | https://www.fmz.com/strategy/48 55 | 56 | > 更新时间 57 | 58 | 2016-07-25 16:10:13 59 | -------------------------------------------------------------------------------- /典型价格百分比通道-凯尔特纳与百分比通道变形.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 典型价格百分比通道-凯尔特纳与百分比通道变形 5 | 6 | > 策略作者 7 | 8 | cyberking 9 | 10 | > 策略描述 11 | 12 | 典型价格百分比通道-凯尔特纳与百分比通道变形 13 | DX^^EMA((H+L+C)/3,N); //21天典型价格均线 中 14 | KRTHR^^EMA(DX,N)*1.05; //21天百分比通道 上 15 | KRTXR^^EMA(DX,N)/1.05; //21天百分比通道 下 16 | 17 | 18 | 19 | > 源码 (麦语言) 20 | 21 | ``` pascal 22 | (*backtest 23 | start: 2019-02-09 00:00:00 24 | end: 2020-03-04 00:00:00 25 | period: 1d 26 | exchanges: [{"eid":"Huobi","currency":"BTC_USDT"}] 27 | *) 28 | 29 | //ZF:=H-C; //振幅 30 | N:=21; 31 | DX^^EMA((H+L+C)/3,N); //21天典型价格均线 中 32 | KRTHR^^EMA(DX,N)*1.05; //21天百分比通道 上 33 | KRTXR^^EMA(DX,N)/1.05; //21天百分比通道 下 34 | 35 | C>DX AND (DXDX AND REF(DX,1)>REF(DX,2),BPK; 37 | CKRTXR),SPK; //下突破典型 中轨, 中轨大于下轨 38 | //C 策略出处 43 | 44 | https://www.fmz.com/strategy/188507 45 | 46 | > 更新时间 47 | 48 | 2020-03-05 21:36:49 49 | -------------------------------------------------------------------------------- /冰山委托买入简单版Simple-Iceberg-order-to-buy.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 冰山委托买入简单版Simple-Iceberg-order-to-buy 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | Very simple, just for learn. 13 | Code is best annotation. 14 | 15 | 冰山委托买入,将订单分成小笔M买入,避免冲击市场,是很好的简单入门比特币量化交易的学习策略 16 | 17 | > 策略参数 18 | 19 | 20 | 21 | |参数|默认值|描述| 22 | |----|----|----| 23 | |BUYAMOUNT|2|amount to buy| 24 | |BUYSIZE|0.1|iceberg order size| 25 | |INTERVAL|3|orders exist time(second)| 26 | 27 | 28 | > 源码 (javascript) 29 | 30 | ``` javascript 31 | function main(){ 32 | var initAccount = _C(exchange.GetAccount) 33 | while(true){ 34 | var account = _C(exchange.GetAccount) 35 | var dealAmount = account.Stocks - initAccount.Stocks 36 | var ticker = _C(exchange.GetTicker) 37 | if(BUYAMOUNT - dealAmount > BUYSIZE){ 38 | var id = exchange.Buy(ticker.Sell, BUYSIZE) 39 | Sleep(INTERVAL*1000) 40 | if(id){ 41 | exchange.CancelOrder(id) // May cause error log when the order is completed, which is all right. 42 | }else{ 43 | throw 'buy error' 44 | } 45 | }else{ 46 | account = _C(exchange.GetAccount) 47 | var avgCost = (initAccount.Balance - account.Balance)/(account.Stocks - initAccount.Stocks) 48 | Log('Iceberg order to buy is done, avg cost is ', avgCost) // including fee cost 49 | return 50 | } 51 | 52 | } 53 | } 54 | ``` 55 | 56 | > 策略出处 57 | 58 | https://www.fmz.com/strategy/121522 59 | 60 | > 更新时间 61 | 62 | 2020-03-20 16:24:13 63 | -------------------------------------------------------------------------------- /冰山委托卖出简单版Simple-Iceberg-order-to-sell.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 冰山委托卖出简单版Simple-Iceberg-order-to-sell 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | Very simple, just for learn. 13 | Code is best annotation. 14 | 15 | 冰山委托卖出,将订单分成小笔卖出,避免冲击市场,是很好的简单入门比特币量化交易的学习策略 16 | 17 | > 策略参数 18 | 19 | 20 | 21 | |参数|默认值|描述| 22 | |----|----|----| 23 | |SELLAMOUNT|2|amount to sell| 24 | |SELLSIZE|0.1|sell orders size| 25 | |INTERVAL|3|order exist time(second)| 26 | 27 | 28 | > 源码 (javascript) 29 | 30 | ``` javascript 31 | function main(){ 32 | var initAccount = _C(exchange.GetAccount) 33 | if (initAccount.Stocks < SELLAMOUNT){ 34 | throw 'check your account amount to sell' 35 | } 36 | while(true){ 37 | var account = _C(exchange.GetAccount) 38 | var dealAmount = initAccount.Stocks - account.Stocks 39 | var ticker = _C(exchange.GetTicker) 40 | if(SELLAMOUNT - dealAmount > SELLSIZE){ 41 | var id = exchange.Sell(ticker.Buy, SELLSIZE) 42 | Sleep(INTERVAL*1000) 43 | if(id){ 44 | exchange.CancelOrder(id) // May cause error log when the order is completed, which is all right. 45 | }else{ 46 | throw 'sell error' 47 | } 48 | }else{ 49 | account = _C(exchange.GetAccount) 50 | var avgCost = (account.Balance - initAccount.Balance)/(initAccount.Stocks - account.Stocks) 51 | Log('Iceberg order to sell is done, avg price is ', avgCost) // including fee cost 52 | return 53 | } 54 | } 55 | } 56 | ``` 57 | 58 | > 策略出处 59 | 60 | https://www.fmz.com/strategy/121524 61 | 62 | > 更新时间 63 | 64 | 2019-07-03 16:39:19 65 | -------------------------------------------------------------------------------- /冲币安新上币开盘.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 冲币安新上币开盘 5 | 6 | > 策略作者 7 | 8 | GCC 9 | 10 | > 策略描述 11 | 12 | 冲币安新币开盘用的,显而易见,成功率并不高,2021/11/4冲DAR开盘,买在了山顶,及时止损亏了10%,不玩了! 13 | 14 | > 策略参数 15 | 16 | 17 | 18 | |参数|默认值|描述| 19 | |----|----|----| 20 | |XX|200|冲多少| 21 | 22 | 23 | > 源码 (python) 24 | 25 | ``` python 26 | def main(): 27 | Log(exchange.GetAccount()) 28 | Log(exchange.GetCurrency()) 29 | while True: 30 | ticker = exchange.GetTicker() 31 | if ticker: 32 | Log("开盘了,冲啊!!!@") 33 | exchange.SetPrecision(1,0) 34 | amount = XX/ticker['Last'] 35 | exchange.Buy(-1, amount) 36 | exchange.Buy(-1, amount/2) 37 | exchange.Buy(-1, amount/4) 38 | exchange.Buy(-1, amount/8) 39 | exchange.Buy(-1, amount/16) 40 | Sleep(15*1000) 41 | while True: 42 | try: 43 | _ticker = exchange.GetTicker() 44 | if _ticker['Last'] > ticker['Last']: 45 | exchange.Sell(-1, amount/3) 46 | Log("已经卖出三分之一@") 47 | return 48 | else: 49 | Sleep(30) 50 | continue 51 | except: 52 | Sleep(30) 53 | continue 54 | else: 55 | Sleep(20) 56 | ``` 57 | 58 | > 策略出处 59 | 60 | https://www.fmz.com/strategy/324178 61 | 62 | > 更新时间 63 | 64 | 2021-11-20 13:45:47 65 | -------------------------------------------------------------------------------- /函数自动容错模板.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 函数自动容错模板 5 | 6 | > 策略作者 7 | 8 | Zero 9 | 10 | > 策略描述 11 | 12 | 打勾调用此模板后会自动对指定的Api函数进行重试容错, 支持多交易所 13 | 14 | > 策略参数 15 | 16 | 17 | 18 | |参数|默认值|描述| 19 | |----|----|----| 20 | |RetryInterval|500|容错重试间隔(毫秒)| 21 | |Debug|true|显示重试记录| 22 | |EnableErrorFilter|false|屏蔽常见网络错误信息| 23 | |ApiList|GetAccount,GetDepth,GetTicker,GetRecords,GetTrades,GetOrders,SetContractType|容错API列表| 24 | 25 | 26 | > 源码 (javascript) 27 | 28 | ``` javascript 29 | // 模板初始化时调用 30 | function init() { 31 | // 过滤常见错误 32 | if (EnableErrorFilter) { 33 | SetErrorFilter("502:|503:|tcp|character|connection|unexpected|network|timeout|WSARecv|Connect|GetAddr|no such|reset|http|received|EOF|reused"); 34 | } 35 | // 重定义需要容错的函数 36 | var names = ApiList.split(','); 37 | _.each(exchanges, function(e) { 38 | _.each(names, function(name) { 39 | if (typeof(e[name]) !== 'function') { 40 | throw "尝试容错 " + name + " 失败, 请确认存在此API并且输入正确."; 41 | } 42 | var old = e[name]; 43 | e[name] = function() { 44 | var r; 45 | while (!(r = old.apply(this, Array.prototype.slice.call(arguments)))) { 46 | if (Debug) { 47 | Log(e.GetLabel(), name, "调用失败", RetryInterval, "毫秒后重试..."); 48 | } 49 | Sleep(RetryInterval); 50 | } 51 | return r; 52 | }; 53 | }); 54 | }); 55 | Log("容错机制开启", names); 56 | } 57 | 58 | // Test 59 | function main() { 60 | // 此时GetTicker就不需要重试了 61 | Log(exchange.GetTicker()); 62 | } 63 | ``` 64 | 65 | > 策略出处 66 | 67 | https://www.fmz.com/strategy/11609 68 | 69 | > 更新时间 70 | 71 | 2016-04-03 17:17:41 72 | -------------------------------------------------------------------------------- /分享-ATR为例均值计算中容错教程.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 分享-ATR为例均值计算中容错教程 5 | 6 | > 策略作者 7 | 8 | 作手君 9 | 10 | > 策略描述 11 | 12 | 为回馈FMZ平台与社区,进行策略&代码&思路&模板的分享 13 | 14 | 简介: 15 | 详细的均值计算步骤,以ATR为例。 16 | 包含指标调用、数据点不足容错、意外数据错误容错等细节 17 | 策略的重要是细节的把握。 18 | 19 | 欢迎合作交流,共同学习进步~ 20 | v:haiyanyydss 21 | 22 | 23 | 24 | > 源码 (javascript) 25 | 26 | ``` javascript 27 | var arecords = _C(exchange.GetRecords, 300); 28 | var time = arecords[arecords.length - 1].Time 29 | var nowtime = time; 30 | var atremaarr = []; 31 | var Onoff = 0; 32 | 33 | function main() { 34 | while (true) { 35 | //这里开始 把这段放循环里 36 | var Num = 50; //可以改,几根的平均值 37 | var records = _C(exchange.GetRecords, 300); 38 | var atr = TA.EMA(records, 9) 39 | nowtime = records[records.length - 1].Time 40 | if (nowtime > time || Onoff == 0) { 41 | atr = atr.slice(atr.length - (20 + Num)); 42 | for (var i = 0; i < (atr.length - Num); i++) { //(atr.length-Num) 长度减掉周期 比如500根 前50根是不准的平均值 这里就取450 43 | var atremTEMP = 0; //计算求和的,初始设置为0 44 | for (var j = 0; j < Num; j++) { //求和 45 | atrTEMP = atr[i + j] > 0 ? atr[i + j] : 0; //剔除意外数据 ,大于O 取值,小于O 或者其他情况取值O 46 | atremTEMP += atrTEMP; 47 | } 48 | atremaarr.push(atremTEMP / Num); //把平均值P到数组 49 | } 50 | time = nowtime; 51 | Onoff += 1; 52 | Log("计算第:", Onoff, "次。"); 53 | } 54 | //这里结算 把这段放循环里 55 | Sleep(3000) 56 | Log("最后一根:", _N(atremaarr[atremaarr.length - 1], 2)) //拿值 57 | //Log("最后第二根:", _N(atremaarr[atremaarr.length-2],2)) 58 | } 59 | } 60 | 61 | ``` 62 | 63 | > 策略出处 64 | 65 | https://www.fmz.com/strategy/396764 66 | 67 | > 更新时间 68 | 69 | 2023-02-09 09:48:42 70 | -------------------------------------------------------------------------------- /分享RSI超买超卖策略.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 分享RSI超买超卖策略 5 | 6 | > 策略作者 7 | 8 | 胡萝卜-CCXT策略代写 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | import talib 18 | import numpy as np 19 | import time 20 | 21 | # 初始化策略参数 22 | symbol = 'huobip/btc_usdt' 23 | period = '1m' 24 | rsi_period = 14 25 | rsi_buy = 30 26 | rsi_sell = 70 27 | amount = 0.01 28 | last_buy_price = 0 29 | 30 | # 连接API 31 | exchange = Exchange() 32 | exchange.SetContractType(symbol) 33 | exchange.SetPeriod(period) 34 | 35 | # 主循环 36 | while True: 37 | # 获取K线数据 38 | klines = exchange.GetRecords() 39 | if not klines: 40 | continue 41 | 42 | # 计算RSI指标 43 | close_prices = np.array([float(k['Close']) for k in klines]) 44 | rsi = talib.RSI(close_prices, rsi_period) 45 | 46 | # 获取当前价格 47 | current_price = float(klines[-1]['Close']) 48 | 49 | # 判断是否超买或超卖 50 | if rsi[-1] < rsi_buy and last_buy_price == 0: 51 | # 超卖,买入 52 | buy_price = current_price 53 | buy_amount = amount / buy_price 54 | exchange.Buy(buy_price, buy_amount) 55 | last_buy_price = buy_price 56 | print('买入', buy_amount, 'BTC,价格', buy_price) 57 | elif rsi[-1] > rsi_sell and last_buy_price != 0: 58 | # 超买,卖出 59 | sell_price = current_price 60 | sell_amount = amount / sell_price 61 | exchange.Sell(sell_price, sell_amount) 62 | last_buy_price = 0 63 | print('卖出', sell_amount, 'BTC,价格', sell_price) 64 | 65 | # 等待下一次循环 66 | time.sleep(60) 67 | 68 | ``` 69 | 70 | > 策略出处 71 | 72 | https://www.fmz.com/strategy/410112 73 | 74 | > 更新时间 75 | 76 | 2023-04-18 12:46:08 77 | -------------------------------------------------------------------------------- /分享抢新现货策略.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 分享抢新现货策略 5 | 6 | > 策略作者 7 | 8 | 胡萝卜-CCXT策略代写 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | import time 18 | 19 | # 初始化策略参数 20 | symbol = 'huobip/ht_usdt' 21 | amount = 10 22 | max_price = 1.5 23 | min_price = 0.5 24 | interval = 0.1 25 | 26 | # 连接API 27 | exchange = Exchange() 28 | exchange.SetContractType(symbol) 29 | 30 | # 主循环 31 | while True: 32 | # 获取当前市场深度 33 | depth = exchange.GetDepth() 34 | 35 | # 获取当前买一和卖一价格 36 | buy_price = float(depth['Bids'][0]['Price']) 37 | sell_price = float(depth['Asks'][0]['Price']) 38 | 39 | # 判断是否满足条件 40 | if buy_price <= max_price and sell_price >= min_price: 41 | # 满足条件,进行买入操作 42 | buy_amount = amount / buy_price 43 | exchange.Buy(buy_price, buy_amount) 44 | print('买入', buy_amount, 'HT,价格', buy_price) 45 | 46 | # 等待一段时间后进行卖出操作 47 | time.sleep(interval) 48 | sell_price = float(depth['Asks'][0]['Price']) 49 | sell_amount = amount / sell_price 50 | exchange.Sell(sell_price, sell_amount) 51 | print('卖出', sell_amount, 'HT,价格', sell_price) 52 | 53 | # 等待下一次循环 54 | time.sleep(1) 55 | 56 | 57 | #该策略使用了FMZ平台提供的Exchange API来进行交易。在主循环中,首先获取当前市场深度,然后获取当前买一和卖一价格。如果买一价格小于等于设定的最大价格且卖一价格大于等于设定的最小价格,则进行买入操作。等待一段时间后再获取当前卖一价格进行卖出操作。最后等待下一次循环。需要注意的是,抢新现货策略存在一定的风险,需要谨慎操作。 58 | ``` 59 | 60 | > 策略出处 61 | 62 | https://www.fmz.com/strategy/410113 63 | 64 | > 更新时间 65 | 66 | 2023-04-18 12:47:36 67 | -------------------------------------------------------------------------------- /分享模板引用错误追踪.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 分享模板引用错误追踪 5 | 6 | > 策略作者 7 | 8 | leviyuan 9 | 10 | > 策略描述 11 | 12 | 使用方法,首先引用这个模板类库 13 | 在每一个脚本文件里面添加 $.fileLineMark("main", 35) 第一个参数:文件名 第二个参数:这行代码在文件里面的行号 14 | 并保证在追踪错误之前,这行代码被执行 15 | 最后在策略代码加上 main = $.tryfunc(main) 以保证所有的调用都通过try 16 | 17 | 在策略报错时,会自动有一行红字指出在哪个文件的哪一行 18 | 19 | 原理:托管着加载js代码的方式,是把所有的js代码,包含类库,合并成一个大文件载入;找出每个文件在大文件中的位置,最后报错时候,反向对应,即可知道具体报错的行号 20 | 21 | ![IMG](https://www.fmz.com/upload/asset/443a3c3f50e09c3ca4be.png) 22 | 23 | 24 | 25 | > 源码 (javascript) 26 | 27 | ``` javascript 28 | var fileStartLine = [] 29 | $.fileLineMark = function(file, line) { 30 | try{a=a+1}catch(ex){ 31 | var markline = parseInt(ex.stack.split('\n')[3].split('(__FILE__:')[1].split(')')[0]) 32 | fileStartLine.push([file, markline-line]) 33 | fileStartLine.sort(function(a, b){ 34 | return b[1] - a[1] 35 | }) 36 | } 37 | } 38 | 39 | $.tryfunc = function(func) { 40 | return function(a,b,c,d,e,f,g,h,i,j,k,l,m,n) { 41 | try { 42 | return func(a,b,c,d,e,f,g,h,i,j,k,l,m,n) 43 | } catch(ex) { 44 | if (ex.message == "execution timeout") { 45 | Log("忽略机器人停止指令") 46 | throw ex 47 | return 48 | } 49 | 50 | var line = parseInt(ex.stack.split('\n')[2].split('(__FILE__:')[1].split(')')[0]) 51 | for (var ii = 0; ii < fileStartLine.length; ii++) { 52 | if (line > fileStartLine[ii][1]) { 53 | Log("catch error at " + fileStartLine[ii][0] + ":" + (line-fileStartLine[ii][1])+"#ff0000") 54 | break 55 | } 56 | } 57 | 58 | throw ex 59 | } 60 | } 61 | } 62 | 63 | function onTick() { 64 | 65 | } 66 | 67 | function main() { 68 | $.fileLineMark("main", 41) 69 | onTick = $.tryfunc(onTick) 70 | 71 | while(true){ 72 | onTick() 73 | Sleep(1000) 74 | } 75 | } 76 | 77 | ``` 78 | 79 | > 策略出处 80 | 81 | https://www.fmz.com/strategy/182793 82 | 83 | > 更新时间 84 | 85 | 2020-01-28 21:11:06 86 | -------------------------------------------------------------------------------- /切换OKEX_V5模拟盘交易终端插件.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 切换OKEX_V5模拟盘交易终端插件 5 | 6 | > 策略作者 7 | 8 | 小小梦 9 | 10 | > 策略描述 11 | 12 | ## 交易终端OKEX_V5模拟盘切换插件 13 | 14 | 当配置好OKEX V5交易所对象时(使用OKEX V5的模拟盘API KEY配置),由于没有切换模拟盘环境,会有如下报错: 15 | 16 | ``` 17 | {"msg":"Broker id of APIKey does not match current environment.","code":"50101"} 18 | ``` 19 | 20 | 可以使用该插件切换,如图: 21 | 22 | - #### 点击添加按钮: 23 | 24 | ![IMG](https://www.fmz.com/upload/asset/1789d89b0004425112f5.png) 25 | 26 | - #### 选择插件: 27 | 28 | ![IMG](https://www.fmz.com/upload/asset/1714b6edacde6828eba2.png) 29 | 30 | - #### 执行插件 31 | 32 | ![IMG](https://www.fmz.com/upload/asset/169ace291c5d0da6e210.png) 33 | 34 | - #### 立即执行 35 | 36 | ![IMG](https://www.fmz.com/upload/asset/170bac2eacc494c2eba3.png) 37 | 38 | - #### 模拟盘资产就读取出来了 39 | 40 | ![IMG](https://www.fmz.com/upload/asset/168a45cf491f249d7189.png) 41 | 42 | 如果要切换回实盘环境,勾掉选项再次执行即可。 43 | 44 | 45 | 46 | > 源码 (javascript) 47 | 48 | ``` javascript 49 | function main() { 50 | exchange.IO("simulate", true) 51 | return "已经切换为OKEX V5模拟盘" 52 | } 53 | ``` 54 | 55 | > 策略出处 56 | 57 | https://www.fmz.com/strategy/288769 58 | 59 | > 更新时间 60 | 61 | 2021-06-08 15:08:47 62 | -------------------------------------------------------------------------------- /动态平衡策略-python-版.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 动态平衡策略-python-版 5 | 6 | > 策略作者 7 | 8 | teddy 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | 18 | # !usr/bin/ python3 19 | # *_* coding:utf-8 *_* 20 | #学会python后写的第一个动态平衡策略 21 | # QQ:5325049 不足之处欢迎指正 22 | 23 | import time 24 | 25 | #定义获取行情及账户信息函数 26 | def nowinfo(): 27 | global NowTicker,NowAsset,NowCoinValue,AssetDiff 28 | NowTicker = exchange.GetTicker() #获取行情信息 29 | NowAsset = exchange.GetAccount() # 获取账户信息 30 | NowCoinValue =NowTicker.Last * NowAsset.Stocks #计算币资产净值 31 | AssetDiff = NowCoinValue-NowAsset.Balance #计算币资产与现金差额 32 | 33 | # 定义交易执行函数 34 | def trade(): 35 | if AssetDiff > NowAsset.Balance*0.05: # 判断币值是否超过资金5% 36 | Log("交易将被执行,以",NowTicker.Buy,"卖出",AssetDiff/2/NowTicker.Buy,"个币") 37 | exchange.SetPrecision(5,5) #设置计价精度 38 | exchange.Sell(NowTicker.Buy,AssetDiff/2/NowTicker.Buy) #执行币卖出交易 39 | elif AssetDiff < NowAsset.Balance*(-0.05): #判断币值是否低于资金5% 40 | Log("交易将被执行,以",NowTicker.Sell,"买入",AssetDiff/-2/NowTicker.Sell,"个币") 41 | exchange.SetPrecision(5,5) #设置计价精度 42 | exchange.Buy(NowTicker.Sell,AssetDiff/-2/NowTicker.Sell) #执行币买入交易 43 | else: 44 | Log("未触发交易条件") 45 | 46 | # 入口函数,只要定义了系统就会自动执行该函数,不需要调用啊 47 | def main(): 48 | i = 0 49 | while i < 1000: #设置执行总次数 50 | nowinfo() # 调用获取行情资产函数 51 | Log(NowTicker) # 打印行情信息 52 | Log(NowAsset) # 打印账户信息 53 | Log("当前币余额:",NowAsset.Stocks) 54 | Log("当前资金余额:",NowAsset.Balance) 55 | Log("当前币市值:", NowCoinValue) 56 | Log("币市值与资金差额:",AssetDiff) 57 | trade() #调用 交易执行函数 58 | i+=1 # 条件迭代 59 | Log("第", i, "轮循环结束") 60 | time.sleep(60) # 等待60秒 61 | 62 | 63 | ``` 64 | 65 | > 策略出处 66 | 67 | https://www.fmz.com/strategy/152830 68 | 69 | > 更新时间 70 | 71 | 2019-06-22 18:35:30 72 | -------------------------------------------------------------------------------- /单独计算收益代码来自zero.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 单独计算收益代码来自zero 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | 收益可以和策略放在一起,但还是独立出来更好。原因:1、交易策略更改中断时,收益不会被重置。2、收益计算本身会调用API函数,经常造成策略API网络错误,影响交易运行,独立出来减少这种可能性。3、可以自定义循环间隔。 13 | 14 | 15 | 16 | > 源码 (javascript) 17 | 18 | ``` javascript 19 | 20 | function adjustFloat(v) { 21 | 22 | return Math.floor(v*1000)/1000; 23 | } 24 | 25 | 26 | function GetAccount() { 27 | var account; 28 | while (!(account = exchange.GetAccount())) { 29 | Sleep(1000); 30 | } 31 | return account; 32 | } 33 | 34 | function GetTicker() { 35 | var ticker; 36 | while (!(ticker = exchange.GetTicker())) { 37 | Sleep(1000); 38 | } 39 | return ticker; 40 | } 41 | 42 | function updateProfit(accountInit, accountNow, ticker) { 43 | var netNow = accountNow.Balance + accountNow.FrozenBalance + ((accountNow.Stocks + accountNow.FrozenStocks) * ticker.Buy); 44 | var netInit = accountInit.Balance + accountInit.FrozenBalance + ((accountInit.Stocks + accountInit.FrozenStocks) * ticker.Buy); 45 | LogProfit(adjustFloat(netNow - netInit), accountNow); 46 | 47 | } 48 | 49 | function main() { 50 | InitAccount = GetAccount(); 51 | while (true) { 52 | updateProfit(InitAccount, GetAccount(), GetTicker()); 53 | Sleep(5000); 54 | } 55 | } 56 | ``` 57 | 58 | > 策略出处 59 | 60 | https://www.fmz.com/strategy/1084 61 | 62 | > 更新时间 63 | 64 | 2016-05-10 20:05:02 65 | -------------------------------------------------------------------------------- /取消所有订单.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 取消所有订单 5 | 6 | > 策略作者 7 | 8 | Zero 9 | 10 | > 策略描述 11 | 12 | 取消所有订单 13 | 14 | 15 | 16 | > 源码 (javascript) 17 | 18 | ``` javascript 19 | var Interval = 1000; 20 | 21 | function GetAccount(e) { 22 | if (typeof(e) == 'undefined') { 23 | e = exchange; 24 | } 25 | var account; 26 | while (!(account = e.GetAccount())) { 27 | Sleep(Interval); 28 | } 29 | return account; 30 | } 31 | 32 | function cancelPending(e) { 33 | Log(e.GetName(), GetAccount(e)); 34 | var ret = false; 35 | var isFutures = e.GetName().indexOf("796") != -1; 36 | while (true) { 37 | if (ret) { 38 | Sleep(Interval); 39 | } 40 | var orders = null; 41 | while (!(orders = e.GetOrders())) { 42 | Sleep(Interval); 43 | } 44 | 45 | if (orders.length == 0) { 46 | break; 47 | } 48 | 49 | for (var j = 0; j < orders.length; j++) { 50 | if (isFutures) { 51 | e.SetDirection(orders[j].Type == ORDER_TYPE_BUY ? "buy" : "sell"); 52 | } 53 | e.CancelOrder(orders[j].Id, orders[j]); 54 | ret = true; 55 | } 56 | } 57 | Log(e.GetName(), GetAccount(e)); 58 | return ret; 59 | } 60 | 61 | function main() { 62 | for (var i = 0; i < exchanges.length; i++) { 63 | cancelPending(exchanges[i]); 64 | } 65 | } 66 | ``` 67 | 68 | > 策略出处 69 | 70 | https://www.fmz.com/strategy/280 71 | 72 | > 更新时间 73 | 74 | 2014-10-07 21:11:05 75 | -------------------------------------------------------------------------------- /各平台策略代写区块链5年专业经验低价高质量-薇芯bov1107.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 各平台策略代写区块链5年专业经验低价高质量-薇芯bov1107 5 | 6 | > 策略作者 7 | 8 | science量化1 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | def main(): 18 | Log(exchange.GetAccount()) 19 | 20 | ``` 21 | 22 | > 策略出处 23 | 24 | https://www.fmz.com/strategy/346773 25 | 26 | > 更新时间 27 | 28 | 2022-02-22 18:25:38 29 | -------------------------------------------------------------------------------- /各平台策略代写区块链5年专业经验低价高质量薇芯bov1107.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 各平台策略代写区块链5年专业经验低价高质量薇芯bov1107 5 | 6 | > 策略作者 7 | 8 | science量化团队(策略代写薇芯:bov1107) 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | def main(): 18 | Log(exchange.GetAccount()) 19 | 20 | ``` 21 | 22 | > 策略出处 23 | 24 | https://www.fmz.com/strategy/346689 25 | 26 | > 更新时间 27 | 28 | 2022-02-22 12:24:35 29 | -------------------------------------------------------------------------------- /吕神简易波动率策略Pine语言版本.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 吕神简易波动率策略Pine语言版本 5 | 6 | > 策略作者 7 | 8 | 发明者量化 9 | 10 | > 策略描述 11 | 12 | 来自于两年前用户公开的一个简单的波动率策略 13 | 14 | https://www.fmz.com/strategy/200131 15 | 16 | 无意翻到, 用PINE重写了下代码量减少了 90% 给量化的朋友们学习参考 17 | 18 | ![IMG](https://www.fmz.com/upload/asset/143fce25524c3447937.png) 19 | 20 | > 策略参数 21 | 22 | 23 | 24 | |参数|默认值|描述| 25 | |----|----|----| 26 | |v_input_1|50|指数计算周期| 27 | 28 | 29 | > 源码 (PineScript) 30 | 31 | ``` javascript 32 | /*backtest 33 | start: 2021-05-16 00:00:00 34 | end: 2022-05-15 23:59:00 35 | period: 1d 36 | basePeriod: 1h 37 | exchanges: [{"eid":"Bitfinex","currency":"BTC_USD"}] 38 | */ 39 | 40 | N = input(50, '指数计算周期') 41 | 42 | vix = math.log(close) / math.log(close[N-1]) - 1 43 | vix_ma = ta.sma(vix, N) 44 | vix_ma_up = ta.highest(vix_ma, N) 45 | vix_ma_down = ta.lowest(vix_ma, N) 46 | 47 | plot(vix, 'vix') 48 | plot(vix_ma, 'vix_ma') 49 | upline = plot(vix_ma_up, 'vix_ma_up') 50 | downline = plot(vix_ma_down, 'vix_ma_down') 51 | fill(upline, downline, color=color.new(color.gray, 50)) 52 | 53 | qty = math.round(strategy.equity / close, 2) 54 | 55 | if strategy.position_size == 0 56 | if vix > vix_ma_up and vix[1] <= vix_ma_up[1] 57 | strategy.entry("LONG", strategy.long, qty=qty) 58 | else if vix < vix_ma_down and vix[1] >= vix_ma_down[1] 59 | strategy.entry("SHORT", strategy.short, qty=qty) 60 | else if strategy.position_size > 0 61 | if vix < vix_ma and vix[1] >= vix_ma[1] 62 | strategy.close_all() 63 | else if strategy.position_size < 0 64 | if vix > vix_ma and vix[1] <= vix_ma[1] 65 | strategy.close_all() 66 | 67 | 68 | ``` 69 | 70 | > 策略出处 71 | 72 | https://www.fmz.com/strategy/361827 73 | 74 | > 更新时间 75 | 76 | 2022-05-29 20:51:28 77 | -------------------------------------------------------------------------------- /回测保存K线到本地CSV.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 回测保存K线到本地CSV 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | ''' 18 | /*backtest 19 | start: 2017-10-01 20 | end: 2017-11-16 21 | period: 1440 22 | periodBase: 15 23 | mode: 0 24 | */ 25 | ''' 26 | 27 | #需要用的pandas库,并且用自己的托管回测才能保存到本地 28 | #import numpy as np 29 | import pandas as pd 30 | 31 | #保存路径 32 | path = 'C:\\Users\\Public\\Documents\\' 33 | 34 | def main(): 35 | df=pd.DataFrame() 36 | while True: 37 | records = _C(exchange.GetRecords) 38 | df_new = pd.DataFrame(records) #把records转为dataframe 39 | df_new['Time'] = pd.to_datetime(df_new['Time'],unit='ms')+pd.Timedelta('8 h') 40 | df_new.index = df_new['Time'] 41 | if df.empty or df_new['Time'].min() >= df['Time'].max(): 42 | df=df.combine_first(df_new) 43 | Log(df['Time'].max()) 44 | #确定最后一次时间,用于保存数据 45 | if df_new['Time'].max() == pd.Timestamp('2017-11-15 23:45:00'): 46 | Log('保存数据') 47 | df=df.combine_first(df_new) 48 | df.to_csv(path+'records15.csv',index=False) 49 | break 50 | #休眠时间是选择周期 51 | Sleep(15*60*1000) 52 | 53 | ``` 54 | 55 | > 策略出处 56 | 57 | https://www.fmz.com/strategy/61867 58 | 59 | > 更新时间 60 | 61 | 2017-12-15 13:31:31 62 | -------------------------------------------------------------------------------- /固定间距批量挂单插件.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 固定间距批量挂单插件 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | 会按固定间隔摆出挂单,可用于期货开仓平仓 13 | 插件可以在交易终端一键启动,不收取费用,方便手动交易。详细介绍:https://www.fmz.com/digest-topic/5051 14 | 15 | > 策略参数 16 | 17 | 18 | 19 | |参数|默认值|描述| 20 | |----|----|----| 21 | |Type|0|下单类型: 买单|卖单|买入平仓|卖出平仓| 22 | |Start_Price|7000|开始价格| 23 | |Spread|5|间隔| 24 | |N|5|挂单个数| 25 | |Amount|0.1|每单挂单量| 26 | |Amount_Step|false|挂单递增量| 27 | 28 | 29 | > 源码 (javascript) 30 | 31 | ``` javascript 32 | 33 | function main() { 34 | var ticker = exchange.GetTicker() 35 | if(!ticker){ 36 | return 'Unable to get price' 37 | } 38 | for(var i=0;i 策略出处 65 | 66 | https://www.fmz.com/strategy/190017 67 | 68 | > 更新时间 69 | 70 | 2020-04-02 11:26:19 71 | -------------------------------------------------------------------------------- /均线和高低点相对强弱策略Relative-Strength-Strategy-Based-on-Price.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 均线和高低点相对强弱策略Relative-Strength-Strategy-Based-on-Price 5 | 6 | > 策略作者 7 | 8 | 阿基米德的浴缸 9 | 10 | > 策略描述 11 | 12 | [trans] 13 | - 策略名称:基于价格相对强的弱策略 14 | - 数据周期:1H 15 | - 支持:商品期货、数字货币、数字货币期货 16 | - 官方网站:www.quantinfo.com 17 | 18 | 19 | ![IMG](https://www.fmz.com/upload/asset/2e346e6e3b2edda65576ffe7d35e104b.png) 20 | 21 | 22 | 23 | - 主图: 24 | 均线,公式: MAN^^MA(C,N); 25 | 26 | 27 | - 副图: 28 | 无 29 | 30 | || 31 | 32 | - Strategy Name: Relative Strength Strategy Based on Price 33 | - Data cycle: 1H 34 | - Support: Commodity Futures, Digital Currency and Digital Currency Futures 35 | 36 | ![IMG](https://www.fmz.com/upload/asset/45096a9dbc8e6361219bd4957494ac60.png) 37 | ![IMG](https://www.fmz.com/upload/asset/bcf5916794bbc6d9e5e8332b6fa9798c.png) 38 | 39 | - Main chart: 40 | MA, formula: MAN^^MA(C,N); 41 | - Secondary chart: 42 | none 43 | 44 | [/trans] 45 | 46 | > 策略参数 47 | 48 | 49 | 50 | |参数|默认值|描述| 51 | |----|----|----| 52 | |N|100|均线指标参数|MA index parameter| 53 | |M|2|止损差价系数|stop loss difference coefficient| 54 | 55 | 56 | > 源码 (麦语言) 57 | 58 | ``` pascal 59 | (*backtest 60 | start: 2018-02-01 00:00:00 61 | end: 2018-04-27 00:00:00 62 | period: 1h 63 | exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}] 64 | args: [["ContractType","rb888",126961]] 65 | *) 66 | 67 | MAN^^MA(C,N); 68 | B_MA:=C>MAN; 69 | S_MA:=C0.5; 72 | B_K1:=SUM((C-L)*V,N)/SUM((H-L)*V,N)>0.5; 73 | 74 | CO:=IF(C>O,C-O,0); 75 | OC:=IF(C0.5; 77 | B_K2:=SUM(CO*V,N)/SUM(ABS(C-O)*V,N)>0.5; 78 | 79 | B_K1 AND B_K2 AND B_MA AND H>=HHV(H,N),BPK; 80 | S_K1 AND S_K2 AND S_MA AND L<=LLV(L,N),SPK; 81 | 82 | STOPLOSS:=M*MA(H-L,N); 83 | CSKPRICE+STOPLOSS,BP(SKVOL); 85 | 86 | S_MA AND BKHIGH>BKPRICE+STOPLOSS,SP(BKVOL); 87 | B_MA AND SKLOW 策略出处 91 | 92 | https://www.fmz.com/strategy/129078 93 | 94 | > 更新时间 95 | 96 | 2018-12-18 10:25:23 97 | -------------------------------------------------------------------------------- /均线策略python版.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 均线策略python版 5 | 6 | > 策略作者 7 | 8 | 小小梦 9 | 10 | > 策略描述 11 | 12 | 均线策略(python版)教学性质,实盘慎用。 13 | 14 | > 策略参数 15 | 16 | 17 | 18 | |参数|默认值|描述| 19 | |----|----|----| 20 | |FastPeriod|3|入市快线周期| 21 | |SlowPeriod|7|入市慢线周期| 22 | |EnterPeriod|3|入市观察期| 23 | |ExitFastPeriod|3|离市快线周期| 24 | |ExitSlowPeriod|7|离市慢线周期| 25 | |ExitPeriod|true|离市观察期| 26 | |PositionRatio|0.8|仓位比例| 27 | |Interval|10|轮询周期| 28 | 29 | 30 | > 源码 (python) 31 | 32 | ``` python 33 | import types 34 | def main(): 35 | STATE_IDLE = -1 36 | state = STATE_IDLE 37 | initAccount = ext.GetAccount() 38 | while True: 39 | if state == STATE_IDLE : 40 | n = ext.Cross(FastPeriod,SlowPeriod) # 指标交叉函数 41 | if abs(n) >= EnterPeriod : 42 | opAmount = _N(initAccount.Stocks * PositionRatio,3) 43 | Dict = ext.Buy(opAmount) if n > 0 else ext.Sell(opAmount) 44 | if Dict : 45 | opAmount = Dict['amount'] 46 | state = PD_LONG if n > 0 else PD_SHORT 47 | Log("开仓详情",Dict,"交叉周期",n) 48 | else: 49 | n = ext.Cross(ExitFastPeriod,ExitSlowPeriod) # 指标交叉函数 50 | if abs(n) >= ExitPeriod and ((state == PD_LONG and n < 0) or (state == PD_SHORT and n > 0)) : 51 | nowAccount = ext.GetAccount() 52 | Dict2 = ext.Sell(nowAccount.Stocks - initAccount.Stocks) if state == PD_LONG else ext.Buy(initAccount.Stocks - nowAccount.Stocks) 53 | state = STATE_IDLE 54 | nowAccount = ext.GetAccount() 55 | LogProfit(nowAccount.Balance - initAccount.Balance,'钱:',nowAccount.Balance,'币:',nowAccount.Stocks,'平仓详情:',Dict2,'交叉周期:',n) 56 | Sleep(Interval * 1000) 57 | 58 | 59 | ``` 60 | 61 | > 策略出处 62 | 63 | https://www.fmz.com/strategy/21157 64 | 65 | > 更新时间 66 | 67 | 2016-09-30 23:25:18 68 | -------------------------------------------------------------------------------- /均线策略范例02.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 均线策略范例02 5 | 6 | > 策略作者 7 | 8 | 小小梦 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (麦语言) 15 | 16 | ``` pascal 17 | M5H^^MA(H,5); 18 | M5L^^MA(L,5); 19 | C>M5H,BPK; 20 | C0,SP; 22 | C>MA(C,5) AND SKVOL>0,BP; 23 | AUTOFILTER; 24 | ``` 25 | 26 | > 策略出处 27 | 28 | https://www.fmz.com/strategy/156699 29 | 30 | > 更新时间 31 | 32 | 2019-07-12 10:23:45 33 | -------------------------------------------------------------------------------- /基于ATR波动率指标构建的通道策略Channel-strategy-based-on-ATR.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 基于ATR波动率指标构建的通道策略Channel-strategy-based-on-ATR 5 | 6 | > 策略作者 7 | 8 | 阿基米德的浴缸 9 | 10 | > 策略描述 11 | 12 | [trans] 13 | - 名称: 基于ATR波动率指标构建的通道策略 14 | - 思路:通道自适应策略,固定止损+浮动止盈 15 | - 数据周期:多周期 16 | - OKEX期货 17 | - 合约 : this_week 当周 18 | - 官方网站:www.quantinfo.com 19 | 20 | ![IMG](https://www.fmz.com/upload/asset/b2ebaacbe7dbb1bb45bb59ceb80dd37f.png) 21 | 22 | - 主图: 23 | 画UBAND, 公式:UBAND^^MAC+M*ATR; 24 | 画DBAND, 公式:DBAND^^MAC-M*ATR; 25 | 26 | - 副图: 27 | 无 28 | 29 | || 30 | 31 | - Strategy name: Channel strategy based on ATR volatility index 32 | - Strategy idea: Channel Adaptive Strategy, Fixed Stop + Floating Stop 33 | - Data Cycle: Multi-Cycle 34 | 35 | ![IMG](https://www.fmz.com/upload/asset/24c0c7b896060cf639540b56028e8d99.png) 36 | ![IMG](https://www.fmz.com/upload/asset/e403406e31b9a3ca04da6ce76e3abe2d.png) 37 | 38 | - Main chart: 39 | Draw UBAND, formula: UBAND ^^ MAC + MATR; 40 | Draw DBAND, formula: DBAND ^^ MAC-MATR; 41 | 42 | - Secondary chart: 43 | none 44 | 45 | [/trans] 46 | 47 | > 策略参数 48 | 49 | 50 | 51 | |参数|默认值|描述| 52 | |----|----|----| 53 | |SLOSS|2|止损百分比|stop loss percentage| 54 | |N|200|ATR指标参数|ATR index parameter| 55 | |M|4|上下轨系数|upper and lower track coefficients| 56 | 57 | 58 | > 源码 (麦语言) 59 | 60 | ``` pascal 61 | (*backtest 62 | start: 2018-06-01 00:00:00 63 | end: 2018-07-01 00:00:00 64 | period: 1h 65 | exchanges: [{"eid":"Futures_OKCoin","currency":"BTC_USD"}] 66 | args: [["TradeAmount",10,126961],["ContractType","this_week",126961]] 67 | *) 68 | 69 | TR1:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW)); 70 | ATR:=MA(TR1,N); 71 | MAC:=MA(C,N); 72 | UBAND^^MAC+M*ATR; 73 | DBAND^^MAC-M*ATR; 74 | H>=HHV(H,N),BPK; 75 | L<=LLV(L,N),SPK; 76 | (H>=HHV(H,M*N) OR C<=UBAND) AND BKHIGH>=BKPRICE*(1+M*SLOSS*0.01),SP; 77 | (L<=LLV(L,M*N) OR C>=DBAND) AND SKLOW<=SKPRICE*(1-M*SLOSS*0.01),BP; 78 | // 止损 79 | // stop loss 80 | C>=SKPRICE*(1+SLOSS*0.01),BP; 81 | C<=BKPRICE*(1-SLOSS*0.01),SP; 82 | AUTOFILTER; 83 | ``` 84 | 85 | > 策略出处 86 | 87 | https://www.fmz.com/strategy/128126 88 | 89 | > 更新时间 90 | 91 | 2018-12-18 12:55:34 92 | -------------------------------------------------------------------------------- /多平台强制滑动平仓买一价.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 多平台强制滑动平仓买一价 5 | 6 | > 策略作者 7 | 8 | Zero 9 | 10 | > 策略描述 11 | 12 | 支持多平台一块平仓, 有多少币卖多少币 13 | 14 | > 策略参数 15 | 16 | 17 | 18 | |参数|默认值|描述| 19 | |----|----|----| 20 | |RetryInterval|5|尝试间隔(秒)| 21 | |SlidePrice|0.3|滑动值| 22 | |KeepStock|false|保留币数| 23 | 24 | 25 | > 源码 (javascript) 26 | 27 | ``` javascript 28 | function cancelAllOrders() { 29 | var orders = null; 30 | while (!(orders = exchange.GetOrders())) { 31 | Sleep(Interval); 32 | } 33 | 34 | if (orders.length > 0) { 35 | for (var j = 0; j < orders.length; j++) { 36 | exchange.CancelOrder(orders[j].Id); 37 | if (j < (orders.length-1)) { 38 | Sleep(2000); 39 | } 40 | } 41 | } 42 | } 43 | 44 | function sellAll() { 45 | cancelAllOrders(); 46 | var initAccount = _C(exchange.GetAccount); 47 | Log(exchange.GetName(), exchange.GetCurrency(), initAccount); 48 | if (initAccount.Stocks == 0) { 49 | Log("空仓"); 50 | return; 51 | } 52 | var remaind = initAccount.Stocks - KeepStock; 53 | var account = initAccount; 54 | while (remaind >= 0.001) { 55 | var ticker = _C(exchange.GetTicker); 56 | exchange.Sell(ticker.Buy - SlidePrice, remaind); 57 | Sleep(RetryInterval * 1000); 58 | cancelAllOrders(); 59 | account = _C(exchange.GetAccount); 60 | remaind = account.Stocks - KeepStock; 61 | } 62 | Log("平均卖出价", (account.Balance - initAccount.Balance) / (initAccount.Stocks - account.Stocks)); 63 | Log(account); 64 | } 65 | 66 | function main() { 67 | for (var i = 0; i < exchanges.length; i++) { 68 | exchange = exchanges[i]; 69 | sellAll(); 70 | } 71 | } 72 | 73 | 74 | ``` 75 | 76 | > 策略出处 77 | 78 | https://www.fmz.com/strategy/99 79 | 80 | > 更新时间 81 | 82 | 2018-03-27 15:55:26 83 | -------------------------------------------------------------------------------- /多线程获取多个交易的深度信息.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 多线程获取多个交易的深度信息 5 | 6 | > 策略作者 7 | 8 | Zero 9 | 10 | > 策略描述 11 | 12 | 多线程获取多个交易的深度信息 13 | 14 | 15 | 16 | > 源码 (javascript) 17 | 18 | ``` javascript 19 | function main() { 20 | var depths = []; 21 | while (true) { 22 | for (var i = 0; i < exchanges.length; i++) { 23 | if (depths[i] == null) { 24 | // 创建异步操作 25 | depths[i] = exchanges[i].Go("GetDepth"); 26 | } 27 | } 28 | var failed = 0; 29 | for (var i = 0; i < exchanges.length; i++) { 30 | if (typeof(depths[i].wait) != "undefined") { 31 | // 等待结果 32 | var ret = depths[i].wait(); 33 | if (ret) { 34 | depths[i] = ret; 35 | Log(exchanges[i].GetName(), depths[i]); 36 | } else { 37 | // 重试 38 | depths[i] = null; 39 | failed++; 40 | } 41 | } 42 | } 43 | if (failed == 0) { 44 | break; 45 | } else { 46 | Sleep(100); 47 | } 48 | } 49 | } 50 | 51 | ``` 52 | 53 | > 策略出处 54 | 55 | https://www.fmz.com/strategy/3651 56 | 57 | > 更新时间 58 | 59 | 2015-01-02 17:18:36 60 | -------------------------------------------------------------------------------- /多线程获取多个交易的账户信息.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 多线程获取多个交易的账户信息 5 | 6 | > 策略作者 7 | 8 | Zero 9 | 10 | > 策略描述 11 | 12 | 多线程获取多个交易的账户信息 13 | 14 | 15 | 16 | > 源码 (javascript) 17 | 18 | ``` javascript 19 | function main() { 20 | var accounts = []; 21 | while (true) { 22 | for (var i = 0; i < exchanges.length; i++) { 23 | if (accounts[i] == null) { 24 | // 创建异步操作 25 | accounts[i] = exchanges[i].Go("GetAccount"); 26 | } 27 | } 28 | var failed = 0; 29 | for (var i = 0; i < exchanges.length; i++) { 30 | if (typeof(accounts[i].wait) != "undefined") { 31 | // 等待结果 32 | var ret = accounts[i].wait(); 33 | if (ret) { 34 | accounts[i] = ret; 35 | Log(exchanges[i].GetName(), accounts[i]); 36 | } else { 37 | // 重试 38 | accounts[i] = null; 39 | failed++; 40 | } 41 | } 42 | } 43 | if (failed == 0) { 44 | break; 45 | } else { 46 | Sleep(100); 47 | } 48 | } 49 | } 50 | ``` 51 | 52 | > 策略出处 53 | 54 | https://www.fmz.com/strategy/3297 55 | 56 | > 更新时间 57 | 58 | 2014-12-11 03:56:53 59 | -------------------------------------------------------------------------------- /奥克量化-JS对接FMZ扩展API-Demo.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 奥克量化-JS对接FMZ扩展API-Demo 5 | 6 | > 策略作者 7 | 8 | 奥克量化 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (javascript) 15 | 16 | ``` javascript 17 | 18 | var URL = "https://www.fmz.com/api/v1?"; 19 | var AK = "b3a53d3XXXXXXXXXXXXXXXXXXX866fe5";//这里替换成你自己的AccessKey 20 | var SK = "1d9ddd7XXXXXXXXXXXXXXXXXXX85be17";//这里替换成你自己的SecretKey 21 | 22 | //获取基础5个参数的对象 23 | function getParam(version,ak,args){ 24 | return { 25 | 'version': version, 26 | 'access_key': ak, 27 | 'method': 'GetNodeList', 28 | 'args': JSON.stringify(args), 29 | 'nonce': new Date().getTime() 30 | } 31 | } 32 | 33 | //执行md5加密 34 | function md5(param){ 35 | var paramUrl = param.version+"|"+param.method+"|"+param.args+"|"+param.nonce+"|"+SK 36 | Log("paramUrl:",paramUrl); 37 | return Hash("md5", "hex", paramUrl) 38 | } 39 | 40 | //获取最终请求URL 41 | function getFinalUrl(param){ 42 | return URL+"access_key="+AK+"&nonce="+param.nonce+"&args="+param.args+"&sign="+param.sign+"&version="+param.version+"&method="+param.method; 43 | } 44 | 45 | //js中不支持...args的命名方式,所以改用arguments关键字获取参数数组 46 | function getArgs(){ 47 | return [].slice.call(arguments); 48 | } 49 | 50 | function main() { 51 | //获取5个基础参数对象 52 | var param = getParam("1.0.0",AK,getArgs()); 53 | Log("param:",param); 54 | //获取拼接参数md5加密后的结果 55 | var md5Result = md5(param); 56 | //赋值加密结果到基础参数对象中 57 | param.sign = md5Result; 58 | //获取请求api的URL 59 | var finalUrl = getFinalUrl(param); 60 | Log("finalUrl:",finalUrl); 61 | //执行请求并打印结果 62 | var info = HttpQuery(finalUrl); 63 | Log("info:",info); 64 | } 65 | ``` 66 | 67 | > 策略出处 68 | 69 | https://www.fmz.com/strategy/208065 70 | 71 | > 更新时间 72 | 73 | 2020-05-16 21:35:13 74 | -------------------------------------------------------------------------------- /定投新手入门每周100USDT-定期定额-100USDT-Invested-Every-Week-Regular-Fixed-Investment.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 定投新手入门每周100USDT-定期定额-100USDT-Invested-Every-Week-Regular-Fixed-Investment 5 | 6 | > 策略作者 7 | 8 | jfyh5388 9 | 10 | > 策略描述 11 | 12 | 每周定投100USDT,定期定额 13 | 14 | 15 | 16 | > 源码 (python) 17 | 18 | ``` python 19 | def main(): 20 | amountAll = 0 #持有总量 21 | cost = 0 #成本 22 | marketValueCurrent = 0 #当前持有总市值 23 | rateOfReturn = 0 #收益率 24 | while True: 25 | ticker = exchange.GetTicker() 26 | price = ticker['Last'] #获得当前价格 27 | amount = 100 / price #计算本次买入量 28 | exchange.Buy(price,amount) #买入 29 | amountAll = amountAll + amount #计算持有总量 30 | cost = cost + 100 #计算总成本 31 | marketValueCurrent = amountAll * price #计算当前持有总市值 32 | rateOfReturn = (marketValueCurrent - cost) / cost #计算收益率 33 | Log("此次投入金额:", 100, "本金:", cost, "当前总市值:", marketValueCurrent, "收益率:", rateOfReturn * 100,"%","当前价格",price) 34 | Sleep(7 * 24 * 60 * 60 * 1000) #等待一周 35 | 36 | ``` 37 | 38 | > 策略出处 39 | 40 | https://www.fmz.com/strategy/260013 41 | 42 | > 更新时间 43 | 44 | 2021-04-06 08:35:55 45 | -------------------------------------------------------------------------------- /定投新手入门每周100USDT左右-定期不定额-100USDT-Invested-Every-Week-Regular-Variable-Investment.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 定投新手入门每周100USDT左右-定期不定额-100USDT-Invested-Every-Week-Regular-Variable-Investment 5 | 6 | > 策略作者 7 | 8 | jfyh5388 9 | 10 | > 策略描述 11 | 12 | 每周定投100USDT左右,定期不定额,跌了多买,涨了少买,收益率优于定额 13 | 14 | 15 | 16 | > 源码 (python) 17 | 18 | ``` python 19 | def main(): 20 | amountAll = 0 #持有总量 21 | cost = 0 #成本 22 | marketValueCurrent = 0 #当前持有总市值 23 | marketValueExpected = 0 #当前期望总市值 24 | rateOfReturn = 0 #收益率 25 | eachBuy = 100 26 | while True: 27 | marketValueExpected = marketValueExpected + eachBuy #计算当前期望总市值 28 | ticker = exchange.GetTicker() 29 | price = ticker['Last'] #获得当前价格 30 | amount = marketValueExpected / price - amountAll #计算本次买入量 31 | if amount > 0: 32 | exchange.Buy(price,amount) #买入 33 | else: 34 | amount = 0 35 | amountAll = amountAll + amount #计算持有总量 36 | cost = cost + amount * price #计算总成本 37 | marketValueCurrent = amountAll * price #计算当前持有总市值 38 | rateOfReturn = (marketValueCurrent - cost) / cost #计算收益率 39 | Log("此次投入金额:", amount * price, "本金:", cost,"当前总持有量", amountAll,"当前总市值:", marketValueCurrent, "收益率:", rateOfReturn * 100,"%" ,"当前价格:", price, ) 40 | Sleep(7 * 24 * 60 * 60 * 1000) #等待一周 41 | 42 | ``` 43 | 44 | > 策略出处 45 | 46 | https://www.fmz.com/strategy/260056 47 | 48 | > 更新时间 49 | 50 | 2021-04-16 16:54:06 51 | -------------------------------------------------------------------------------- /定投止盈脚本.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 定投止盈脚本 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |v_input_1|5|最大损失百分比| 19 | |v_input_2|3|止盈值| 20 | 21 | 22 | > 源码 (PineScript) 23 | 24 | ``` javascript 25 | //@version=4 26 | 27 | strategy("定投止盈", overlay=true) 28 | 29 | //定义最大损失百分比 30 | maxLossPercent = input(title="最大损失百分比", type=float,defval=5) 31 | 32 | //定义止盈数字 33 | stopProfitVal = input(title="止盈值", type=float, defval=3) 34 | 35 | //主力合约做多头头寸 36 | longCondition = crossover(open, close) //主力合约以开盘价横向突破收盘价做多 37 | 38 | if (longCondition) 39 | strategy.entry("Long", strategy.long, comment="Open Long") 40 | 41 | //止损条件 42 | //if (strategy.position_size > 0) 43 | //strategy.exit("Exit long", stop=strategy.position_avg_price * (1 - maxLossPercent/100)) 44 | 45 | //止盈条件 46 | profitExit = strategy.position_avg_price + stopProfitVal 47 | if (strategy.position_size > 0) 48 | strategy.exit("Exit long", limit = profitExit) 49 | 50 | ``` 51 | 52 | > 策略出处 53 | 54 | https://www.fmz.com/strategy/396182 55 | 56 | > 更新时间 57 | 58 | 2023-01-29 09:49:34 59 | -------------------------------------------------------------------------------- /定时撤单.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 定时撤单 5 | 6 | > 策略作者 7 | 8 | 亚瑟d 9 | 10 | > 策略描述 11 | 12 | 定时撤单 13 | 14 | > 策略参数 15 | 16 | 17 | 18 | |参数|默认值|描述| 19 | |----|----|----| 20 | |LoopInterval|30|轮询间隔(分)| 21 | 22 | 23 | > 源码 (javascript) 24 | 25 | ``` javascript 26 | // 回测环境 27 | /*backtest 28 | start: 2018-01-01 00:00:00 29 | end: 2018-08-01 11:00:00 30 | period: 1m 31 | exchanges: [{"eid":"Bitfinex","currency":"BTC_USD"}] 32 | */ 33 | 34 | 35 | 36 | // 撤单函数 37 | function CancelPendingOrders() { 38 | Sleep(1000); // 休眠 1秒 39 | var ret = false; 40 | while (true) { 41 | var orders = null; 42 | // 持续获取未成交订单数组,如果返回异常,则继续获取 43 | while (!(orders = exchange.GetOrders())) { 44 | Sleep(1000); // 休眠 1秒 45 | } 46 | if (orders.length == 0) { // 如果订单数组为空 47 | return ret; // 返回撤单状态 48 | } 49 | for (var j = 0; j < orders.length; j++) { // 遍历未成交订单数组 50 | exchange.CancelOrder(orders[j].Id); // 依次取消未成交订单 51 | ret = true; 52 | if (j < (orders.length - 1)) { 53 | Sleep(1000); // 休眠 1秒 54 | } 55 | } 56 | } 57 | } 58 | 59 | 60 | // 主函数 61 | function main() { 62 | while (true) { // 轮询模式 63 | CancelPendingOrders(); // 取消未成交的挂单 64 | Log(_C(exchange.GetAccount)); // 打印当前账户信息 65 | Sleep(LoopInterval * 60000); // 休眠 66 | } 67 | } 68 | ``` 69 | 70 | > 策略出处 71 | 72 | https://www.fmz.com/strategy/284760 73 | 74 | > 更新时间 75 | 76 | 2021-05-25 18:15:28 77 | -------------------------------------------------------------------------------- /定量分型速率交易策略-by泊宇量化.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 定量分型速率交易策略-by泊宇量化 5 | 6 | > 策略作者 7 | 8 | homily 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |len|35|len| 19 | 20 | 21 | > 源码 (麦语言) 22 | 23 | ``` pascal 24 | (*backtest 25 | start: 2019-01-01 00:00:00 26 | end: 2021-01-31 00:00:00 27 | period: 1h 28 | exchanges: [{"eid":"Futures_OKCoin","currency":"BTC_USD","fee":[0.05,0.05]}] 29 | args: [["TradeAmount",200,126961],["ContractType","quarter",126961]] 30 | *) 31 | 32 | //len:=35;//设计周期数 33 | liang:=INTPART(MONEYTOT*REF(C,1)/100)*0.5; 34 | 35 | hh^^HHV(H,len);//取一定周期内的最高价 36 | ll^^LLV(L,len);//取一定周期内的最低价 37 | hl2^^(hh+ll)/2;//最高价、最低价的平均值 38 | avg^^MA(hl2,5);//对平均值计算平滑移动均线 39 | 40 | ss:SLOPE(avg,len);// 对均线计算回归斜率 41 | 42 | ssREF(ss,1),BPK(liang);//当斜率变大说明行情动能不断增加,有上升趋势,平空做多 44 | AUTOFILTER; 45 | 46 | 47 | 48 | ``` 49 | 50 | > 策略出处 51 | 52 | https://www.fmz.com/strategy/183416 53 | 54 | > 更新时间 55 | 56 | 2021-02-08 13:47:31 57 | -------------------------------------------------------------------------------- /山寨币指数20180222基点1000.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 山寨币指数20180222基点1000 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | 疼痛及了山寨币对BTC价格指数,2018.02.22基点1000。新加入的山寨币会列出。 13 | 14 | 15 | 16 | > 源码 (python) 17 | 18 | ``` python 19 | #!/usr/bin/env python 20 | # -*- coding: utf-8 -*-coding 21 | import time 22 | import urllib2 23 | import json 24 | import pickle 25 | 26 | def updateTicker(): 27 | global index,initPrice 28 | ticker = json.loads(urllib2.urlopen('https://api.binance.com/api/v3/ticker/price',timeout=10).read()) 29 | change = [] 30 | for t in ticker: 31 | if t['symbol'][-3:] == 'BTC': 32 | if t['symbol'][:-3] in initPrice.keys(): 33 | change.append(float(t['price'])/initPrice[t['symbol'][:-3]]) 34 | else: 35 | initPrice[t['symbol'][:-3]] = float(t['price']) 36 | f=open('price.pkl','w') 37 | pickle.dump(initPrice,f,0) 38 | f.close() 39 | Log(t['symbol'][:-3],' added') 40 | if len(change)>0: 41 | index = 1000*sum(change)/len(change) 42 | 43 | 44 | 45 | initPrice = {} 46 | price = {} 47 | index = 1000 48 | try: 49 | f=open('price.pkl','r') 50 | initPrice=pickle.load(f) 51 | f.close() 52 | except: 53 | initPrice = {} 54 | Log('共计入山寨币:', len(initPrice)) 55 | def main(): 56 | while True: 57 | try: 58 | updateTicker() 59 | LogProfit(round(index,4)) 60 | except Exception as e: 61 | pass 62 | Sleep(3600000) 63 | 64 | ``` 65 | 66 | > 策略出处 67 | 68 | https://www.fmz.com/strategy/73461 69 | 70 | > 更新时间 71 | 72 | 2019-07-03 16:46:08 73 | -------------------------------------------------------------------------------- /币安websocket订阅永续合约行情信息.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 币安websocket订阅永续合约行情信息 5 | 6 | > 策略作者 7 | 8 | GCC 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | import json 18 | def main(): 19 | LogStatus("正在连接...") 20 | # client = Dial("wss://stream.binance.com:9443/stream?streams=btcusdt@aggTrade/ethusdt@aggTrade|reconnect=true") #多个交易对 21 | # client = Dial("wss://stream.binance.com:9443/ws/btcusdt@aggTrade|reconnect=true") #单个交易对 22 | # client = Dial("wss://dstream.binance.com/ws/btcusd_perp@aggTrade|reconnect=true") #币本位,ticker 23 | client = Dial("wss://fstream.binance.com/ws/btcusdt@aggTrade|reconnect=true") 24 | if not client: 25 | Log("连接失败, 程序退出") 26 | return 27 | while True: 28 | buf = client.read(-2) 29 | Log('tt',buf) 30 | if buf: 31 | obj = json.loads(buf) 32 | # Log(obj) 33 | # Log('交易对',obj['data']['s'], ' 价格', obj['data']['p']) #多个交易对 34 | Log(obj['p']) #测试 35 | Sleep(5000) 36 | client.close() 37 | ``` 38 | 39 | > 策略出处 40 | 41 | https://www.fmz.com/strategy/327491 42 | 43 | > 更新时间 44 | 45 | 2021-11-24 14:29:50 46 | -------------------------------------------------------------------------------- /币安出售所有山寨币.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 币安出售所有山寨币 5 | 6 | > 策略作者 7 | 8 | Zero 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |quoteZone|0|交易区: BTC|ETH|BNB|USDT| 19 | 20 | 21 | > 源码 (javascript) 22 | 23 | ``` javascript 24 | function main() { 25 | var quoteCurrency = ['BTC', 'ETH', 'BNB', 'USDT'][quoteZone]; 26 | Log("当前交易区", quoteCurrency); 27 | var symbols = JSON.parse(_C(HttpQuery, "https://api.binance.com/api/v1/exchangeInfo")).symbols; 28 | _.each(_C(exchange.GetAccount).Info.balances, function(ele) { 29 | if (ele.asset == quoteCurrency) { 30 | return 31 | } 32 | var totalV = parseFloat(ele.free) + parseFloat(ele.locked); 33 | if (totalV == 0) { 34 | return; 35 | } 36 | var cfg = _.findWhere(symbols, {symbol: ele.asset+quoteCurrency}); 37 | if (!cfg) { 38 | Log("没有找到", ele.asset, "交易对的配置", ele); 39 | return; 40 | } 41 | var filter = _.findWhere(cfg.filters, {filterType: "LOT_SIZE"}); 42 | if (!filter) { 43 | return; 44 | } 45 | 46 | var v = _N(parseInt(totalV/filter.stepSize)*filter.stepSize, cfg.baseAssetPrecision); 47 | if (v > 0) { 48 | Log(ele, "stepSize", filter.stepSize); 49 | exchange.IO("currency", ele.asset + "_"+quoteCurrency); 50 | while (true) { 51 | var orders = _C(exchange.GetOrders); 52 | _.each(orders, function(order) { 53 | exchange.CancelOrder(order.Id); 54 | }); 55 | if (orders.length == 0) { 56 | break; 57 | } 58 | } 59 | exchange.Sell(-1, v); 60 | Log(ele); 61 | } 62 | }); 63 | Log("操作完成, 当前", quoteCurrency, "数量", _C(exchange.GetAccount).Balance); 64 | } 65 | ``` 66 | 67 | > 策略出处 68 | 69 | https://www.fmz.com/strategy/97629 70 | 71 | > 更新时间 72 | 73 | 2018-06-11 17:56:50 74 | -------------------------------------------------------------------------------- /币安取消所有交易对未完成订单IO扩展示范Cancel-ALL-Binance-Orders.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 币安取消所有交易对未完成订单IO扩展示范Cancel-ALL-Binance-Orders 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | 币安取消所有交易对未完成订单,使用IO接口,可以当作学习IO接口连接为支持API接口的范例 13 | 14 | 15 | 16 | > 源码 (javascript) 17 | 18 | ``` javascript 19 | function cancellAll(){ 20 | try{ 21 | var openOrders = exchange.IO('api', 'GET', '/api/v3/openOrders'); 22 | for (var i=0; i 策略出处 45 | 46 | https://www.fmz.com/strategy/121549 47 | 48 | > 更新时间 49 | 50 | 2019-07-03 16:36:05 51 | -------------------------------------------------------------------------------- /币安合约BNB手续费抵扣-自动购买自动划转.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 币安合约BNB手续费抵扣-自动购买自动划转 5 | 6 | > 策略作者 7 | 8 | Xueqiu Bot 9 | 10 | > 策略描述 11 | 12 | Contact : ck@xueqiubot.com / WeChat@stay37 13 | 本策略为自动从合约账户划转USDT至现货账户购买BNB,将BNB转入合约账户抵扣手续费。 14 | 需提前添加bnb_usdt交易对 15 | 16 | 17 | 18 | > 源码 (python) 19 | 20 | ``` python 21 | # Contact : ck@xueqiubot.com / WeChat@stay37 22 | 23 | import time 24 | 25 | 26 | def supply_bnb(transfer_usdt,i): 27 | Log("当前BNB不足,补充BNB作为手续费抵扣") 28 | #获取当前BNB_USDT价格 29 | depth = _C(exchanges[i].GetDepth) 30 | #转出transfer_usdt个USDT 31 | timestamp = time.time() * 1000 32 | transfer = exchanges[i].IO("api","POST","/sapi/v1/futures/transfer","asset=USDT&amount="+str(transfer_usdt)+"&type=2×tamp=+"+str(timestamp)) 33 | time.sleep(1) 34 | #获取BNB深度 下单购买 35 | depth = _C(exchanges[i].GetDepth) 36 | buyamount = round(transfer_usdt / (depth.Asks[0].Price + 0.2) , 2) 37 | buyid = exchanges[i].Buy(round(depth.Asks[0].Price + 0.1 , 4) , buyamount) 38 | time.sleep(1) 39 | #查询购买结果 将购买后的BNB以及剩余的USDT转入合约账户 40 | acc = _C(exchanges[i].GetAccount) 41 | transfer_usdt = acc.Balance 42 | transfer_bnb = acc.Stocks 43 | timestamp = time.time() * 1000 44 | transfer = exchanges[i].IO("api","POST","/sapi/v1/futures/transfer","asset=USDT&amount="+str(transfer_usdt)+"&type=1×tamp=+"+str(timestamp)) 45 | transfer = exchanges[i].IO("api","POST","/sapi/v1/futures/transfer","asset=BNB&amount="+str(transfer_bnb)+"&type=1×tamp=+"+str(timestamp)) 46 | Log("BNB补充完成") 47 | 48 | 49 | 50 | 51 | def main(): 52 | if '合约账户内BNB不足': 53 | #transfer_usdt: 需要购买的usdt金额 54 | #i: bnb_usdt现货交易对的序号 55 | supply_bnb(transfer_usdt,i) 56 | 57 | ``` 58 | 59 | > 策略出处 60 | 61 | https://www.fmz.com/strategy/236437 62 | 63 | > 更新时间 64 | 65 | 2020-11-11 22:38:54 66 | -------------------------------------------------------------------------------- /币安合约websocket接口查询持仓账户范例.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 币安合约websocket接口查询持仓账户范例 5 | 6 | > 策略作者 7 | 8 | 小小梦 9 | 10 | > 策略描述 11 | 12 | ## 币安合约websocket接口查询持仓账户范例 13 | 14 | 币安文档:https://binance-docs.github.io/apidocs/delivery/cn/#e3ee8329c9 15 | 16 | 测试时添加配置之后的币安期货交易所对象。 17 | 18 | ![IMG](https://www.fmz.com/upload/asset/1677407ce69131d8047b.png) 19 | 20 | 21 | 22 | > 源码 (javascript) 23 | 24 | ``` javascript 25 | function main() { 26 | LogReset(1) 27 | var ws = null 28 | exchange.IO("base", "https://dapi.binance.com") 29 | var obj = exchange.IO("api", "POST", "/dapi/v1/listenKey") 30 | Log(obj, typeof(obj)) 31 | var listenKey = obj.listenKey 32 | Log("listenKey:", listenKey) 33 | var ts = new Date().getTime() 34 | ws = Dial("wss://dstream.binance.com/ws/" + String(listenKey)) 35 | while (1) { 36 | var arr = ["balance", "account", "position"] 37 | for (var i in arr) { 38 | var info = { 39 | "method": "REQUEST", 40 | "params": [ 41 | listenKey + "@" + arr[i] 42 | ], 43 | "id": ts 44 | } 45 | ws.write(JSON.stringify(info)) 46 | var ret = ws.read() 47 | Log(ret) 48 | Sleep(1000) 49 | } 50 | Sleep(1000) 51 | } 52 | } 53 | ``` 54 | 55 | > 策略出处 56 | 57 | https://www.fmz.com/strategy/242102 58 | 59 | > 更新时间 60 | 61 | 2020-12-15 15:25:46 62 | -------------------------------------------------------------------------------- /币安多交易对价格区间提醒.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 币安多交易对价格区间提醒 5 | 6 | > 策略作者 7 | 8 | 轻轻的云 9 | 10 | > 策略描述 11 | 12 | 因为Aicoin的IOS版不是会员,不能用了,没有价格提醒了,所以琢磨自己弄个。 13 | 14 | 但是对代码实在是不懂弄,就照着梦大的代码复制粘贴了一通, https://www.fmz.com/digest-topic/8512 15 | 我英文不好,所以上限下限我用的拼音,其他的英文都是复制梦大的。[呲牙] 16 | 感谢梦大[抱拳][握手]!!! 17 | 18 | 有知道还有什么APP可以像Aicoin那样提醒价格帮忙告诉小弟一下,谢谢。 19 | 20 | 这个默认是合约交易的,支持USDT BUSD。设置上限下限,最新价高于上限或者低于下限就会发送消息通知。 21 | 如果需要现货的,在参数中把【合约交易】的对勾去掉就可以了。然后添加交易所选择现货币安。 22 | 需要把FMZ绑定推送,我是绑定的QQ邮箱,然后QQ邮箱设置特殊提示音,同时绑定微信,就会有两次提醒了。 23 | 24 | > 策略参数 25 | 26 | 27 | 28 | |参数|默认值|描述| 29 | |----|----|----| 30 | |B_sleeptime|30|轮询时间(秒)| 31 | |symbols|ETH_BUSD,ETC_USDT,LTC_USDT|交易对| 32 | |B_shangxian|3000,100,200|价格上限| 33 | |B_xiaxian|2000,50,100|价格下限| 34 | |B_heyue|true|合约交易| 35 | 36 | 37 | > 源码 (javascript) 38 | 39 | ``` javascript 40 | var arrSymbols = symbols.split(",") 41 | var arrshangxian = B_shangxian.split(",") 42 | var arrxiaxian = B_xiaxian.split(",") 43 | var shang = parseFloat(arrshangxian[i]) 44 | var xia = parseFloat(arrxiaxian[i]) 45 | 46 | function main() { 47 | if (B_chongzhi) { 48 | LogReset() 49 | LogVacuum() 50 | Log("重置所有数据", "#FF0000") 51 | } 52 | while (true) { 53 | for (var i = 0; i < arrSymbols.length; i++) { 54 | var symbol = arrSymbols[i] 55 | if (B_heyue == true) { 56 | exchange.SetContractType("swap") 57 | } 58 | exchange.SetCurrency(symbol) 59 | var ticker = _C(exchange.GetTicker).Last 60 | Log("交易对:", symbol, "最新价:", ticker) 61 | if (ticker > shang || ticker < xia) { 62 | Log(symbol, "价格跳出区间,当前最新价格:", ticker, "#FF0000", "@") 63 | } 64 | Sleep(B_sleeptime * 1000) 65 | } 66 | Sleep(5 * 1000) 67 | 68 | } 69 | } 70 | ``` 71 | 72 | > 策略出处 73 | 74 | https://www.fmz.com/strategy/342165 75 | 76 | > 更新时间 77 | 78 | 2022-04-21 22:45:14 79 | -------------------------------------------------------------------------------- /币安小额资产转换.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 币安小额资产转换 5 | 6 | > 策略作者 7 | 8 | xunfeng91 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (javascript) 15 | 16 | ``` javascript 17 | //小额资产转换为BNB 18 | function autoswaptobnb() { 19 | var ret = exchange.IO("api", "POST", "/sapi/v1/asset/dust-btc") 20 | Sleep(100) 21 | var dustarr = [] 22 | 23 | for (var i = 0; i < ret.details.length; i++) { 24 | dustarr.push(ret.details[i].asset) 25 | } 26 | if (dustarr.length > 0) { 27 | Log("将进行小额资产转换", dustarr) 28 | var obj 29 | if (dustarr.length == 1) { 30 | obj = "asset=" + dustarr[0] + "×tamp=" + new Date().getTime() 31 | } 32 | if (dustarr.length > 1) { 33 | obj = "asset=" + dustarr[0] 34 | for (var i = 1; i < dustarr.length; i++) { 35 | obj = obj + "&asset=" + dustarr[i] 36 | } 37 | obj = obj + "×tamp=" + new Date().getTime() 38 | } 39 | var ret = exchange.IO("api", "POST", "/sapi/v1/asset/dust", obj) 40 | Log("小额资产转换完成") 41 | Log(ret) 42 | } 43 | } 44 | 45 | function main() { 46 | autoswaptobnb() 47 | } 48 | ``` 49 | 50 | > 策略出处 51 | 52 | https://www.fmz.com/strategy/385533 53 | 54 | > 更新时间 55 | 56 | 2022-10-08 18:05:14 57 | -------------------------------------------------------------------------------- /干货-下单量精度和价格精度-适用各个交易所.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 干货-下单量精度和价格精度-适用各个交易所 5 | 6 | > 策略作者 7 | 8 | 陈皮 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | from collections import Counter 18 | def GetAmountPrecision(): 19 | depth = _C(exchange.GetDepth) 20 | amountPrecisions = [] 21 | for ask in depth["Asks"]: 22 | i = ask["Amount"] 23 | amountPrecision = 0 24 | if str(i).count('.') == 1: 25 | amountPrecision = len(str(i).split(".")[1]) 26 | amountPrecisions.append(amountPrecision) 27 | amountPrecision = max(amountPrecisions) 28 | return amountPrecision 29 | 30 | def GetPricePrecision(): 31 | depth = _C(exchange.GetDepth) 32 | pricePrecisions = [] 33 | for ask in depth["Asks"]: 34 | j = ask["Price"] 35 | pricePrecision = 0 36 | if str(j).count('.') == 1: 37 | pricePrecision = len(str(j).split(".")[1]) 38 | pricePrecisions.append(pricePrecision) 39 | pricePrecision = Counter(pricePrecisions).most_common(1)[0][0] 40 | return pricePrecision 41 | ``` 42 | 43 | > 策略出处 44 | 45 | https://www.fmz.com/strategy/295680 46 | 47 | > 更新时间 48 | 49 | 2021-09-25 10:25:30 50 | -------------------------------------------------------------------------------- /干货-选币系统-选币因子.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 干货-选币系统-选币因子 5 | 6 | > 策略作者 7 | 8 | 陈皮 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | import numpy as np 18 | from scipy.stats import norm 19 | from sklearn import preprocessing 20 | import json 21 | 22 | #计算波动率因子值 23 | def GetAtrFactorService(records): 24 | atrlength = 14 25 | atrs = TA.ATR(records, atrlength) 26 | acs = sorted(range(len(atrs)), key=lambda k: atrs[k]) 27 | ac = acs[-1] 28 | arr_mean = np.mean(acs) 29 | arr_std = np.std(acs,ddof=1) 30 | p = norm.cdf(x=ac, loc=arr_mean, scale = arr_std) 31 | #P值越大,波动性越大 32 | atrFactor = _N(p,3) 33 | return atrFactor 34 | 35 | #计算机构的行为痕迹因子值 36 | def GetITFactorService(records): 37 | #本福特定律分布频数 38 | PN = [301, 176, 125, 97, 79, 67, 58, 51, 46] 39 | FN = [0, 0, 0, 0, 0, 0, 0, 0, 0] 40 | for i in range(len(records)): 41 | valume = records[i]['Volume']*10000 42 | strValume = str(valume) 43 | num = strValume[0] 44 | for j in range(len(FN)): 45 | key = j + 1 46 | if int(num) == key: 47 | FN[j] += 1 48 | if sum(FN) == 0: 49 | FN = PN 50 | X = 0 51 | for i in range(len(PN)): 52 | X += (FN[i] - PN[i])**2 53 | ITFactor = X 54 | #X 的数值越大,则成交量数据与本福特理想分布的偏离越大,机构的行为痕迹也越大 55 | return ITFactor 56 | 57 | #计算价格因子值 58 | def GetPriceFactorService(records): 59 | record = records[-1] 60 | price = record["Close"] 61 | PFactor = 1/price 62 | #PFactor数值越大,则价格越小 63 | return PFactor 64 | 65 | #标准化处理 --计算出来的因子值因为数量级不同,要进行标准化处理。暂不处理空值、异常值 66 | def StandardizedService(factor): 67 | # 标准化处理 68 | factorArray = np.asarray(factor) 69 | factorArray = preprocessing.scale(factorArray) 70 | factor = factorArray.tolist() 71 | 72 | ext.GetAtrFactorService = GetArtFactorService 73 | ext.GetITFactorService = GetITFactorService 74 | ext.GetPriceFactorService = GetPriceFactorService 75 | ext.StandardizedService = StandardizedService 76 | ``` 77 | 78 | > 策略出处 79 | 80 | https://www.fmz.com/strategy/344801 81 | 82 | > 更新时间 83 | 84 | 2022-02-12 11:17:18 85 | -------------------------------------------------------------------------------- /当周季度差价画图插件.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 当周季度差价画图插件 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | 可画出季度-当周的差价图,用于对冲分析 13 | 14 | 插件可以在交易终端一键启动,不收取费用,方便手动交易。详细介绍:https://www.fmz.com/digest-topic/5051 15 | 16 | 17 | 18 | > 源码 (javascript) 19 | 20 | ``` javascript 21 | 22 | var chart = { 23 | __isStock: true, 24 | title : { text : '差价分析图'}, 25 | xAxis: { type: 'datetime'}, 26 | yAxis : { 27 | title: {text: '差价'}, 28 | opposite: false, 29 | }, 30 | series : [ 31 | {name : "diff", data : []}, 32 | 33 | ] 34 | } 35 | function main() { 36 | exchange.SetContractType('quarter') 37 | var recordsA = exchange.GetRecords(PERIOD_M5) 38 | exchange.SetContractType('this_week') 39 | var recordsB = exchange.GetRecords(PERIOD_M5) 40 | 41 | for(var i=0;i 策略出处 50 | 51 | https://www.fmz.com/strategy/187755 52 | 53 | > 更新时间 54 | 55 | 2020-03-24 10:52:17 56 | -------------------------------------------------------------------------------- /把USDT从合约账户划转到现货-资金账户OKEX币安同时支持.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 把USDT从合约账户划转到现货-资金账户OKEX币安同时支持 5 | 6 | > 策略作者 7 | 8 | 夏天不打你 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (javascript) 15 | 16 | ``` javascript 17 | function main() { 18 | transferToMain(100); 19 | } 20 | 21 | // 从U本位合约钱包向现货钱包划转指定数量的USDT 22 | function transferToMain(amount){ 23 | var ret = null; 24 | if (isOKexExchange()) { 25 | let param = "ccy=USDT" + "&from=18" + "&amt=" + amount.toString() + "&to=6"; 26 | ret = exchange.IO("api", "POST", "/api/v5/asset/transfer", param); 27 | } else if (isBinanceExchange()) { 28 | let time = UnixNano() / 1000000; 29 | let param = "type=UMFUTURE_MAIN" + "&asset=USDT" + "&amount=" + amount.toString() + "×tamp=" + time.toString(); 30 | exchange.SetBase('https://api.binance.com'); 31 | ret = exchange.IO("api", "POST", "/sapi/v1/asset/transfer", param); 32 | exchange.SetBase('https://fapi.binance.com'); 33 | } else { 34 | Log("资金划转失败,不支持的交易所!"); 35 | } 36 | if (ret) { 37 | Log("已经从合约划转到现货账户: ", amount, " USDT"); 38 | return true; 39 | } else { 40 | Log("资金划转失败!"); 41 | return false; 42 | } 43 | } 44 | 45 | // 判断是否币安交易所 46 | function isBinanceExchange() { 47 | if (exchange.GetName() == "Futures_Binance") { 48 | return true; 49 | } 50 | return false; 51 | } 52 | 53 | // 判断是否OKEX交易所 54 | function isOKexExchange() { 55 | if (exchange.GetName() == "Futures_OKCoin") { 56 | return true; 57 | } 58 | return false; 59 | } 60 | ``` 61 | 62 | > 策略出处 63 | 64 | https://www.fmz.com/strategy/338145 65 | 66 | > 更新时间 67 | 68 | 2021-12-30 16:11:11 69 | -------------------------------------------------------------------------------- /数字货币定投.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 数字货币定投 5 | 6 | > 策略作者 7 | 8 | ankye 9 | 10 | > 策略描述 11 | 12 | 数字货币通用定投策略,支持多交易所同时定投 13 | 14 | # 参数说明 15 | orderAmount #定投金额 BTCCNY和BCCCNY 单位 CNY, BCCBTC 单位 BTC 等等 16 | 17 | accountLimitMoney #账户限额,保留一部分钱,账户达到最低限额就停止定投 18 | 19 | 20 | orderTimeInterval #定投间隔,单位秒, 每分钟=60 每小时= 3600 每天=86400 每周=604800 21 | 22 | maxBidPrice #最大交易价格,超过价格就跳过,等待下次交易机会出现 23 | 24 | > 策略参数 25 | 26 | 27 | 28 | |参数|默认值|描述| 29 | |----|----|----| 30 | |orderAmount|true|order amount| 31 | |maxBidPrice|false|max bid price| 32 | |accountLimitMoney|false|account limit money| 33 | |orderTimeInterval|60|Order Time Interval| 34 | 35 | 36 | > 源码 (python) 37 | 38 | ``` python 39 | def onTick(): 40 | 41 | exchange_count = len(exchanges) 42 | for i in range(exchange_count): 43 | account = exchanges[i].GetAccount() 44 | 45 | marketName = exchanges[i].GetName() 46 | depth = exchanges[i].GetDepth() 47 | Log("Market ",marketName,exchanges[i].GetCurrency(),"Account Balance [",account["Balance"],"] Stocks[",account["Stocks"],"]") 48 | if account and depth and account["Balance"] > accountLimitMoney : 49 | bidPrice = depth["Asks"][0]["Price"] 50 | if bidPrice < maxBidPrice : 51 | amount = orderAmount 52 | if amount <= account["Balance"]: 53 | exchanges[i].Buy(amount) 54 | else: 55 | Log("Account Balance is less than bid Amount") 56 | else: 57 | Log("Bid Price >= maxBidPrice, not process") 58 | else: 59 | Log("Account Balance <= accountLimitMoney") 60 | def main() : 61 | while 1: 62 | 63 | onTick() 64 | time.sleep(orderTimeInterval) 65 | ``` 66 | 67 | > 策略出处 68 | 69 | https://www.fmz.com/strategy/54256 70 | 71 | > 更新时间 72 | 73 | 2017-09-08 14:43:38 74 | -------------------------------------------------------------------------------- /数字货币期货切换全仓逐仓插件.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 数字货币期货切换全仓逐仓插件 5 | 6 | > 策略作者 7 | 8 | 小小梦 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |type|0|全仓/逐仓模式: 逐仓|全仓| 19 | 20 | 21 | > 源码 (javascript) 22 | 23 | ``` javascript 24 | function main() { 25 | var posType = [false, true][type] 26 | var name = exchange.GetName() 27 | if (name == "Futures_Binance") { 28 | exchange.IO("cross", posType) 29 | } else if (name == "Futures_HuobiDM") { 30 | exchange.IO("cross", posType) 31 | } else if (name == "Futures_Bibox") { 32 | exchange.IO("cross", posType) 33 | } else if (name == "Futures_Bitget") { 34 | exchange.IO("cross", posType) 35 | } else if (name == "Futures_AOFEX") { 36 | exchange.IO("cross", posType) 37 | } else { 38 | throw "not support!" 39 | } 40 | return name + "切换 cross :" + posType 41 | } 42 | ``` 43 | 44 | > 策略出处 45 | 46 | https://www.fmz.com/strategy/351758 47 | 48 | > 更新时间 49 | 50 | 2022-03-18 18:55:24 51 | -------------------------------------------------------------------------------- /数字货币期货现货差价监控.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 数字货币期货现货差价监控 5 | 6 | > 策略作者 7 | 8 | 小小梦 9 | 10 | > 策略描述 11 | 12 | ## 数字货币期货现货差价监控 13 | 14 | 本策略为一个期货交易所和现货交易所之间差价监控的策略。 15 | 画图以10秒钟一次统计差价,画在图表上。 16 | 第一个添加的交易所为期货交易所。 17 | 第二个添加的交易所为现货交易所。 18 | 19 | 测试可以使用 BTC_USDT 交易对,进行测试。 20 | 默认期货交易所用火币DM合约的 季度合约,代码为: ```quarter``` 。 21 | 现货测试交易所用BIT-Z,交易对设置BTC_USDT。 22 | 23 | 测试演示、教学使用。 24 | 25 | > 策略参数 26 | 27 | 28 | 29 | |参数|默认值|描述| 30 | |----|----|----| 31 | |ContractType|quarter|期货合约| 32 | 33 | 34 | 35 | 36 | |按钮|默认值|描述| 37 | |----|----|----| 38 | |CMD_1|__button__|命令1| 39 | |CMD_2|命令2的字符串|命令2| 40 | 41 | 42 | > 源码 (javascript) 43 | 44 | ``` javascript 45 | function main () { 46 | LogReset(1) 47 | 48 | exchanges[0].SetContractType(ContractType) 49 | 50 | var lastPlotTime = 0 51 | while(true) { 52 | var ticker_futures = exchanges[0].GetTicker() 53 | var ticker_spot = exchanges[1].GetTicker() 54 | var diff = ticker_futures.Last - ticker_spot.Last 55 | 56 | LogStatus(_D(), "期货-现货,差价:", diff) 57 | var cmd = GetCommand() 58 | if (cmd) { 59 | Log("接收到命令:", cmd, "可以对该命令内容解析,触发自定义的函数执行!#FF0000") 60 | } 61 | 62 | var ts = new Date().getTime() 63 | if (ts - lastPlotTime > 1000 * 10) { 64 | $.PlotLine("差价(期货-现货)", diff) 65 | lastPlotTime = ts 66 | } 67 | 68 | Sleep(500) 69 | } 70 | } 71 | ``` 72 | 73 | > 策略出处 74 | 75 | https://www.fmz.com/strategy/164680 76 | 77 | > 更新时间 78 | 79 | 2019-09-02 14:57:48 80 | -------------------------------------------------------------------------------- /日志Logger.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 日志Logger 5 | 6 | > 策略作者 7 | 8 | fmzero 9 | 10 | > 策略描述 11 | 12 | 设置不同的level,控制日志输出等级 13 | 14 | > 策略参数 15 | 16 | 17 | 18 | |参数|默认值|描述| 19 | |----|----|----| 20 | |level|0|日志级别: 调试|信息|警告|错误| 21 | 22 | 23 | > 源码 (javascript) 24 | 25 | ``` javascript 26 | //var COLOR_ERROR = "#FF0000" 27 | //var COLOR_WARN = "#FF0000" 28 | //var COLOR_INFO = "#0000FF" 29 | //var COLOR_DEBUG = "#000000" 30 | var LEVER_PATTERN = { 31 | DEBUG: 0, 32 | INFO: 1, 33 | WARNING: 2, 34 | ERROR: 3 35 | } 36 | //var loggerLever = [LEVER_PATTERN.DEBUG, LEVER_PATTERN.INFO, LEVER_PATTERN.WARNING, LEVER_PATTERN.ERROR][level] 37 | $.Error = function(msg) { 38 | Log('[ERR] ', msg, '#FF0000') 39 | } 40 | 41 | $.Warn = function(msg) { 42 | if(level <= LEVER_PATTERN.WARNING) { 43 | Log('[WAR] ', msg, '#FF0000') 44 | } 45 | } 46 | 47 | $.Info = function(msg) { 48 | if(level <= LEVER_PATTERN.INFO) { 49 | Log('[INF] ', msg, '#0000FF') 50 | } 51 | } 52 | 53 | $.Debug = function(msg) { 54 | if(level <= LEVER_PATTERN.DEBUG) { 55 | Log('[DBG] ', msg, '#000000') 56 | } 57 | } 58 | 59 | function main() { 60 | $.Error('this is error') 61 | $.Warn('this is warn') 62 | $.Info('this is info') 63 | $.Debug('this is debug') 64 | } 65 | 66 | ``` 67 | 68 | > 策略出处 69 | 70 | https://www.fmz.com/strategy/151754 71 | 72 | > 更新时间 73 | 74 | 2020-01-20 10:17:59 75 | -------------------------------------------------------------------------------- /暴力马丁适合eth和btc-Copy.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 暴力马丁适合eth和btc-Copy 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | > 策略描述 11 | 12 | ETH 每600美元0.002手设置,一个月盈利50%,建议每两个月把盈利取出来,因为马丁最后的归宿就是爆仓,天下没有不爆仓的马丁,建议有3份资金,也就是1800美元使用,btc没测试,总之很暴力就是了 13 | 14 | > 策略参数 15 | 16 | 17 | 18 | |参数|默认值|描述| 19 | |----|----|----| 20 | |N|0.002|资金使用率或手数| 21 | |XX|true|加倍数值| 22 | |sssss|true|实盘参数系数2| 23 | 24 | 25 | > 源码 (麦语言) 26 | 27 | ``` pascal 28 | (*backtest 29 | start: 2022-01-01 08:00:00 30 | end: 2022-02-02 00:00:00 31 | period: 6h 32 | basePeriod: 1m 33 | exchanges: [{"eid":"Futures_Binance","currency":"ETH_USDT","balance":600,"fee":[0.008,0.025]}] 34 | args: [["RunMode",1,126961],["TradeAmount",0.001,126961],["MaxCacheLen",3000,126961],["ContractType","swap",126961],["MinLot",0.001,126961],["LoopInterval",1,126961],["SyncDelay",1,126961],["MarginLevel",50,126961]] 35 | *) 36 | 37 | 38 | 39 | 40 | TR:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW)); 41 | ATR:WMA(TR,10); //求26个周期内真实波幅的简单移动平均 42 | TC:N;//MAX(ROUND(5/C*MONEY/200,3),0.002);//手续费0.023,杠杆50倍 43 | yue:ABS(BKVOL+SKVOL); 44 | junjia:ABS(BKPRICEAV+SKPRICEAV); 45 | 46 | 47 | 48 | CCC^^WMA(C,20); 49 | AA^^WMA(C,10); 50 | 51 | 52 | 53 | BKVOL=0 AND SKVOL=0 AND REF(AA,1)>REF(CCC,1) , BK(TC); 54 | 55 | 56 | ISLASTBK AND C < BKPRICE-ATR*0.1 , BK(ROUND(XX*BKVOL,3)); 57 | 58 | 59 | BKVOL>0 AND C > BKPRICEAV+ATR*0.1 , SP(BKVOL); 60 | 61 | 62 | 63 | 64 | REF(AA,1)0,SP(BKVOL); 65 | INFO(REF(AA,1)0, '止损离场'); 66 | 67 | 68 | 69 | SKVOL=0 AND BKVOL=0 AND REF(AA,1) SKPRICE + 0.1*ATR, SK(ROUND(XX*SKVOL,3)); 74 | 75 | 76 | SKVOL>0 AND C < SKPRICEAV - 0.1*ATR , BP(SKVOL); 77 | 78 | 79 | 80 | 81 | 82 | REF(AA,1)>REF(CCC,1) AND SKVOL>0,BP(SKVOL); 83 | INFO(REF(AA,1)>REF(CCC,1)AND SKVOL>0 , '止损离场'); 84 | MULTSIG(0, 0, 50, 0); 85 | TRADE_AGAIN(100); 86 | ``` 87 | 88 | > 策略出处 89 | 90 | https://www.fmz.com/strategy/343745 91 | 92 | > 更新时间 93 | 94 | 2022-02-06 07:08:49 95 | -------------------------------------------------------------------------------- /期货一键对冲插件Hedge-on-two-contracts.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 期货一键对冲插件Hedge-on-two-contracts 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | 可自动立即对冲两个合约,注意加适当的滑价,可能会不成交。仓位较多可分多次点击. 13 | 14 | 插件可以在交易终端一键启动,不收取费用,方便手动交易。详细介绍:https://www.fmz.com/digest-topic/5051 15 | 16 | > 策略参数 17 | 18 | 19 | 20 | |参数|默认值|描述| 21 | |----|----|----| 22 | |Contract_A|this_week|交易合约A|Contract A| 23 | |Contract_B|quarter|交易合约B|Contract B| 24 | |Amount|10|开仓数量|Open Amount| 25 | |Slip|2|滑价|Slip Price| 26 | |Reverse|false|反向交易|Reverse Direction| 27 | 28 | 29 | > 源码 (javascript) 30 | 31 | ``` javascript 32 | 33 | function main(){ 34 | exchange.SetContractType(Reverse ? Contract_B : Contract_A) 35 | var ticker_A = exchange.GetTicker() 36 | if(!ticker_A){return 'Unable to get quotes'} 37 | exchange.SetDirection('buy') 38 | var id_A = exchange.Buy(ticker_A.Sell+Slip, Amount) 39 | exchange.SetContractType(Reverse ? Contract_B : Contract_A) 40 | var ticker_B = exchange.GetTicker() 41 | if(!ticker_B){return 'Unable to get quotes'} 42 | exchange.SetDirection('sell') 43 | var id_B = exchange.Sell(ticker_B.Buy-Slip, Amount) 44 | if(id_A){ 45 | exchange.SetContractType(Reverse ? Contract_B : Contract_A) 46 | exchange.CancelOrder(id_A) 47 | } 48 | if(id_B){ 49 | exchange.SetContractType(Reverse ? Contract_B : Contract_A) 50 | exchange.CancelOrder(id_B) 51 | } 52 | return 'Position: ' + JSON.stringify(exchange.GetPosition()) 53 | } 54 | 55 | ``` 56 | 57 | > 策略出处 58 | 59 | https://www.fmz.com/strategy/191348 60 | 61 | > 更新时间 62 | 63 | 2020-03-24 10:52:08 64 | -------------------------------------------------------------------------------- /期货一键平仓插件Cover-all-contracts.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 期货一键平仓插件Cover-all-contracts 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | 平该交易对下的所有期货仓位。 13 | 平仓方式:已平多仓为例,不断挂卖一卖出,0.5s后撤销,继续挂卖一,知道完全平仓。每次挂单量为当前所有可平仓位。 14 | 15 | 插件可以在交易终端一键启动,不收取费用,方便手动交易。详细介绍:https://www.fmz.com/digest-topic/5051 16 | 17 | 18 | 19 | > 源码 (javascript) 20 | 21 | ``` javascript 22 | 23 | function main(){ 24 | while(ture){ 25 | var pos = exchange.GetPosition() 26 | var ticker = exchange.GetTicekr() 27 | if(!ticker){return '无法获取ticker'} 28 | if(!pos || pos.length == 0 ){return '已无持仓'} 29 | for(var i=0;i 策略出处 54 | 55 | https://www.fmz.com/strategy/191363 56 | 57 | > 更新时间 58 | 59 | 2020-04-02 09:40:01 60 | -------------------------------------------------------------------------------- /查询结算单.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 查询结算单 5 | 6 | > 策略作者 7 | 8 | 扫地僧 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |QDate|20211025|日期| 19 | 20 | 21 | > 源码 (javascript) 22 | 23 | ``` javascript 24 | function main() { 25 | if (exchange.GetName() != 'Futures_CTP') { 26 | throw "只支持CTP前置机"; 27 | } 28 | r = exchange.IO("settlement", QDate); 29 | if (r) { 30 | return r.Content || r; 31 | } else { 32 | throw "没有数据"; 33 | } 34 | } 35 | ``` 36 | 37 | > 策略出处 38 | 39 | https://www.fmz.cn/strategy/38108 40 | 41 | > 更新时间 42 | 43 | 2021-11-01 15:38:16 44 | -------------------------------------------------------------------------------- /标准上涨五浪下跌五浪策略.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 标准上涨五浪下跌五浪策略 5 | 6 | > 策略作者 7 | 8 | Zer3192 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (PineScript) 15 | 16 | ``` javascript 17 | //@version=4 18 | // 标准上涨五浪下跌五浪策略 19 | // 顶1 20 | s1 = lowest(low, 5) 21 | // 底1 22 | b1 = highest(high, 5) 23 | // 顶2 24 | s2 = lowest(low[1], 5) 25 | // 底2 26 | b2 = highest(high[1], 5) 27 | // 顶3 28 | s3 = lowest(low[2], 5) 29 | // 底3 30 | b3 = highest(high[2], 5) 31 | // 顶4 32 | s4 = lowest(low[3], 5) 33 | // 底4 34 | b4 = highest(high[3], 5) 35 | // 顶5 36 | s5 = lowest(low[4], 5) 37 | // 底5 38 | b5 = highest(high[4], 5) 39 | 40 | // 上涨五浪 41 | up_waves = (b1 > b2) and (b2 > b3) and (b3 > b4) and (b4 > b5) 42 | // 下跌五浪 43 | down_waves = (s1 < s2) and (s2 < s3) and (s3 < s4) and (s4 < s5) 44 | 45 | // 交易条件 46 | if (up_waves) 47 | strategy.entry("long", strategy.long, 1, stop = low[4], comment = "long") 48 | 49 | else if (down_waves) 50 | strategy.entry("short", strategy.short, 1, stop = high[4], comment = "short") 51 | 52 | // 绘图 53 | plotshape(up_waves, style = shape.triangleup, location = location.belowbar, color=green, title="上涨五浪") 54 | plotshape(down_waves, style = shape.triangledown, location = location.abovebar, color=red, title="下跌五浪") 55 | 56 | ``` 57 | 58 | > 策略出处 59 | 60 | https://www.fmz.com/strategy/395584 61 | 62 | > 更新时间 63 | 64 | 2023-01-03 21:31:11 65 | -------------------------------------------------------------------------------- /标定值或均线交叉策略.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 标定值或均线交叉策略 5 | 6 | > 策略作者 7 | 8 | cyberking 9 | 10 | > 策略描述 11 | 12 | 标定值 13 | 高点> btc 10000 || MA(10)MA(30)则买入; 15 | Stoploss为8 , 8%止损点. 16 | 周期按日线.回测数据还可以;低于日线周期回测数据不好. 17 | 本策略是用的趋势指标. 18 | *取10000和6725的理由是根据江恩的思路. 19 | ![IMG](https://www.fmz.com/upload/asset/149338fe3f9011badc20c.png) ![IMG](https://www.fmz.com/upload/asset/14947231d56707e5f7e8c.png) 20 | 21 | > 策略参数 22 | 23 | 24 | 25 | |参数|默认值|描述| 26 | |----|----|----| 27 | |HGH|10000|高点| 28 | |MMD|6725|中坚点| 29 | |STOPLOSS|8|止损数| 30 | 31 | 32 | > 源码 (麦语言) 33 | 34 | ``` pascal 35 | (*backtest 36 | start: 2019-01-05 00:00:00 37 | end: 2020-02-29 00:00:00 38 | period: 1d 39 | exchanges: [{"eid":"Huobi","currency":"BTC_USDT"}] 40 | *) 41 | // 42 | MA10:=MA(C,10); 43 | MA30:=MA(C,30); 44 | 45 | 买入开仓价:=VALUEWHEN(BARSBK=1,O); 46 | 卖出开仓价:=VALUEWHEN(BARSSK=1,O); 47 | //开仓条件 48 | 49 | BUYCONDITION:=REF(C,1) < MMD OR CROSSUP(MA10,MA30); 50 | SELLCONDITION:=REF(C,1) > HGH OR CROSSDOWN(MA10,MA30); 51 | 52 | BKVOL=0 AND BUYCONDITION,BK; 53 | SKVOL=0 AND SELLCONDITION,SK; 54 | 55 | //离场条件 56 | BKVOL>0 AND SELLCONDITION,SP; 57 | SKVOL>0 AND BUYCONDITION,BP; 58 | // 启动止损 59 | SKVOL>0 AND HIGH>=卖出开仓价*(1+STOPLOSS*0.01),BP; 60 | BKVOL>0 AND LOW<=买入开仓价*(1-STOPLOSS*0.01),SP; 61 | AUTOFILTER; 62 | ``` 63 | 64 | > 策略出处 65 | 66 | https://www.fmz.com/strategy/187874 67 | 68 | > 更新时间 69 | 70 | 2020-03-02 11:22:35 71 | -------------------------------------------------------------------------------- /检查https-quantla-Argus-是否正常.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 检查https-quantla-Argus-是否正常 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | import urllib2 18 | def main(): 19 | Log("开始检查@") 20 | while True: 21 | try: 22 | urllib2.urlopen("https://quant.la/API/Argus/predict", timeout=15) 23 | Log("服务正常") 24 | except: 25 | Log(_D()," 服务异常@") 26 | Sleep(10*60*1000) 27 | 28 | ``` 29 | 30 | > 策略出处 31 | 32 | https://www.fmz.com/strategy/100344 33 | 34 | > 更新时间 35 | 36 | 2018-06-22 10:29:01 37 | -------------------------------------------------------------------------------- /模板库使用例子.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 模板库使用例子 5 | 6 | > 策略作者 7 | 8 | Zero 9 | 10 | > 策略描述 11 | 12 | 模板库使用例子 13 | 14 | > 策略参数 15 | 16 | 17 | 18 | |参数|默认值|描述| 19 | |----|----|----| 20 | |OType|0|买或卖: 买|卖| 21 | |Amount|0.5|下单量| 22 | 23 | 24 | > 源码 (javascript) 25 | 26 | ``` javascript 27 | 28 | function main() { 29 | Log(OType === 0 ? $.Buy(Amount) : $.Sell(Amount)); 30 | } 31 | ``` 32 | 33 | > 策略出处 34 | 35 | https://www.fmz.com/strategy/10991 36 | 37 | > 更新时间 38 | 39 | 2016-02-20 22:13:47 40 | -------------------------------------------------------------------------------- /每1分钟统计各个平台间的差价by-JackConan.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 每1分钟统计各个平台间的差价by-JackConan 5 | 6 | > 策略作者 7 | 8 | yzl_126@126.com 9 | 10 | > 策略描述 11 | 12 | 统计各个平台间的最大差价; 13 | 如果要打印当时各交易所的市场行情,可以把 //printCurPrice(); 前面的注释//去掉; 14 | 15 | 16 | 17 | > 源码 (javascript) 18 | 19 | ``` javascript 20 | var maxSpace = 0; 21 | 22 | function adjustFloat(v) { 23 | return Math.floor(v*1000)/1000; 24 | } 25 | 26 | function printCurPrice() { 27 | for (var i = 0; i < exchanges.length; i++) { 28 | Log(exchanges[i].GetName(),'=',exchanges[i].GetTicker()); 29 | } 30 | } 31 | 32 | function onTick() { 33 | // TODO something. 34 | var smallPrice = 99999; 35 | var bigPrice = 0; 36 | var curPrice = 0; 37 | var curSpace = 0; 38 | 39 | for (var i = 0; i < exchanges.length; i++) { 40 | curPrice = exchanges[i].GetTicker().Last; 41 | if (curPrice < smallPrice){ 42 | smallPrice = curPrice; 43 | } 44 | if (curPrice > bigPrice){ 45 | bigPrice = curPrice; 46 | } 47 | curSpace = bigPrice - smallPrice; 48 | } 49 | 50 | if (curSpace > maxSpace){ 51 | maxSpace = curSpace; 52 | //打印各交易所当前的市场行情; 53 | printCurPrice(); 54 | Log('有新高差价:', adjustFloat(maxSpace),'高价:', bigPrice,'低价:', smallPrice, '发生时间 →_→'); 55 | } 56 | Log('当前差价:', adjustFloat(curSpace),'高价:', bigPrice,'低价:', smallPrice,'最高差价:', adjustFloat(maxSpace)); 57 | } 58 | 59 | function main() { 60 | if (exchanges.length < 2) { 61 | Log("交易所数量最少得两个才能完成统计"); 62 | return; 63 | } 64 | while(true) { 65 | onTick(); 66 | Sleep(60000); 67 | } 68 | } 69 | ``` 70 | 71 | > 策略出处 72 | 73 | https://www.fmz.com/strategy/98 74 | 75 | > 更新时间 76 | 77 | 2014-07-20 14:52:55 78 | -------------------------------------------------------------------------------- /每日市价定投.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 每日市价定投 5 | 6 | > 策略作者 7 | 8 | cdxy 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |singleInvestAmount|true|市价买入| 19 | 20 | 21 | > 源码 (javascript) 22 | 23 | ``` javascript 24 | 25 | 26 | function main() { 27 | Log(exchange.GetAccount()); 28 | 29 | 30 | //最近一次投资的日期 31 | var lastInvestDate = ''; 32 | 33 | while (true) { 34 | //每次轮询,间隔时间为60秒 35 | Sleep(60 * 1000); 36 | 37 | //如果当前日期和最近一次投资日期相同,说明当天已经投过了,跳过 38 | var now = new Date(); 39 | var date = now.toISOString().slice(0,10); 40 | if (date == lastInvestDate) { 41 | continue; 42 | } 43 | 44 | lastInvestDate = date; 45 | Log("日期: " + date); 46 | 47 | 48 | exchange.Buy(-1, singleInvestAmount); 49 | } 50 | } 51 | 52 | ``` 53 | 54 | > 策略出处 55 | 56 | https://www.fmz.com/strategy/151259 57 | 58 | > 更新时间 59 | 60 | 2019-06-07 16:26:19 61 | -------------------------------------------------------------------------------- /永续合约一键市价平仓.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 永续合约一键市价平仓 5 | 6 | > 策略作者 7 | 8 | GCC 9 | 10 | > 策略描述 11 | 12 | 一键平所有永续合约仓位 13 | 14 | 15 | 16 | > 源码 (javascript) 17 | 18 | ``` javascript 19 | function main(){ 20 | exchange.SetContractType('swap') 21 | exchange.SetCurrency('BNB_USDT') 22 | Log(exchange.GetPosition()) 23 | acc = exchange.GetAccount() 24 | //Log(exchange.GetAccount().Info) 25 | var pos = exchange.GetAccount().Info.positions 26 | var positioned = false 27 | for(var i=0;i 策略出处 56 | 57 | https://www.fmz.com/strategy/322449 58 | 59 | > 更新时间 60 | 61 | 2022-03-25 10:48:05 62 | -------------------------------------------------------------------------------- /测试1111.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 测试1111 5 | 6 | > 策略作者 7 | 8 | Tayoji 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |b|0|b: a|b|c| 19 | |a|33|a| 20 | 21 | 22 | > 源码 (javascript) 23 | 24 | ``` javascript 25 | /*backtest 26 | start: 2017-02-22 00:00:00 27 | end: 2023-03-07 13:59:33 28 | period: 1h 29 | basePeriod: 1h 30 | exchanges: [{"eid":"Binance","currency":"BTC_USDT","balance":50001,"stocks":4,"feeder":"http://fmz.com","quotePrecision":1,"basePrecision":2,"depthDeep":3},{"eid":"Binance","currency":"LTC_USDT"}] 31 | mode: 1 32 | args: [["b",2],["za",3,362903],["zb",2,362903],["zc",4,362903]] 33 | */ 34 | 35 | 36 | 37 | function main() { 38 | Log(exchange.GetAccount()); 39 | } 40 | ``` 41 | 42 | > 策略出处 43 | 44 | https://www.fmz.com/strategy/403218 45 | 46 | > 更新时间 47 | 48 | 2023-03-09 10:30:06 49 | -------------------------------------------------------------------------------- /测试多图表展示Python版.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 测试多图表展示Python版 5 | 6 | > 策略作者 7 | 8 | 小小梦 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | import random 18 | import time 19 | def main(): 20 | cfgA = { 21 | "title" : {"text" : "盘口图表"}, 22 | "xAxis" : { 23 | "type" : "datetime" 24 | }, 25 | "series" : [{ 26 | "name" : "买一", 27 | "data" : [], 28 | },{ 29 | "name" : "卖一", 30 | "data" : [], 31 | }] 32 | } 33 | 34 | cfgB = { 35 | "title" : {"text" : "差价图"}, 36 | "xAxis" : { 37 | "type" : "datetime" 38 | }, 39 | "series" : [{ 40 | "name" : "差价", 41 | "type" : "column", 42 | "data" : [], 43 | }] 44 | } 45 | 46 | cfgC = { 47 | "__isStock" : False, 48 | "title" : { 49 | "text" : "饼图" 50 | }, 51 | "series" : [{ 52 | "type" : "pie", 53 | "name" : "one", 54 | "data" : [ 55 | ["A", 25], 56 | ["B", 25], 57 | ["C", 25], 58 | ["D", 25], 59 | ] 60 | }] 61 | } 62 | 63 | chart = Chart([cfgA, cfgB, cfgC]) 64 | chart.reset() 65 | chart.add(3, { 66 | "name" : "ZZ", 67 | "y" : random.random() * 100 68 | }) 69 | 70 | 71 | chart.update([cfgA, cfgB, cfgC]) 72 | chart.add(0, [_N(time.time() * 1000, 0), 50]) 73 | chart.add(1, [_N(time.time() * 1000, 0), 80]) 74 | chart.add(2, [_N(time.time() * 1000, 0), 90]) 75 | chart.add(3, { 76 | "name" : "ZZ", 77 | "y" : random.random() * 100 78 | }, -1) 79 | 80 | ``` 81 | 82 | > 策略出处 83 | 84 | https://www.fmz.com/strategy/84042 85 | 86 | > 更新时间 87 | 88 | 2018-03-30 22:20:34 89 | -------------------------------------------------------------------------------- /测试托管者与交易所服务器的真实网络延迟-支持同时测试多个交易所.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 测试托管者与交易所服务器的真实网络延迟-支持同时测试多个交易所 5 | 6 | > 策略作者 7 | 8 | Xueqiu Bot 9 | 10 | > 策略描述 11 | 12 | Contact : ck@xueqiubot.com / WeChat@stay37 13 | 本策略为测试托管者到服务器之间的真实网络延迟,测试方法为:对比发送请求的时间和收到结果的时间,多次取平均值。 14 | 支持多个交易所同时测试,添加不同交易平台即可,需要安装numpy模块。 15 | 16 | 17 | 18 | > 源码 (python) 19 | 20 | ``` python 21 | # Contact : ck@xueqiubot.com / WeChat@stay37 22 | 23 | import time 24 | import numpy as np 25 | 26 | 27 | def test(): 28 | #延迟数据接收器 29 | delay_list = [] 30 | for i in range(len(exchanges)): 31 | delay_list.append([]) 32 | while True: 33 | #延迟数据获取 34 | for i in range(len(exchanges)): 35 | send_t = time.time() 36 | ticker = exchanges[i].GetTicker() 37 | delay_list[i].append(round((time.time() - send_t) * 1000 , 2)) 38 | #数据输出 39 | delay_table = {"type":'table',"title":'延迟数据',"cols": ['账号序号','最近一次延迟','平均延迟','已测试次数'],"rows":[]} 40 | for i in range(len(delay_list)): 41 | delay_table['rows'].append([i + 1, str(delay_list[i][-1])+' ms', str(round(np.mean(delay_list[i]) , 2)) + ' ms', len(delay_list[i])]) 42 | LogStatus("输出的延迟为:发送一次get_ticker请求到获取到数据的真实时间" + "\n" + "`" + json.dumps(delay_table) + "`") 43 | time.sleep(0.05) 44 | 45 | 46 | def main(): 47 | for i in range(len(exchanges)): 48 | exchanges[i].SetContractType('swap') 49 | test() 50 | 51 | 52 | ``` 53 | 54 | > 策略出处 55 | 56 | https://www.fmz.com/strategy/236426 57 | 58 | > 更新时间 59 | 60 | 2021-01-10 19:22:52 61 | -------------------------------------------------------------------------------- /测试插件.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 测试插件 5 | 6 | > 策略作者 7 | 8 | Tayoji 9 | 10 | > 策略描述 11 | 12 | 13 | | head1 | head2 | head3 | 14 | | ------ | ------ | ------ | 15 | | column1 | column2 | column3 | 16 | | column1 | column2 | column3 | 17 | 18 | 19 | > 策略参数 20 | 21 | 22 | 23 | |参数|默认值|描述| 24 | |----|----|----| 25 | |a2|false|a2| 26 | |b|100|(?ssss)b| 27 | |c|20|c| 28 | |enc|$$$__enc__$$$accc|测试enc| 29 | |dd|233124|dd| 30 | |e2|$$$__enc__$$$123|e2| 31 | |aaax|0|(?sssss)描述f: a|b|c| 32 | |ffff|asdb|描述ffff| 33 | |affff|$$$__enc__$$$a|描述!!ffff| 34 | 35 | 36 | 37 | 38 | |按钮|默认值|描述| 39 | |----|----|----| 40 | |a|123|a| 41 | |c|123|c| 42 | 43 | 44 | > 源码 (javascript) 45 | 46 | ``` javascript 47 | /*backtest 48 | start: 2015-02-22 00:00:00 49 | end: 2023-02-01 17:29:50 50 | period: 30m 51 | basePeriod: 30m 52 | */ 53 | 54 | function main() { 55 | return exchange.GetName(); 56 | } 57 | ``` 58 | 59 | > 策略出处 60 | 61 | https://www.fmz.com/strategy/397743 62 | 63 | > 更新时间 64 | 65 | 2023-02-28 13:38:05 66 | -------------------------------------------------------------------------------- /测试默认参数组功能.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 测试默认参数组功能 5 | 6 | > 策略作者 7 | 8 | 小小梦 9 | 10 | > 策略描述 11 | 12 | ### 如何使用代码精确调整“回测系统默认设置” 13 | 14 | > 在策略的参数测试,不同时间段回测,多个标的物回测等,回测策略时由于参数需要反复调整,而且不能记录,下次回测时又要重新设置。平台为了方便参数调整,新增加功能 -- 使用代码精确调整“回测系统默认设置”。 15 | 16 | > 策略参数 17 | 18 | 19 | 20 | |参数|默认值|描述| 21 | |----|----|----| 22 | |number|9999|数字类型| 23 | |bool|true|布尔类型| 24 | |string|Hello World!|字符串类型| 25 | |comboBox|0|下拉框: combo1|combo2|combo3| 26 | 27 | 28 | > 源码 (javascript) 29 | 30 | ``` javascript 31 | /*backtest 32 | start: 2017-03-01 33 | end: 2017-03-02 34 | period: 15 35 | mode: 1 36 | */ 37 | 38 | /*defaults 39 | number : 0 40 | bool: false 41 | string: Hello BotVS! 42 | comboBox : 2 43 | */ 44 | 45 | function main(){ 46 | while(true){ 47 | LogStatus("测试默认参数!"); 48 | Sleep(1000); 49 | } 50 | } 51 | ``` 52 | 53 | > 策略出处 54 | 55 | https://www.fmz.com/strategy/40155 56 | 57 | > 更新时间 58 | 59 | 2021-07-02 16:33:15 60 | -------------------------------------------------------------------------------- /深度快照.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 深度快照 5 | 6 | > 策略作者 7 | 8 | 发明者量化 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (javascript) 15 | 16 | ``` javascript 17 | function main() { 18 | var tbl = { 19 | type: 'table', 20 | title: '深度快照 @ ' + _D(), 21 | cols: ['#', 'Amount', 'Ask', 'Bid', 'Amount'], 22 | rows: [] 23 | }; 24 | var d = exchange.GetDepth(); 25 | for (var i = 0; i < Math.min(Math.min(d.Asks.length, d.Bids.length), 15); i++) { 26 | tbl.rows.push([i, d.Asks[i].Amount, d.Asks[i].Price+'#ff0000', d.Bids[i].Price+'#0000ff', d.Bids[i].Amount]); 27 | } 28 | return tbl; 29 | } 30 | ``` 31 | 32 | > 策略出处 33 | 34 | https://www.fmz.com/strategy/187969 35 | 36 | > 更新时间 37 | 38 | 2020-03-01 23:49:04 39 | -------------------------------------------------------------------------------- /火币期货币币账户间资金划转范例.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 火币期货币币账户间资金划转范例 5 | 6 | > 策略作者 7 | 8 | 小小梦 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (javascript) 15 | 16 | ``` javascript 17 | function main() { 18 | // API 接口描述: 19 | // https://api.huobi.pro 20 | // POST /v1/futures/transfer 21 | // params currency e.g. btc 22 | // amount 23 | // type futures-to-pro 24 | 25 | Log(exchange.GetAccount()) 26 | var ret = exchange.IO("api", "POST", "/v1/futures/transfer", "currency=ltc&amount=0.1&type=pro-to-futures") // 测试的是LTC , 币币转期货 27 | Log("ret", ret) 28 | 29 | /* ret 30 | ret {"status":"ok","data":25669845} 31 | */ 32 | } 33 | ``` 34 | 35 | > 策略出处 36 | 37 | https://www.fmz.com/strategy/148532 38 | 39 | > 更新时间 40 | 41 | 2019-05-20 18:19:53 42 | -------------------------------------------------------------------------------- /火币点卡.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 火币点卡 5 | 6 | > 策略作者 7 | 8 | 一拳男孩 9 | 10 | > 策略描述 11 | 12 | - getHBPoints(exchange) 13 | > 获取火币点卡 14 | > 返回值,number类型 15 | 16 | 17 | 18 | > 源码 (javascript) 19 | 20 | ``` javascript 21 | $.getHBPoints = function(ex) { 22 | try { 23 | var accountRet = ex.IO("api", "GET", "/v1/account/accounts") 24 | if (accountRet && accountRet.data) { 25 | var account = _.findWhere(accountRet.data, { 26 | type: 'point' 27 | }) 28 | if (account && account.id) { 29 | var balanceRet = ex.IO("api", "GET", "/v1/account/accounts/" + account.id + "/balance") 30 | if (balanceRet && balanceRet.data && balanceRet.data.list) { 31 | var balance = _.reduce(balanceRet.data.list, function(p, n) { 32 | return new Decimal(p).plus(n.balance).toNumber() 33 | }, 0) 34 | return balance 35 | } 36 | } 37 | } 38 | } catch (e) {} 39 | return null 40 | } 41 | ``` 42 | 43 | > 策略出处 44 | 45 | https://www.fmz.com/strategy/162055 46 | 47 | > 更新时间 48 | 49 | 2019-08-13 22:05:07 50 | -------------------------------------------------------------------------------- /爬取币安公告永续新上币和下架币.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 爬取币安公告永续新上币和下架币 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (javascript) 15 | 16 | ``` javascript 17 | 18 | function main() { 19 | var last_news = '' 20 | while(true){ 21 | var html = HttpQuery('https://www.binance.com/en/support/announcement/c-49?navId=49') 22 | if(html){ 23 | var news = html.match(/Launch .{0,40} Perpetual|Delist.{0,40}-\d{1,2}/i) 24 | if(news && last_news != news[0]){ 25 | Log(news[0],'@') 26 | last_news = news[0] 27 | } 28 | } 29 | Sleep(60*1000) 30 | } 31 | } 32 | 33 | ``` 34 | 35 | > 策略出处 36 | 37 | https://www.fmz.com/strategy/311117 38 | 39 | > 更新时间 40 | 41 | 2023-02-26 21:08:49 42 | -------------------------------------------------------------------------------- /现货冰山委托买入插件Simple-Iceberg-order-to-buy-Copy.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 现货冰山委托买入插件Simple-Iceberg-order-to-buy-Copy 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | Very simple, just for learn. 13 | Code is best annotation. 14 | 15 | 冰山委托买入,将订单分成小笔M买入,避免冲击市场,是很好的简单入门比特币量化交易的学习策略 16 | 插件可以在交易终端一键启动,不收取费用,方便手动交易。详细介绍:https://www.fmz.com/digest-topic/5051 17 | 18 | > 策略参数 19 | 20 | 21 | 22 | |参数|默认值|描述| 23 | |----|----|----| 24 | |BUYAMOUNT|2|amount to buy| 25 | |BUYSIZE|0.1|iceberg order size| 26 | |INTERVAL|3|orders exist time(second)| 27 | 28 | 29 | > 源码 (javascript) 30 | 31 | ``` javascript 32 | function main(){ 33 | var initAccount = _C(exchange.GetAccount) 34 | while(true){ 35 | var account = _C(exchange.GetAccount) 36 | var dealAmount = account.Stocks - initAccount.Stocks 37 | var ticker = _C(exchange.GetTicker) 38 | if(BUYAMOUNT - dealAmount >= BUYSIZE){ 39 | var id = exchange.Buy(ticker.Sell, BUYSIZE) 40 | Sleep(INTERVAL*1000) 41 | if(id){ 42 | exchange.CancelOrder(id) // May cause error log when the order is completed, which is all right. 43 | }else{ 44 | throw 'buy error' 45 | } 46 | }else{ 47 | account = _C(exchange.GetAccount) 48 | var avgCost = (initAccount.Balance - account.Balance)/(account.Stocks - initAccount.Stocks) 49 | return 'Iceberg order to buy is done, avg cost is '+avgCost 50 | } 51 | 52 | } 53 | } 54 | ``` 55 | 56 | > 策略出处 57 | 58 | https://www.fmz.com/strategy/191771 59 | 60 | > 更新时间 61 | 62 | 2020-03-24 10:50:51 63 | -------------------------------------------------------------------------------- /现货冰山委托卖出插件Simple-Iceberg-order-to-sell-Copy.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 现货冰山委托卖出插件Simple-Iceberg-order-to-sell-Copy 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | Very simple, just for learn. 13 | Code is best annotation. 14 | 15 | 冰山委托卖出,将订单分成小笔卖出,避免冲击市场,是很好的简单入门比特币量化交易的学习策略 16 | 插件可以在交易终端一键启动,不收取费用,方便手动交易。详细介绍:https://www.fmz.com/digest-topic/5051 17 | 18 | > 策略参数 19 | 20 | 21 | 22 | |参数|默认值|描述| 23 | |----|----|----| 24 | |SELLAMOUNT|2|amount to sell| 25 | |SELLSIZE|0.1|sell orders size| 26 | |INTERVAL|3|order exist time(second)| 27 | 28 | 29 | > 源码 (javascript) 30 | 31 | ``` javascript 32 | function main(){ 33 | var initAccount = _C(exchange.GetAccount) 34 | if (initAccount.Stocks < SELLAMOUNT){ 35 | throw 'check your account amount to sell' 36 | } 37 | while(true){ 38 | var account = _C(exchange.GetAccount) 39 | var dealAmount = initAccount.Stocks - account.Stocks 40 | var ticker = _C(exchange.GetTicker) 41 | if(SELLAMOUNT - dealAmount >= SELLSIZE){ 42 | var id = exchange.Sell(ticker.Buy, SELLSIZE) 43 | Sleep(INTERVAL*1000) 44 | if(id){ 45 | exchange.CancelOrder(id) // May cause error log when the order is completed, which is all right. 46 | }else{ 47 | throw 'sell error' 48 | } 49 | }else{ 50 | account = _C(exchange.GetAccount) 51 | var avgCost = (account.Balance - initAccount.Balance)/(initAccount.Stocks - account.Stocks) 52 | return 'Iceberg order to sell is done, avg price is ' + avgCost 53 | 54 | } 55 | } 56 | } 57 | ``` 58 | 59 | > 策略出处 60 | 61 | https://www.fmz.com/strategy/191772 62 | 63 | > 更新时间 64 | 65 | 2020-03-24 10:50:43 66 | -------------------------------------------------------------------------------- /画线机器人一年翻倍回撤1完美曲线.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 画线机器人一年翻倍回撤1完美曲线 5 | 6 | > 策略作者 7 | 8 | xy_thu 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | import random 18 | 19 | def main(): 20 | account = exchange.GetAccount() 21 | balance = account["Balance"] 22 | while True: 23 | LogProfit(balance - account["Balance"]) 24 | balance = balance * (1 + (0.5 - random.random()) / 1000 + 1 / 100000) 25 | Sleep(1000 * 60) 26 | 27 | ``` 28 | 29 | > 策略出处 30 | 31 | https://www.fmz.com/strategy/349298 32 | 33 | > 更新时间 34 | 35 | 2022-03-07 02:35:46 36 | -------------------------------------------------------------------------------- /短信通知接口测试.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 短信通知接口测试 5 | 6 | > 策略作者 7 | 8 | Zero 9 | 10 | > 策略描述 11 | 12 | 短信通知接口测试, 请到支持api的短信平台注册账户(推荐短信宝), 然后把发送的URL输入到接口里 13 | 比如 http://www.xxxx.com/sms.php?phone=1111111&c={BODY} 14 | 测试能不能手到短信 15 | 16 | > 策略参数 17 | 18 | 19 | 20 | |参数|默认值|描述| 21 | |----|----|----| 22 | |SMSAPI|http://|短信接口| 23 | |Msg|你好,测试成功|发送的信息| 24 | 25 | 26 | > 源码 (javascript) 27 | 28 | ``` javascript 29 | function main() { 30 | if (SMSAPI.length > 10 && SMSAPI.indexOf('http') == 0 && SMSAPI.indexOf('{BODY}') != -1) { 31 | Log('发送: ', Msg); 32 | HttpQuery(SMSAPI.replace('{BODY}', encodeURIComponent(Msg))); 33 | Log('发送完成, 请检测是否收到短信'); 34 | } else { 35 | Log('参数配置错误, 请重新检测短信接口'); 36 | } 37 | } 38 | ``` 39 | 40 | > 策略出处 41 | 42 | https://www.fmz.com/strategy/653 43 | 44 | > 更新时间 45 | 46 | 2014-09-25 17:35:46 47 | -------------------------------------------------------------------------------- /简单多品种商品期货均线策略.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 简单多品种商品期货均线策略 5 | 6 | > 策略作者 7 | 8 | 扫地僧 9 | 10 | > 策略描述 11 | 12 | 商品期货类库实现了$.CTA函数的策略框架,借助该策略框架, 可以短短几十行实现一个并发稳定可实盘的多品种策略 13 | 14 | https://dn-filebox.qbox.me/21384f4e53937bc1dd252ff478ff08e5b4d52e71.png 15 | 16 | > 策略参数 17 | 18 | 19 | 20 | |参数|默认值|描述| 21 | |----|----|----| 22 | |Symbols|rb000,MA000|操作品种| 23 | |FastPeriod|5|快线周期| 24 | |SlowPeriod|20|慢线周期| 25 | |ConfirmPeriod|2|确认周期| 26 | |Lots|true|开仓手数| 27 | 28 | 29 | > 源码 (javascript) 30 | 31 | ``` javascript 32 | /*backtest 33 | start: 2017-06-01 00:00:00 34 | end: 2017-10-01 00:00:00 35 | period: 1d 36 | exchanges: [{"eid":"Futures_CTP","currency":"FUTURES"}] 37 | */ 38 | function main() { 39 | // 使用了商品期货类库的CTA策略框架 40 | $.CTA(Symbols, function(st) { 41 | var r = st.records 42 | var mp = st.position.amount 43 | var symbol = st.symbol 44 | /* 45 | r为K线, mp为当前品种持仓数量, 正数指多仓, 负数指空仓, 0则不持仓, symbol指品种名称 46 | 返回值如为n: 47 | n = 0 : 指全部平仓(不管当前持多持空) 48 | n > 0 : 如果当前持多仓,则加n个多仓, 如果当前为空仓则平n个空仓,如果n大于当前持仓, 则反手开多仓 49 | n < 0 : 如果当前持空仓,则加n个空仓, 如果当前为多仓则平n个多仓,如果-n大于当前持仓, 则反手开空仓 50 | 无返回值表示什么也不做 51 | */ 52 | if (r.length < SlowPeriod) { 53 | return 54 | } 55 | var cross = _Cross(TA.EMA(r, FastPeriod), TA.EMA(r, SlowPeriod)); 56 | if (mp <= 0 && cross > ConfirmPeriod) { 57 | Log(symbol, "金叉周期", cross, "当前持仓", mp); 58 | return Lots * (mp < 0 ? 2 : 1) 59 | } else if (mp >= 0 && cross < -ConfirmPeriod) { 60 | Log(symbol, "死叉周期", cross, "当前持仓", mp); 61 | return -Lots * (mp > 0 ? 2 : 1) 62 | } 63 | }); 64 | } 65 | ``` 66 | 67 | > 策略出处 68 | 69 | https://www.fmz.cn/strategy/57029 70 | 71 | > 更新时间 72 | 73 | 2019-10-06 18:01:54 74 | -------------------------------------------------------------------------------- /简单预定买入后卖出插件Buy-then-Sell-ping-pong-strategy.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 简单预定买入后卖出插件Buy-then-Sell-ping-pong-strategy 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | 如题,可设定买入价格,买入成功后自动挂卖出价格卖出, 13 | 插件可以在交易终端一键启动,不收取费用,方便手动交易。详细介绍:https://www.fmz.com/digest-topic/5051 14 | 15 | > 策略参数 16 | 17 | 18 | 19 | |参数|默认值|描述| 20 | |----|----|----| 21 | |BUYPRICE|6200|buy price| 22 | |BUYAMOUNT|0.1|buy amount| 23 | |SELLPRICE|6400|sell price after buying| 24 | |Intervel|6|sleep time (second)| 25 | 26 | 27 | > 源码 (javascript) 28 | 29 | ``` javascript 30 | function CancelPendingOrders() { 31 | var orders = _C(exchange.GetOrders); 32 | for (var j = 0; j < orders.length; j++) { 33 | exchange.CancelOrder(orders[j].Id, orders[j]); 34 | } 35 | } 36 | function main() { 37 | Log('robot starts to run') 38 | if(BUYPRICE >= SELLPRICE){ 39 | throw 'check buy and sell price' 40 | } 41 | CancelPendingOrders() 42 | var account = _C(exchange.GetAccount) 43 | var init_account = account 44 | Log('account: ', account.Balance); 45 | if(account.Balance > BUYPRICE*BUYAMOUNT){ 46 | exchange.Buy(BUYPRICE, BUYAMOUNT); 47 | }else{ 48 | throw 'account balances is not enough' 49 | } 50 | while(true){ 51 | account = _C(exchange.GetAccount) 52 | if(account.Stocks >= init_account.Stocks + 0.01){ 53 | exchange.Sell(SELLPRICE, account.Stocks - init_account.Stocks) 54 | } 55 | Sleep(Intervel*1000) 56 | } 57 | } 58 | 59 | ``` 60 | 61 | > 策略出处 62 | 63 | https://www.fmz.com/strategy/121228 64 | 65 | > 更新时间 66 | 67 | 2020-03-24 10:50:59 68 | -------------------------------------------------------------------------------- /练习01RSI.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 练习01RSI 5 | 6 | > 策略作者 7 | 8 | 3028165668 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (python) 15 | 16 | ``` python 17 | 18 | def RSI(): 19 | ticker = exchange.GetTicker() 20 | account = exchange.GetAccount() 21 | r = exchange.GetRecords(PERIOD_H1 * 4) 22 | rsi = TA.RSI(r, 14) 23 | is_buy = False 24 | is_sell = False 25 | if rsi[-1] > 70 and account["Stocks"] > 0: 26 | id = exchange.Sell(ticker["Buy"], account["Stocks"] * 0.01) 27 | is_buy = True 28 | elif rsi[-1] < 30 and account["Balance"] > 0: 29 | id = exchange.Buy(ticker["Sell"], account["Balance"] / ticker["Sell"] * 0.01) 30 | is_sell = True 31 | 32 | 33 | if is_buy or is_sell: 34 | Sleep(1000 * 60 * 4) 35 | 36 | # if rsi[-1] < 40 and account["Balance"] > 0: 37 | # id = exchange.Buy(ticker["Buy"], account["Balance"] / ticker["Sell"] * 0.0005) 38 | # if rsi[-1] > 60 and account["Stocks"] > 0: 39 | # id = exchange.Sell(ticker["Sell"], account["Stocks"] * 0.0005) 40 | # if rsi[-1] < 40 and account["Balance"] > 0: 41 | # id = exchange.Buy(ticker["Buy"], account["Balance"] / ticker["Sell"] * 0.05) 42 | return 43 | 44 | def main(): 45 | Log("策略开始 !") 46 | i = 0 47 | while True: #循环 48 | RSI() #执行策略主函数 49 | i = i + 1 50 | if i % 50 == 0: 51 | account = exchange.GetAccount() 52 | Log(account["Balance"], account["Stocks"]) 53 | 54 | ''' 55 | def main(): 56 | Log("策略开始 !") 57 | ticker = exchange.GetTicker() 58 | account = exchange.GetAccount() 59 | id = exchange.Buy(ticker["Buy"], 0.01) 60 | Log(account["Balance"]) 61 | Log(id) 62 | Sleep(60 * 1000) 63 | ''' 64 | 65 | ``` 66 | 67 | > 策略出处 68 | 69 | https://www.fmz.com/strategy/288889 70 | 71 | > 更新时间 72 | 73 | 2021-06-09 10:24:00 74 | -------------------------------------------------------------------------------- /统计K线回测是否存在趋势.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 统计K线回测是否存在趋势 5 | 6 | > 策略作者 7 | 8 | 小草 9 | 10 | > 策略描述 11 | 12 | 这个策略主要是想从回测数据中考察是否可以根据前面涨跌情况,预测接下来的涨跌。具体如下:如果5根K线中,出现4个或5个上涨,那么下一根是否更趋向于上涨,该策略将统计出上涨的频率。当然也已更改策略的参数统计其它上涨或下跌的情况。在几天的回测时间内,策略运行的还可以,但是回测周期较长时,比如从本月13号到现在,就会出现混乱,不清楚原因。 13 | 14 | 15 | 16 | > 源码 (javascript) 17 | 18 | ``` javascript 19 | function adjustFloat(v) { 20 | 21 | return Math.floor(v*1000)/1000; 22 | } 23 | function main(){ 24 | var arr=[0,0,0,0,0,0];//总共考察六根K线,用前五个的结果去预测第六个,可以自由选择 25 | var appear=0; //模式的出现次数 26 | var fit=0; //第六根K线的结果符合预期 27 | var diff=0; //预定模式出现后,第六根的收盘价和开盘价之差。 28 | while(true){ 29 | var records=exchange.GetRecords(); 30 | i=records.length-1; 31 | if(i>1&&(records[i].Close-records[i].Open>0)){ 32 | arr.push(1); 33 | arr.shift(); //把最近一个K线的插入数组末尾,删去元素一以保持长度不变。上涨插入1,否则插入0 34 | } 35 | if(i>1&&!(records[i].Close-records[i].Open>0)){ 36 | arr.push(0); 37 | arr.shift(); 38 | } 39 | if(i>5){ 40 | var count=0; 41 | for(k=0;k<5;k++){ 42 | if(arr[k]<1){ 43 | count++; //前5根K线上涨的个数 44 | } 45 | } 46 | if(count<2){ //设定需要多少个上涨K线,在这里要求四个或五个。 47 | appear++; //所需模式出现一次 48 | diff+=(records[i].Close-records[i].Open);//统计第六根,也是最近一根的差价和 49 | if(arr[5]<1){ //这里所期望的结果是上涨,也可以写成其它的 50 | fit++; //期待结果出现一次 51 | Log("出现模式次数",appear,"符合预计次数",fit,"所占比例",adjustFloat(fit/appear),"差价之和",adjustFloat(diff)); 52 | LogProfit(adjustFloat(fit/appear)); //把比例输出为收益曲线 53 | } 54 | } 55 | } 56 | Sleep(300000); //间隔时间,应与所选K线周期相同?这里是5分钟 57 | } 58 | } 59 | ``` 60 | 61 | > 策略出处 62 | 63 | https://www.fmz.com/strategy/1125 64 | 65 | > 更新时间 66 | 67 | 2014-10-28 19:32:09 68 | -------------------------------------------------------------------------------- /统计各个平台间的最大差价by-JackConan.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 统计各个平台间的最大差价by-JackConan 5 | 6 | > 策略作者 7 | 8 | yzl_126@126.com 9 | 10 | > 策略描述 11 | 12 | 统计各个平台间的最大差价; 13 | 如果要打印当时各交易所的市场行情,可以把 //printCurPrice(); 前面的注释//去掉; 14 | 15 | 16 | 17 | > 源码 (javascript) 18 | 19 | ``` javascript 20 | var maxSpace = 0; 21 | 22 | function adjustFloat(v) { 23 | return Math.floor(v*1000)/1000; 24 | } 25 | 26 | function printCurPrice() { 27 | for (var i = 0; i < exchanges.length; i++) { 28 | Log(exchanges[i].GetName(),'=',exchanges[i].GetTicker()); 29 | } 30 | } 31 | 32 | function onTick() { 33 | // TODO something. 34 | var smallPrice = 99999; 35 | var bigPrice = 0; 36 | var curPrice = 0; 37 | var curSpace = 0; 38 | 39 | for (var i = 0; i < exchanges.length; i++) { 40 | curPrice = exchanges[i].GetTicker().Buy; 41 | if (curPrice < smallPrice){ 42 | smallPrice = curPrice; 43 | } 44 | if (curPrice > bigPrice){ 45 | bigPrice = curPrice; 46 | } 47 | curSpace = bigPrice - smallPrice; 48 | } 49 | 50 | if (curSpace > maxSpace){ 51 | maxSpace = curSpace; 52 | Log('差价:', adjustFloat(maxSpace),'高价:', bigPrice,'低价:', smallPrice, '发生时间 →_→'); 53 | //打印各交易所当前的市场行情; 54 | printCurPrice(); 55 | } 56 | } 57 | 58 | function main() { 59 | if (exchanges.length < 2) { 60 | Log("交易所数量最少得两个才能完成统计"); 61 | return; 62 | } 63 | while(true) { 64 | onTick(); 65 | Sleep(60000); 66 | } 67 | } 68 | ``` 69 | 70 | > 策略出处 71 | 72 | https://www.fmz.com/strategy/86 73 | 74 | > 更新时间 75 | 76 | 2014-06-22 21:15:34 77 | -------------------------------------------------------------------------------- /统计收益-复制.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 统计收益-复制 5 | 6 | > 策略作者 7 | 8 | 总值约: 23938.37 元 9 | 10 | > 策略描述 11 | 12 | 统计OK和Bitvc期货总收益;OK为主交易所; 13 | 14 | > 策略参数 15 | 16 | 17 | 18 | |参数|默认值|描述| 19 | |----|----|----| 20 | |LXT|20|循环周期(秒)| 21 | 22 | 23 | > 源码 (javascript) 24 | 25 | ``` javascript 26 | var okrights=0; 27 | var vcright=0; 28 | var InitRights=0; 29 | var totalrights=0; 30 | var profit=0; 31 | var oldprofit=0; 32 | 33 | SetErrorFilter("502:|503:|unexpected|network|timeout|WSARecv|Connect|GetAddr|no such|reset|http|received|EOF"); 34 | 35 | 36 | 37 | function Rights() { 38 | 39 | var accountok; 40 | var accountvc; 41 | while (!(accountok = exchanges[0].GetAccount())) { 42 | Sleep(500); 43 | } 44 | while (!(accountvc = exchanges[1].GetAccount())) { 45 | Sleep(500); 46 | } 47 | var objok; 48 | var objvc; 49 | 50 | objok=JSON.parse(exchanges[0].GetRawJSON()); 51 | objvc=JSON.parse(exchanges[1].GetRawJSON()); 52 | 53 | okrights=objok.info["btc"].rights; 54 | vcrights=objvc.dynamicRights; 55 | totalrights=okrights+vcrights; 56 | 57 | 58 | } 59 | 60 | function main(){ 61 | Rights(); 62 | InitRights=totalrights; 63 | Log("初始权益合计_BTC",InitRights); 64 | while(true){ 65 | Rights(); 66 | profit=totalrights-InitRights; 67 | if(profit!==oldprofit){ 68 | LogProfit(profit,"BTC"); 69 | oldprofit=profit; 70 | } 71 | Sleep(LXT*1000); 72 | } 73 | 74 | 75 | } 76 | 77 | 78 | 79 | 80 | ``` 81 | 82 | > 策略出处 83 | 84 | https://www.fmz.com/strategy/4489 85 | 86 | > 更新时间 87 | 88 | 2015-02-28 19:17:29 89 | -------------------------------------------------------------------------------- /自动获取币安永续合约交易精度最小开仓u已弃坑.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 自动获取币安永续合约交易精度最小开仓u已弃坑 5 | 6 | > 策略作者 7 | 8 | GCC 9 | 10 | > 策略描述 11 | 12 | 本来从交易规则里直接获取交易精度是很合理的做法,奈何币安经常不及时更新这部分,遂弃坑。 13 | 14 | 15 | 16 | > 源码 (python) 17 | 18 | ``` python 19 | def init(): 20 | global symbols, min_value 21 | # 获取交易规则 22 | exchange.SetBase('https://dapi.binance.com') 23 | rule = exchange.IO("api", "GET", "/dapi/v1/exchangeInfo", "", "")["symbols"] 24 | Log(rule) 25 | # 获取交易对名称 26 | for i in range(len(exchanges)): 27 | exchanges[i].SetMarginLevel(M) 28 | exchanges[i].SetContractType("swap") # 设置永续合约 29 | _symbol = exchanges[i].GetCurrency().split("_")[0] # +'USDT'币本位交易对名称 30 | # 设置交易精度 31 | j = 0 32 | flag1 = False 33 | flag2 = False 34 | #Log(rule) 35 | while (j < len(rule)) and flag1 == False and flag2 == False: 36 | if str(rule[j]["symbol"]).rfind(_symbol)>=0: 37 | for x in rule[j]["filters"]: 38 | if x["filterType"] == "PRICE_FILTER" and flag1 == False: 39 | #Log("价格",x["tickSize"]) 40 | #Log(len(str(float(x["tickSize"])).split('.')[-1])) 41 | price_precision = len(str(float(x["tickSize"])).split('.')[-1]) 42 | flag1 = True 43 | elif x["filterType"] == "LOT_SIZE" and flag2 == False: 44 | amount_precision = len(x["minQty"].split('.')[-1]) 45 | flag2 = True 46 | j = j + 1 47 | exchanges[i].SetPrecision(price_precision, amount_precision) 48 | Log("初始化结束") 49 | ``` 50 | 51 | > 策略出处 52 | 53 | https://www.fmz.com/strategy/322632 54 | 55 | > 更新时间 56 | 57 | 2021-11-12 15:44:44 58 | -------------------------------------------------------------------------------- /范例-定时测试微信消息推送.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 范例-定时测试微信消息推送 5 | 6 | > 策略作者 7 | 8 | 小小梦 9 | 10 | > 策略描述 11 | 12 | 定时测试微信消息推送 范例~抛砖引玉,方便用户参考学习。 13 | 14 | 15 | 16 | > 源码 (javascript) 17 | 18 | ``` javascript 19 | function main(){ 20 | var initTime = (new Date()).getTime() ; 21 | Log("程序起始时间:",$.getTimeByNormal(initTime) ); 22 | var preDif = 0; 23 | var str = ""; 24 | while(true){ 25 | var nowTime = (new Date()).getTime(); 26 | if( Math.floor((nowTime - initTime) / (1000*60*10) ) !== preDif ){ 27 | str = $.getTimeByNormal(nowTime); 28 | Log("从程序开始执行,已过10分钟!提醒。"+"--现在时间:"+str+"推送微信@" ); 29 | preDif = Math.floor((nowTime - initTime) / (1000*60*10) ) ; 30 | } 31 | Sleep(2000); 32 | } 33 | } 34 | ``` 35 | 36 | > 策略出处 37 | 38 | https://www.fmz.com/strategy/15098 39 | 40 | > 更新时间 41 | 42 | 2017-01-04 12:00:55 43 | -------------------------------------------------------------------------------- /获取OK期货实时限价.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 获取OK期货实时限价 5 | 6 | > 策略作者 7 | 8 | 数·狂 9 | 10 | > 策略描述 11 | 12 | 获取OK期货实时限价,仅实盘有效。 13 | 代码仅供学习,作者不保证程序正确性,据此交易后果自负。 14 | 15 | 16 | 17 | > 源码 (javascript) 18 | 19 | ``` javascript 20 | $.GetLimit = function(currStr, contract) { 21 | var url = "https://www.okcoin.com/api/v1/future_price_limit.do?symbol=" + currStr + "_usd&contract_type=" + contract; 22 | var httpResp = HttpQuery(url); 23 | if (httpResp.indexOf("false") != -1) return null; 24 | var parsedResp; 25 | try { 26 | parsedResp = JSON.parse(httpResp); 27 | } catch (e) { 28 | return null; 29 | } 30 | return parsedResp; 31 | }; 32 | 33 | function main() { 34 | var limit = $.GetLimit('btc', 'quarter'); // 获取 比特币 季度 合约限价 35 | Log(limit.high, limit.low); // 最高买入、最低卖出限价 36 | limit = $.GetLimit('ltc', 'this_week'); // 获取 莱特币 当周 合约限价 37 | Log(limit.high, limit.low); // 最高买入、最低卖出限价 38 | limit = $.GetLimit('btc', 'next_week'); // 获取 比特币 次周 合约限价 39 | Log(limit.high, limit.low); // 最高买入、最低卖出限价 40 | 41 | } 42 | ``` 43 | 44 | > 策略出处 45 | 46 | https://www.fmz.com/strategy/17028 47 | 48 | > 更新时间 49 | 50 | 2016-06-19 11:15:05 51 | -------------------------------------------------------------------------------- /获取币安usdt合约全币种名称.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 获取币安usdt合约全币种名称 5 | 6 | > 策略作者 7 | 8 | 11111 9 | 10 | > 策略描述 11 | 12 | 1,放入FMZ调试工具,可以直接运行 13 | 2,获取币安usdt合约全币种名称及个数 14 | 15 | 16 | 17 | > 源码 (javascript) 18 | 19 | ``` javascript 20 | function unique (str) { 21 | var arr = str.split(','); 22 | return Array.from(new Set(arr)).join(',') 23 | } 24 | 25 | function main() { 26 | var exchange_info = JSON.parse(HttpQuery('https://fapi.binance.com/fapi/v1/exchangeInfo')); 27 | //Log(exchange_info.symbols); 28 | var str = ''; 29 | exchange_info.symbols.forEach(function(exitem, index) { 30 | if (exitem.symbol.indexOf('USDT') == -1) {return} 31 | if (exitem.symbol.indexOf('BTCST') !== -1) {return} 32 | if (exitem.symbol.indexOf('BTCDOM') !== -1) {return} 33 | var content = ','; 34 | if (index == exchange_info.symbols.length - 1) { 35 | content = ''; 36 | } 37 | str += exitem.baseAsset + content; 38 | }); 39 | Log(unique(str)) 40 | Log(unique(str).split(',').length) 41 | //return unique(str); 42 | } 43 | 44 | ``` 45 | 46 | > 策略出处 47 | 48 | https://www.fmz.com/strategy/327743 49 | 50 | > 更新时间 51 | 52 | 2021-11-04 03:25:30 53 | -------------------------------------------------------------------------------- /获取持仓均价你用对了吗.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 获取持仓均价你用对了吗 5 | 6 | > 策略作者 7 | 8 | LiteFly 9 | 10 | > 策略描述 11 | 12 | 获取持仓均价大部分人用的是 13 | position = exchanges[0].GetPosition() 14 | avgPrice = position[0]["Price"] 15 | 但是其实这样是不准的,打印币安合约position信息: 16 | [map[Amount:5 ContractType:swap FrozenAmount:0 Info:map[entryPrice:55173.32071038 isAutoAddMargin:false isolatedMargin:0.00000000 isolatedWallet:0 leverage:20 liquidationPrice:0 marginType:cross markPrice:55171.20000000 maxQty:50 notionalValue:-0.00906269 positionAmt:-5 positionSide:BOTH symbol:BTCUSD_PERP unRealizedProfit:0.00000034] Margin:0.0004531349689693174 MarginLevel:20 Price:55173.32071038 Profit:3.4e-07 Type:1]] 17 | 18 | 发现有2个价格entryPrice Price,而合约交易不同交易所每天都会进行结算,结算后Price就会变了,而entryPrice才算真正的原始持仓价格, 19 | 若这时你用Price去计算收益率来进行止盈止损,可能会造成较大的损失。 20 | 21 | 以上原因,封装了三大交易所的持仓均价函数,拿走不谢 22 | 23 | 24 | 25 | > 源码 (python) 26 | 27 | ``` python 28 | def getAvgPrice(position): 29 | if hasattr(position[0],'Info') and hasattr(position[0].Info,'cost_open'):# Huobi 30 | return position[0].Info.cost_open 31 | elif hasattr(position[0],'Info') and hasattr(position[0].Info,'avg_cost'):#OKex 32 | return position[0].Info.avg_cost 33 | elif hasattr(position[0],'Info') and hasattr(position[0].Info,'entryPrice'):#binance 34 | return position[0].Info.entryPrice 35 | else: 36 | return position[0]["Price"] 37 | 38 | def main(): 39 | Log(exchange.GetAccount()) 40 | position = exchanges[0].GetPosition() 41 | if len(position)>0: 42 | avgPrice = getAvgPrice(position) 43 | Log(avgPrice) 44 | 45 | 46 | 47 | ``` 48 | 49 | > 策略出处 50 | 51 | https://www.fmz.com/strategy/261288 52 | 53 | > 更新时间 54 | 55 | 2021-03-11 14:45:53 56 | -------------------------------------------------------------------------------- /融资融币统计.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 融资融币统计 5 | 6 | > 策略作者 7 | 8 | 数·狂 9 | 10 | > 策略描述 11 | 12 | 使用交易所api功能显示当前交易所的融资融币情况(未还部分,含手续费)。目前只支持OKCoin和火币,欢迎继续完善。 13 | 需要最新版托管者。 14 | 15 | 16 | 17 | > 源码 (javascript) 18 | 19 | ``` javascript 20 | function getLoanInfo(exchange, type) { 21 | var loanInfo; 22 | var dueAmount; 23 | if (exchange.GetName() == "OKCoin") { 24 | loanInfo = exchange.IO("api", "borrows_info", "symbol=cny"); 25 | if (type == "btc") { 26 | dueAmount = loanInfo.borrow_btc + loanInfo.interest_btc; 27 | } 28 | else if (type == "ltc") { 29 | dueAmount = loanInfo.borrow_ltc + loanInfo.interest_ltc; 30 | } 31 | else if (type == "cny") { 32 | dueAmount = loanInfo.borrow_cny + loanInfo.interest_cny; 33 | } 34 | } 35 | else if (exchange.GetName() == "Huobi") { 36 | loanInfo = exchange.IO("api", "get_loans", "market=cny"); 37 | dueAmount = 0; 38 | for (var i = 0; i < loanInfo.length; i++) { 39 | if (type == "cny" && loanInfo[i].type == 1 || type == "btc" && loanInfo[i].type == 2 || type == "ltc" && loanInfo[i].type == 3) { 40 | dueAmount += (Number(loanInfo[i].loan_amount) - Number(loanInfo[i].repayment_amount) + Number(loanInfo[i].interest_nopay) + Number(loanInfo[i].interest_payed)); 41 | } 42 | } 43 | } 44 | else 45 | throw "暂不支持交易所: " + exchange.GetName(); 46 | return dueAmount; 47 | } 48 | 49 | function main() { 50 | for (var i = 0; i < exchanges.length; i++) 51 | Log(exchanges[i].GetName(), 52 | "未归还CNY:", getLoanInfo(exchanges[i], "cny"), 53 | "未归还BTC:", getLoanInfo(exchanges[i], "btc"), 54 | "未归还LTC:", getLoanInfo(exchanges[i], "ltc") 55 | ); 56 | } 57 | ``` 58 | 59 | > 策略出处 60 | 61 | https://www.fmz.com/strategy/8954 62 | 63 | > 更新时间 64 | 65 | 2016-01-13 19:03:22 66 | -------------------------------------------------------------------------------- /行情中心延时.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 行情中心延时 5 | 6 | > 策略作者 7 | 8 | fmzero 9 | 10 | > 策略描述 11 | 12 | **测试[行情中心](https://www.fmz.com/strategy/182185)延时** 13 | 14 | ![IMG](https://www.fmz.com/upload/asset/3c072bb7197f82f80b68.png) 15 | 16 | 17 | 18 | > 源码 (javascript) 19 | 20 | ``` javascript 21 | function main() { 22 | mcc = $.NewMarketCenterClient() 23 | Log('support list: '+mcc.GetSupportList()) 24 | mcc.SubscribeSpotTicker('binance.com', 'BTC_USDT', 200) 25 | Sleep(1000) 26 | Log("start...") 27 | var count = 0 28 | 29 | var max = -1 30 | var min = 9999999 31 | var ave = 0 32 | var sum = 0 33 | 34 | for(var i = 0; i < 1000; i++) { 35 | var start = new Date().getTime() 36 | var ticker = mcc.GetSpotTicker('binance.com', 'BTC_USDT') 37 | var end = new Date().getTime() 38 | if (ticker === null) { 39 | continue 40 | } 41 | count += 1 42 | var pass = end - start 43 | if (pass > max) { 44 | max = pass 45 | } 46 | if (pass < min) { 47 | min = pass 48 | } 49 | sum += pass 50 | } 51 | ave = sum / count 52 | 53 | var allstatus = '行情中心延时测试\n' 54 | allstatus += "https://www.fmz.com/strategy/183009\n"; 55 | allstatus += "♜Q:6510676#0000ff\n"; 56 | allstatus += "♜Q群:364655408#0000ff\n"; 57 | allstatus += "♜微信: btstarinfo#0000ff\n"; 58 | 59 | var table = { 60 | type: 'table', 61 | title: '延时测试', 62 | cols: ['测试次数', '最大(ms)', '最小(ms)', '平均(ms)'], 63 | rows: [ 64 | [ 65 | count, max, min, ave 66 | ] 67 | ] 68 | } 69 | allstatus += "`" + JSON.stringify(table) + "`" + "\n"; 70 | 71 | LogStatus(allstatus) 72 | } 73 | ``` 74 | 75 | > 策略出处 76 | 77 | https://www.fmz.com/strategy/183009 78 | 79 | > 更新时间 80 | 81 | 2020-02-10 20:12:47 82 | -------------------------------------------------------------------------------- /跨周期均线交易multiple-timeframe-trading.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 跨周期均线交易multiple-timeframe-trading 5 | 6 | > 策略作者 7 | 8 | 发明者量化 9 | 10 | > 策略描述 11 | 12 | [trans]演示Pine语言如何跨周期调用||Demonstrates how the pine language use multiple timeframe[/trans] 13 | 14 | 15 | 16 | > 源码 (PineScript) 17 | 18 | ``` javascript 19 | /*backtest 20 | start: 2021-05-04 00:00:00 21 | end: 2022-05-03 23:59:00 22 | period: 1d 23 | basePeriod: 1h 24 | exchanges: [{"eid":"Bitfinex","currency":"BTC_USD"}] 25 | */ 26 | strategy("multiple timeframe trading") 27 | 28 | expr = ta.ema(close, 5) 29 | hVal = request.security(syminfo.tickerid, '60', expr) 30 | 31 | plot(expr, timeframe.period) 32 | plot(hVal, '1hour') 33 | 34 | // 5 hour vs 5 days 35 | if hVal > expr 36 | strategy.entry("long", strategy.long) 37 | else 38 | strategy.entry("short", strategy.short) 39 | 40 | ``` 41 | 42 | > 策略出处 43 | 44 | https://www.fmz.com/strategy/361360 45 | 46 | > 更新时间 47 | 48 | 2022-05-06 16:47:08 49 | -------------------------------------------------------------------------------- /追涨杀跌.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 追涨杀跌 5 | 6 | > 策略作者 7 | 8 | ChildeTang 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |PERIOD|60|周期| 19 | |LENGTH|1440|长度| 20 | 21 | 22 | > 源码 (python) 23 | 24 | ``` python 25 | list=[] 26 | 27 | def doTicker(): 28 | #Log(exchange.GetAccount()) 29 | #Log(list) 30 | ticker = exchange.GetTicker() 31 | last = ticker.Last 32 | if len(list) < LENGTH: 33 | list.append(last) 34 | else: 35 | pMax = max(list) 36 | pMin = min(list) 37 | if last > pMax: 38 | Log("buy " + str(exchange.GetAccount())) 39 | account = exchange.GetAccount() 40 | if account.Balance > last: 41 | #id = exchange.Buy(last, 1) 42 | id = exchange.Buy(-1, 1) 43 | Log("buy id --> " + str(id)) 44 | elif last < pMin: 45 | Log("sell " + str(exchange.GetAccount())) 46 | account = exchange.GetAccount() 47 | if account.Stocks > 0: 48 | #id = exchange.Sell(last, 1) 49 | id = exchange.Sell(-1, 1) 50 | Log("sell id --> " + str(id)) 51 | list.pop(0) 52 | list.append(last) 53 | 54 | def main(): 55 | while(true): 56 | doTicker() #执行策略 57 | Sleep(PERIOD * 1000) #休息一段时间 58 | 59 | ``` 60 | 61 | > 策略出处 62 | 63 | https://www.fmz.com/strategy/96634 64 | 65 | > 更新时间 66 | 67 | 2018-06-06 16:32:06 68 | -------------------------------------------------------------------------------- /通过HttpQuery直接获取币安K线数据.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 通过HttpQuery直接获取币安K线数据 5 | 6 | > 策略作者 7 | 8 | 夏天不打你 9 | 10 | 11 | 12 | 13 | 14 | > 源码 (javascript) 15 | 16 | ``` javascript 17 | // GetRecords_Binance_Swap("5m", "ETHUSDT") 18 | // GetRecords_Binance_Swap("4h", "ETHUSDT") 19 | function GetRecords_Binance_Swap(period, symbol) { 20 | // var url = "https://api.binance.com/api/v3/klines?symbol=" + symbol + "&interval=" + period // 现货 21 | var url = "https://fapi.binance.com/fapi/v1/klines?symbol=" + symbol + "&interval=" + period // U本位永续 22 | var ret = HttpQuery(url) 23 | 24 | try { 25 | var jsonData = JSON.parse(ret) 26 | var records = [] 27 | for (var i = 0; i < jsonData.length; i++) { 28 | records.push({ 29 | Time: jsonData[i][0], 30 | High: Number(jsonData[i][2]), 31 | Open: Number(jsonData[i][1]), 32 | Low: Number(jsonData[i][3]), 33 | Close: Number(jsonData[i][4]), 34 | Volume: Number(jsonData[i][5]), 35 | }); 36 | } 37 | return records 38 | } catch (e) { 39 | Log(e) 40 | } 41 | } 42 | ``` 43 | 44 | > 策略出处 45 | 46 | https://www.fmz.com/strategy/334026 47 | 48 | > 更新时间 49 | 50 | 2021-12-07 20:17:06 51 | -------------------------------------------------------------------------------- /钉钉推送.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 钉钉推送 5 | 6 | > 策略作者 7 | 8 | 一拳男孩 9 | 10 | > 策略描述 11 | 12 | - $.ddNotice(title, content) 13 | > title: 字符串类型,推送的标题 14 | > content: 数组类型,markdown格式 15 | 16 | > 策略参数 17 | 18 | 19 | 20 | |参数|默认值|描述| 21 | |----|----|----| 22 | |DING_URI|钉钉URI|钉钉URI| 23 | 24 | 25 | > 源码 (javascript) 26 | 27 | ``` javascript 28 | $.ddNotice = function(title, content) { 29 | content = content == null ? title : content instanceof Array ? content.join('\n') : content 30 | HttpQuery(DING_URI, { 31 | method: 'POST', 32 | timeout: 3000, 33 | data: JSON.stringify({ 34 | msgtype: 'markdown', 35 | markdown: { 36 | title: title, 37 | text: content 38 | } 39 | }) 40 | }, null, 'Content-Type: application/json') 41 | } 42 | ``` 43 | 44 | > 策略出处 45 | 46 | https://www.fmz.com/strategy/159668 47 | 48 | > 更新时间 49 | 50 | 2019-08-13 22:38:39 51 | -------------------------------------------------------------------------------- /麦语言网格策略.md: -------------------------------------------------------------------------------- 1 | 2 | > 策略名称 3 | 4 | 麦语言网格策略 5 | 6 | > 策略作者 7 | 8 | a8269917 9 | 10 | 11 | 12 | > 策略参数 13 | 14 | 15 | 16 | |参数|默认值|描述| 17 | |----|----|----| 18 | |ktkc|10|空头起始仓位| 19 | |dtkc|false|多头起始仓位| 20 | |y|0.02|盈利减仓距离| 21 | |s|0.02|亏损加仓距离| 22 | |jia|true|亏损加仓数量| 23 | |jian|true|盈利减仓数量| 24 | 25 | 26 | > 源码 (麦语言) 27 | 28 | ``` pascal 29 | VARIABLE:V1:1; 30 | IF dtkc>0 AND BKVOL=0 THEN BEGIN 1,BK(dtkc);V1:C;INFO(1,V1);END 31 | IF ktkc>0 AND SKVOL=0 THEN BEGIN 1,SK(ktkc);V1:C;INFO(1,V1);END 32 | IF BKVOL>0 AND C>V1/(1-y) THEN BEGIN 1,SP(jian);V1:C;INFO(1,V1);END 33 | IF BKVOL>0 AND C0 AND C0 AND C>V1*(1+s) THEN BEGIN 1,SK(jia);V1:C;INFO(1,V1);END 36 | MULTSIG(0,0,60,0); 37 | TRADE_AGAIN(1000); 38 | ``` 39 | 40 | > 策略出处 41 | 42 | https://www.fmz.com/strategy/142701 43 | 44 | > 更新时间 45 | 46 | 2019-06-21 23:07:47 47 | --------------------------------------------------------------------------------