Skip to content

Commit c24fe5c

Browse files
幸福村的二娃幸福村的二娃
authored andcommitted
优化策略,放踏空跟随行情,网格交易价格自动拉升
1 parent 0eac225 commit c24fe5c

File tree

576 files changed

+142738
-62
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

576 files changed

+142738
-62
lines changed

.idea/binance-quantization.iml

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/encodings.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 Bytes
Binary file not shown.
121 Bytes
Binary file not shown.

app/authorization.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
api_secret = ''
66
recv_window = 5000
77

8-
dingding_token = ""
8+
dingding_token = "618c195120b60e6832b6e21e7c10043605dfb29955efaad8667da55daaf5f75a"

app/dingding.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def buy_limit_msg(self,market, quantity, rate):
2222

2323
def sell_limit_msg(self,market, quantity, rate):
2424
'''
25-
2625
:param market:
2726
:param quantity: 数量
2827
:param rate: 价格
170 Bytes
Binary file not shown.

data/data.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"runBet": {
3-
"next_buy_price": 9.2179,
4-
"grid_sell_price": 10.2941,
5-
"step": 4
3+
"next_buy_price": 568.1,
4+
"grid_sell_price": 627.9,
5+
"step": 0
66
},
77
"config": {
8-
"profit_ratio": 5,
8+
"profit_ratio": 6,
99
"double_throw_ratio": 5,
10-
"cointype": "WINGUSDT",
11-
"quantity": [10,10,10,10]
10+
"cointype": "ETHUSDT",
11+
"quantity": [0.25,0.3,0.35,0.4,0.45,0.5]
1212
}
13-
}
13+
}

data/runBetData.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import os,json
22
# linux
3-
# data_path = os.getcwd()+"/data/data.json"
3+
data_path = os.getcwd()+"/data/data.json"
44
# windows
5-
data_path = os.getcwd() + "\data\data.json"
5+
# data_path = os.getcwd() + "\data\data.json"
66

77
class RunBetData:
88

@@ -37,13 +37,19 @@ def get_cointype(self):
3737
data_json = self._get_json_data()
3838
return data_json["config"]["cointype"]
3939

40-
def get_quantity(self):
40+
def get_quantity(self,exchange_method=True):
41+
'''
42+
:param exchange: True 代表买入,取买入的仓位 False:代表卖出,取卖出应该的仓位
43+
:return:
44+
'''
45+
4146
data_json = self._get_json_data()
42-
cur_step = data_json["runBet"]["step"]
47+
cur_step = data_json["runBet"]["step"] if exchange_method else data_json["runBet"]["step"] - 1 # 买入与卖出操作对应的仓位不同
4348
quantity_arr = data_json["config"]["quantity"]
49+
4450
quantity = None
45-
if cur_step <= len(quantity_arr):
46-
quantity = quantity_arr[0] if cur_step == 0 else quantity_arr[cur_step-1]
51+
if cur_step < len(quantity_arr): # 当前仓位 > 设置的仓位 取最后一位
52+
quantity = quantity_arr[0] if cur_step == 0 else quantity_arr[cur_step]
4753
else:
4854
quantity = quantity_arr[-1]
4955
return quantity
@@ -54,10 +60,10 @@ def get_step(self):
5460

5561
# 买入后,修改 补仓价格 和 网格平仓价格以及步数
5662
def modify_price(self, deal_price,step):
57-
print("交易成功,开始修改补仓价和网格价")
63+
print("开始修改补仓价和网格价")
5864
data_json = self._get_json_data()
59-
data_json["runBet"]["next_buy_price"] = round(deal_price * (1 - data_json["config"]["double_throw_ratio"] / 100), 3)
60-
data_json["runBet"]["grid_sell_price"] = round(deal_price * (1 + data_json["config"]["profit_ratio"] / 100), 3)
65+
data_json["runBet"]["next_buy_price"] = round(deal_price * (1 - data_json["config"]["double_throw_ratio"] / 100), 2) # 保留2位小数
66+
data_json["runBet"]["grid_sell_price"] = round(deal_price * (1 + data_json["config"]["profit_ratio"] / 100), 2)
6167
data_json["runBet"]["step"] = step
6268
self._modify_json_data(data_json)
6369
print("修改后的补仓价格为:{double}。修改后的网格价格为:{grid}".format(double=data_json["runBet"]["next_buy_price"],
@@ -68,4 +74,4 @@ def modify_price(self, deal_price,step):
6874
if __name__ == "__main__":
6975
instance = RunBetData()
7076
# print(instance.modify_price(8.87,instance.get_step()-1))
71-
print(instance.get_quantity())
77+
print(instance.get_quantity(False))

0 commit comments

Comments
 (0)