コード例 #1
0
# -*- coding: utf-8 -*-
from app.BinanceAPI import BinanceAPI
from app.authorization import api_key, api_secret
from data.runBetData import RunBetData
from app.dingding import Message
import time

binan = BinanceAPI(api_key, api_secret)
runbet = RunBetData()
msg = Message()


class Run_Main():
    def __init__(self):
        self.coinType = runbet.get_cointype()  # 交易币种
        pass

    def loop_run(self):
        while True:
            cur_market_price = binan.get_ticker_price(
                runbet.get_cointype())  # 当前交易对市价
            grid_buy_price = runbet.get_buy_price()  # 当前网格买入价格
            grid_sell_price = runbet.get_sell_price()  # 当前网格卖出价格
            quantity = runbet.get_quantity()  # 买入量
            step = runbet.get_step()  # 当前步数

            if grid_buy_price >= cur_market_price:  # 是否满足买入价
                res = msg.buy_limit_msg(self.coinType, quantity,
                                        grid_buy_price)
                if res['orderId']:  # 挂单成功
                    runbet.modify_price(grid_buy_price,
コード例 #2
0
from app.BinanceAPI import BinanceAPI
from app.authorization import api_key, api_secret
from data.runBetData import RunBetData
from app.dingding import Message
from data.calcIndex import CalcIndex
import time

import mplfinance as mpf
import matplotlib as mpl  # 用于设置曲线参数
from cycler import cycler  # 用于定制线条颜色
import pandas as pd  # 导入DataFrame数据
import matplotlib.pyplot as plt

binan = BinanceAPI(api_key, api_secret)
runbet = RunBetData()
msg = Message()

index = CalcIndex()


class Run_Main():
    def __init__(self):
        self.coinType = runbet.get_cointype()  # 交易币种
        pass

    def loop_run(self):
        while True:
            cur_market_price = binan.get_ticker_price(
                runbet.get_cointype())  # 当前交易对市价
            grid_buy_price = runbet.get_buy_price()  # 当前网格买入价格
            grid_sell_price = runbet.get_sell_price()  # 当前网格卖出价格