class FxSystem(object): def __init__(self, pair, period, data_file): self.market = Market(pair, period) self.market.load_data(data_file) self.account = Account(self.market) def __repr__(self): out = "Fx System Trading {0} {1}.".format(self.market, self.account) return out
Returns a value between -1 (indicating short signal) and +1 (indicating long signal) Return what when required signal unavailable? Consider using sigmoid function to determine binary (ternary?) options From linear data ''' def __init__(self, market): self.market = market def CrossoverAnalyser(Analyser): ''' Bases signal on crossover of EAC ''' ''' add the indicators need to implement indicators.INDICATOR_INFO to matche number of columns and names against talib functions ''' if __name__ == '__main__': from market import Market, DATA_FILE m = Market("GBPCAD", "10m") m.load_data(DATA_FILE) a = Advisor(m) a.add_analysis(Analyser) print a
# profit - buy base / sell quote if self.quote > 0.0: profit = self.quote / self.market.get_ask() else: # loss - sell base / buy quote profit = self.quote / self.market.get_bid() #print "Opened at {0}, closed at {1}".format(self.position['price'], price) #print "PROFIT: {0} = {1}%".format(profit, 100*profit/self.position['price']) return profit class Advisor(object): ''' Uses technical indicators to advise on trading decisions ''' def __init__(self): pass if __name__ == "__main__": market = Market("GBPCAD", "10m") market.load_data(DATA_FILE) account = Account(market) ''' add the indicators need to implement indicators.INDICATOR_INFO to matche number of columns and names against talib functions '''