Created
July 10, 2017 18:02
-
-
Save Death916/ba1f7cf6deaed56adf4e509388771ba2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BotStrategy(object): | |
def __init__(self): | |
self.output = BotLog() | |
self.prices = [] | |
self.closes = [] # Needed for Momentum Indicator | |
self.trades = [] | |
self.currentPrice = "" | |
self.currentClose = "" | |
self.numSimulTrades = 1 | |
self.indicators = BotIndicators() | |
for trade in openTrades:def tick(self,candlestick): | |
self.currentPrice = float(candlestick['weightedAverage']) | |
self.prices.append(self.currentPrice) | |
self.currentClose = float(candlestick['close']) | |
self.closes.append(self.currentClose) | |
self.output.log("Price: "+str(candlestick['weightedAverage'])+"\tMoving Average: "+str(self.indicators.movingAverage(self.prices,15))) | |
self.evaluatePositions() | |
self.updateOpenTrades() | |
self.showPositions() | |
def evaluatePositions(self): | |
openTrades = [] | |
for trade in self.trades: | |
if (trade.status == "OPEN"): | |
openTrades.append(trade) | |
if (len(openTrades) < self.numSimulTrades): | |
if int(self.currentPrice < (self.indicators.movingAverage(self.prices,15))): | |
self.trades.append(BotTrade(self.currentPrice,stopLoss=.0001)) | |
if (self.currentPrice > self.indicators.movingAverage(self.prices,15)): | |
trade.close(self.currentPrice) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment