-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patht5_cheap_bots.py
More file actions
43 lines (35 loc) · 1.96 KB
/
Copy patht5_cheap_bots.py
File metadata and controls
43 lines (35 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import json,sys,os,requests
from datetime import datetime,date,timedelta
from time import sleep
import time
sys.path.insert(0,'functions')
from bot_config import *
from fetch_data import *
from backtest import *
#lets define the pair we want to backtest
pair = 'SOLUSDT'
#update the price data for this pair.. you should comment it out to avoid fetching data every time you are testing --> put a # in front of the line.
updatePriceData(pair)
#the date from which the backtest should start
startDate = date(2022,4,1).strftime("%Y-%m-%d %H:%M:%S")
#this date can be different from the initialStartDate we used to fetch our data.
#so we can download all data from the last 6 months but we start our backtest 3 months ago.. or 3 days.. whatever
#we will format this date as a string and it should look like this 2021-11-01 00:00:00
#the format found in the price files ('SOLUSDT.txt') needs to be the same format!!!
#the date at which the backtest should end. by default the test runs as long as data is avaiable..
endDate = date(2022,4,30).strftime("%Y-%m-%d %H:%M:%S")
#we can use getConfigsByMaxBotUsage to test all bots that have a max_amount_for_bot_usage between min and max
#this returns all bots that are less then or equal to 350$
config_list = getConfigsByMaxBotUsage(0,350)
whitelist=[]
results=[]
for config in config_list:
if config.config_name in whitelist or whitelist==[]:
result = startBacktest(config,pair,startDate,endDate)
#lets say we only want to find the configs with a profit of at least 5 percent
#if result['profit_percent'] > 5:
#print (result['config_name'],result['profit'],result['max_safety_order_price_deviation'],result['max_amount_for_bot_usage'],result['profit_percent'])
results.append(result)
print (config.config_name, result['profit'],result['max_amount_for_bot_usage'],result['profit_percent'])
#we can save the result to a csv file for further analysis (folder = results)
saveResult(results,'cheap_bots.csv')