Thiết lập thị trường sâu, kiểm soát giao dịch, robot điều khiển, làm công cụ thị trường

Tác giả:3 piggy, Ngày: 2019-05-02 20:50:00
Tags:Người tạo ra thị trườngPython

Chiến lược chạy cho sàn giao dịch, chiến lược chung là lấy giá hiện tại, đồng thời treo lệnh mua bán tăng độ sâu, có thể sao chép các thị trường khác, có thể tham khảo các xu hướng khác.


# -*- coding: UTF-8 -*-
import requests
import time
import random
import hashlib
import sys
import threading
from api import *

symbol = sys.argv[1]
gap= float(sys.argv[2]) #密度/价差
baseamount = float(sys.argv[3])
basebuy = float(sys.argv[4])
amount_add	= float(sys.argv[5]) 	#挂单增量	数字型(number)
amount_add2 = float(sys.argv[6]) 	#挂单增量	数字型(number)
longperoidlimit = int(sys.argv[7])
bigbase = float(sys.argv[8])				#大单基准量
orderlimit = int(sys.argv[9])   #总单量
api_key = sys.argv[10]
secret_key = sys.argv[11]

shortperoidlimit = 3	#高频单量

pre_short_id = []	#高平id标记
pre_long_id = []	#低频id标记
pre_big_id = 0

requests.packages.urllib3.disable_warnings()

def GetTicker():

def GetPV():

def GetDepth():

def GetSign(sign_str):


def GetOrders():

def create_order(side,price,amount):

def CancelOrder(order_id):

def Buy(price,amount):

def Sell(price,amount):

def GetRecords(symbol,period):

def GetPrecision():

def getrr():

def ordersend_shortperoid():

def ordersend_longperoid():

def send_big_order():

def cancel():


if __name__ == '__main__':
	precision = GetPrecision()
	print(precision)
	i = 0
	for x in precision:
		if precision[i]['symbol'] == symbol:
			pricedot = precision[i]['price_precision']
			amountdot = precision[i]['amount_precision']
		i += 1
	pricegap =  max(gap,pow(10,-pricedot))
	threading_list = [ordersend_shortperoid,ordersend_longperoid,send_big_order,cancel]
	threadingList = []
	threadingDict = {}
	for x in threading_list:
		th = threading.Thread(target=x)
		threadingList.append(th)
		threadingDict[th.__dict__['_name']] = th.__dict__['_target']
		th.start()

	while True:
		try:
			time.sleep(200)
			for i in threadingList:
				if i.is_alive() is False:
					threadingList.remove(i)
					result = threadingDict.pop(i.name)
					th = threading.Thread(target=result)
					threadingList.append(th)
					threadingDict[th.__dict__['_name']] = th.__dict__['_target']
					th.start()
		except Exception as e:
			print('check error',e)

Có liên quan

Thêm nữa

lcgs005Có thể thay đổi nó thành tiếng Ma.

Ồ.Bạn có nhiều cách liên lạc như thế nào?

3 piggy 15800768444