2023-01-11 17:10:25 +08:00
|
|
|
|
2023-07-14 18:39:48 +08:00
|
|
|
> Name
|
2023-01-11 17:10:25 +08:00
|
|
|
|
2023-04-18 23:12:35 +08:00
|
|
|
Python-KLineChart
|
2023-01-11 17:10:25 +08:00
|
|
|
|
2023-07-14 18:39:48 +08:00
|
|
|
> Author
|
2023-01-11 17:10:25 +08:00
|
|
|
|
|
|
|
|
发明者量化
|
|
|
|
|
|
2023-07-14 18:39:48 +08:00
|
|
|
> Strategy Description
|
2023-01-11 17:10:25 +08:00
|
|
|
|
|
|
|
|
平台(Javascript/Python语言)开通KLineChart支持, 支持Pine语言全部画图功能(参数保持一致), 支持自定义买卖信号
|
|
|
|
|
下面是一个演示的例子
|
|
|
|
|
|
|
|
|
|
参考文档 https://www.fmz.com/api#klinechart
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-07-14 18:39:48 +08:00
|
|
|
> Source (python)
|
2023-01-11 17:10:25 +08:00
|
|
|
|
|
|
|
|
``` python
|
|
|
|
|
'''backtest
|
|
|
|
|
start: 2022-03-30 09:00:00
|
|
|
|
|
end: 2022-06-30 15:00:00
|
|
|
|
|
period: 1h
|
|
|
|
|
basePeriod: 15m
|
|
|
|
|
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
def main():
|
|
|
|
|
Log(sys.version)
|
|
|
|
|
c = KLineChart()
|
|
|
|
|
c.reset(0)
|
|
|
|
|
|
|
|
|
|
bars = exchange.GetRecords()
|
|
|
|
|
for bar in bars:
|
|
|
|
|
c.begin(bar)
|
|
|
|
|
c.barcolor('rgba(255, 0, 0, 0.2)' if bar.Close > bar.Open else 'rgba(0, 0, 0, 0.2)')
|
|
|
|
|
if bar.Close > bar.Open:
|
|
|
|
|
c.bgcolor('rgba(0, 255, 0, 0.5)')
|
|
|
|
|
|
|
|
|
|
h = c.plot(bar.High, 'high')
|
|
|
|
|
l = c.plot(bar.Low, 'low')
|
|
|
|
|
c.fill(h, l, 'rgba(255, 0, 0, 1)' if bar.Close > bar.Open else '#000000')
|
|
|
|
|
c.hline(bar.High)
|
|
|
|
|
c.plotarrow(bar.Close - bar.Open)
|
|
|
|
|
c.plotshape(bar.Low, style = 'diamond')
|
|
|
|
|
c.plotchar(bar.Close, char = 'X')
|
|
|
|
|
c.plotcandle(bar.Open*0.9, bar.High*0.9, bar.Low*0.9, bar.Close*0.9)
|
|
|
|
|
if bar.Close > bar.Open:
|
|
|
|
|
c.signal("long", bar.High, 1.5, "LONG")
|
|
|
|
|
elif bar.Close < bar.Open:
|
|
|
|
|
c.signal("closelong", bar.Low, 1.5)
|
|
|
|
|
c.close()
|
|
|
|
|
```
|
|
|
|
|
|
2023-07-14 18:39:48 +08:00
|
|
|
> Detail
|
2023-01-11 17:10:25 +08:00
|
|
|
|
|
|
|
|
https://www.fmz.com/strategy/371600
|
|
|
|
|
|
2023-07-14 18:39:48 +08:00
|
|
|
> Last Modified
|
2023-01-11 17:10:25 +08:00
|
|
|
|
|
|
|
|
2022-07-01 17:57:42
|