def test_CustomDraw(self): createdf.connectandsave() G = drawgraph.Graph() kwargs = { "Sma": { "params": (7, 14), "Enable": True }, "Ema": { "params": (7, 14), "Enable": True }, "Bb": { "params": (20, 2.0), "Enable": False }, "Macd": { "params": (12, 26, 9), "Enable": True }, "Rsi": { "params": (6, 30, 70), "Enable": True }, "Ichimoku": { "params": (9, 26, 52), "Enable": True } } G.CustomDraw(**kwargs)
def Change(request): changeproductcode.change_productcode() code = models.UsingProductCode.objects.last().code DEma = models.DEmaForm Ema = models.EmaForm Sma = models.SmaForm Bb = models.BbForm Ichimoku = models.IchimokuForm Rsi = models.RsiForm Macd = models.MacdForm G = drawgraph.Graph(duration="h", num_data=100, product_code=code) kwargs = { "DEma": { "params": (7, 14), "Enable": True }, "Ema": { "params": (7, 14), "Enable": True }, "Sma": { "params": (7, 14), "Enable": True }, "Bb": { "params": (20, 2.0), "Enable": True }, "Macd": { "params": (12, 26, 9), "Enable": True }, "Rsi": { "params": (6, 30, 70), "Enable": True }, "Ichimoku": { "params": (9, 26, 52), "Enable": True } } graph = G.CustomDraw(**kwargs) return render( request, "chart/index.html", { "graph": graph, "DEma": DEma, "Ema": Ema, "Sma": Sma, "Bb": Bb, "Ichimoku": Ichimoku, "Rsi": Rsi, "Macd": Macd, })
def backtest(request, indicator=None): G = drawgraph.Graph(duration="h", num_data=300, backtest=True) graph = G.DrawCandleStickWithOptimizedEvents(indicator=indicator) algolist = models.AlgoList.objects.all().values_list("algo", flat=True) return render(request, "chart/backtest.html", { "graph": graph, "algolist": algolist, })
def Trade(request, duration="h", side=None): code = models.UsingProductCode.objects.last().code balance = get_data.Balance(key.api_key, key.api_secret, code=code).GetBalance() jpy = balance["JPY"]['available'] btc = code.split("_")[0] btc = balance[btc]['available'] child_order_acceptance_id = None signalevent = None G = drawgraph.Graph(duration=duration, num_data=30, product_code=code) plt_fig = G.DrawCandleStick() if request.method == "POST": orders = order.BitFlayer_Order(api_key=key.api_key, api_secret=key.api_secret, product_code=code) side = request.POST["order"] size = float(request.POST["num_order"]) if side == "BUY": child_order_acceptance_id = orders.BUY(currency=size) elif side == "SELL": child_order_acceptance_id = orders.SELL(size=size) if child_order_acceptance_id is not None: signalevent = models.SignalEvents.objects.last() child_order_acceptance_id = child_order_acceptance_id[ "child_order_acceptance_id"] return render( request, "chart/trade.html", { "jpy": jpy, "btc": btc, "graph": plt_fig, "id": child_order_acceptance_id, "signalevents": signalevent })
def index(request, duration="h"): if not models.UsingProductCode.objects.exists(): models.UsingProductCode(code="BTC_JPY").save() code = models.UsingProductCode.objects.last().code DEma = models.DEmaForm Ema = models.EmaForm Sma = models.SmaForm Bb = models.BbForm Ichimoku = models.IchimokuForm Rsi = models.RsiForm Macd = models.MacdForm G = drawgraph.Graph(duration=duration, num_data=100, product_code=code) if request.method == "POST": kwargs = query2dict.get_data(request.POST) else: kwargs = { "DEma": { "params": (7, 14), "Enable": True }, "Ema": { "params": (7, 14), "Enable": True }, "Sma": { "params": (7, 14), "Enable": True }, "Bb": { "params": (20, 2.0), "Enable": True }, "Macd": { "params": (12, 26, 9), "Enable": True }, "Rsi": { "params": (6, 30, 70), "Enable": True }, "Ichimoku": { "params": (9, 26, 52), "Enable": True } } graph = G.CustomDraw(**kwargs) return render( request, "chart/index.html", { "graph": graph, "DEma": DEma, "Ema": Ema, "Sma": Sma, "Bb": Bb, "Ichimoku": Ichimoku, "Rsi": Rsi, "Macd": Macd, })
def test_DrawCandleStickWithOptimizedEvents(self): createdf.connectandsave(num_data=300) G = drawgraph.Graph() G.DrawCandleStickWithOptimizedEvents(indicator="Ema")
def test_Draw(self): createdf.connectandsave() G = drawgraph.Graph() G.DrawCandleStick()