Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sreenivasdoosa
GitHub Repository: sreenivasdoosa/sdoosa-algo-trade-python
Path: blob/master/src/config/Config.py
296 views
1
import json
2
import os
3
4
def getServerConfig():
5
with open('../config/server.json', 'r') as server:
6
jsonServerData = json.load(server)
7
return jsonServerData
8
9
def getSystemConfig():
10
with open('../config/system.json', 'r') as system:
11
jsonSystemData = json.load(system)
12
return jsonSystemData
13
14
def getBrokerAppConfig():
15
with open('../config/brokerapp.json', 'r') as brokerapp:
16
jsonUserData = json.load(brokerapp)
17
return jsonUserData
18
19
def getHolidays():
20
with open('../config/holidays.json', 'r') as holidays:
21
holidaysData = json.load(holidays)
22
return holidaysData
23
24
def getTimestampsData():
25
serverConfig = getServerConfig()
26
timestampsFilePath = os.path.join(serverConfig['deployDir'], 'timestamps.json')
27
if os.path.exists(timestampsFilePath) == False:
28
return {}
29
timestampsFile = open(timestampsFilePath, 'r')
30
timestamps = json.loads(timestampsFile.read())
31
return timestamps
32
33
def saveTimestampsData(timestamps = {}):
34
serverConfig = getServerConfig()
35
timestampsFilePath = os.path.join(serverConfig['deployDir'], 'timestamps.json')
36
with open(timestampsFilePath, 'w') as timestampsFile:
37
json.dump(timestamps, timestampsFile, indent=2)
38
print("saved timestamps data to file " + timestampsFilePath)
39
40