【发布时间】:2019-11-04 05:37:52
【问题描述】:
我完全被卡住了。我需要一双额外的眼睛。我试着看看这个,我只是不知所措。我应该做些什么?我会在 cryptotrader 寻求帮助,但他们会表现得好像我很愚蠢,因为我没有神奇地知道答案。是我打错字还是怎么的?另外,我需要继续输入,这样我才能发帖,因为它认为它主要是代码。
trading = require "trading"
params = require "params"
talib = require "talib"
invest = params.add "Invest Amount in asset",.001
distance = params.add "Price change in asset",50
fees = params.add "Percentage of fees",.0025
init: ->
handle: ->
instrument=data.instruments[0]
asset = @portfolios[instrument.market].positions[instrument.asset()].amount
base = @portfolios[instrument.market].positions[instrument.base()].amount/_.last(instrument.close)
InsClose=_.last(instrument.close)
balance=(base+asset)*InsClose
storage.price?=InsClose
if InsClose>(storage.price+distance)
if asset/(1-fees)>=invest
trading.sell(instrument,'limit',invest,InsClose)
storage.price=storage.price+distance
debug “Balance #{balance}”
if InsClose<(storage.price-distance)
if base/(1-fees)>=invest
trading.buy(instrument,'limit',invest,InsClose)
storage.price=storage.price-distance
debug “Balance #{balance}”
sellprice=storage.price+distance
buyprice=storage.price-distance
plot:
sellprice:sellprice
buyprice:buyprice
【问题讨论】:
标签: coffeescript referenceerror