-
Notifications
You must be signed in to change notification settings - Fork 149
/
gvars.py
76 lines (62 loc) · 2.56 KB
/
gvars.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# encoding: utf-8
# This code is free, THANK YOU!
# It is explained at the guide you can find at www.theincompleteguide.com
# You will also find improvement ideas and explanations
from pathlib import Path
from datetime import datetime
MAX_WORKERS = 10 # max threads at a time
gainRatio = 1.5 # takeProfit = -stopLoss*gainRatio
stopLossMargin = 0.05 # extra margin for the stop loss
operEquity = 10000 # defines the target amount per execution ($)
limitOrderMargin = 0.1 # percentage that defines the offset for the limit orders
# YOUR API KEYS AT ALPACA GO HERE!
API_KEY = ""
API_SECRET_KEY = ""
ALPACA_API_URL = "https://paper-api.alpaca.markets"
# this block checks whether you have your keys written or not
if API_KEY is "" or API_SECRET_KEY is "":
print('\n\n##### \n\nPlease get an API key at the Alpaca website! \n\n##### \n\n')
raise ValueError
################################################################ ATTEMPTS ->
# max iteration attempts for the different actions
maxAttempts = {
'SO':5, # SUBMIT ORDER
'CP':5, # CHECK POSITION
'CO':5, # CANCEL ORDER
'LHD1':10, # LOAD HISTORICAL DATA 1
'LHD2':20 # LOAD HISTORICAL DATA 2
}
# limit for the indicators
limStoch = {
'maxBuy':75, # max allowed value to buy
'minSell':25 # min allowed value to sell
}
################################################################ TIMEFRAMES ->
# fetch historical data intervals
fetchItval = {
'little':'5Min',
'big':'30Min'
}
# timeouts that will kill a process
timeouts = {
'GT':0 # if 0, it discards a bad general trend instantly
}
# waiting time before repeating each iteration
sleepTimes = {
'GT': 10*60, # general trend
'IT': 2*60, # instant trend
'RS': 60, # RSI
'ST': 60, # stochastic every minut
'CO': 10, # check order every 10 seconds
'SO': 5, # submit order every 5 seconds
'LH': 5, # load_historical_data
'PF': 10, # price fetch (current price)
'CP': 10, # check position, to check if it entered
'GS': 60, # get slope inside enter position
'UA': 10*60 # unlock assets
}
################################################################ PATHS ->
home = str(Path.home())
FILES_FOLDER = home + '/tbot_files_test/'
RAW_ASSETS = './_raw_assets.csv' # you should have this list at the same folder than everything
LOGS_PATH = FILES_FOLDER + 'logs/'