def __init__(self): self.start_value = 0 self.coinbase = Coinbase() self.binance = Binance() self.polo = poloniex() self.Threshold = 0.0021 self.num_trades = 0 self.order_volume = {'btc': 0.5, 'eth': 1, 'usd': 1000, 'xrp': 100} self.start_value = 0
######### Functions from other python files ######### from Poloniex import poloniex, createTimeStamp from Technical import TechnicalIndicators ######### from time import gmtime, strftime import pandas as pd import numpy as np import matplotlib.pyplot as plt # <API Key>, <Secret Key>, to connect with Poloniex API source_API = poloniex("API Key", "Secret Key") ###### Simulation ###### def MACD_RSI_SIMULATION(market_currency, trade_currency, data_range_time, periodic): # Parameters strategy = TechnicalIndicators() macd_fast = 12 macd_slow = 26 rsi_period = 14 rsi_upper = 70 rsi_down = 30 nNine = 9 # As starting position for market transactions # willing_position = "buy" # To prepare data for simulation #
from Poloniex import poloniex, createTimeStamp from Graphs import chart_technical, chart_general from Technical import TechnicalIndicators from Trading_Strategies import MACD_RSI_STRATEGY from Trading_Simulation import MACD_RSI_SIMULATION from time import gmtime, strftime import matplotlib.pyplot as plt import pandas as pd ############# MODIFY PARAMETERS ############### #<API Key>, <Secret Key>`` source_API = poloniex("", "") # As a DOLLAR for buying a stock market_currency = "USDT" #BTC; ETH; XMR; USDT # As a STOCK which will be traded trade_currency = "XRP" #XRP at least 0.0001 periodic = 900 #300(5min) #900(15 min) #1800(30 min) #7200(2 h) #14400(4 h) #86400(24 h) data_range_time = 2592000 #1 day (86400 s) #3 day (259200 s)
import sys class C: HEADER = '\033[95m' OKBLUE = '\033[94m' OKGREEN = '\033[92m' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' BOLD = '\033[1m' UNDERLINE = '\033[4m' b = Binance() p = poloniex() engine = Engine() while True: polo_price = float(p.getLastTradingPrice('BTC_XRP')) binance_price = float(b.client.get_all_tickers()[88]['price']) percent_difference = (polo_price - binance_price) / min( polo_price, binance_price) pd = str(percent_difference) if (percent_difference) > engine.Threshold: pd = C.OKBLUE + str(percent_difference) + C.ENDC elif abs(percent_difference) > engine.Threshold: pd = C.OKGREEN + str(percent_difference) + C.ENDC print polo_price, '\t', binance_price, '\t', pd