forked from Connie-Wild/ChannelBreakoutBot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
trade.py
53 lines (47 loc) · 1.67 KB
/
trade.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
#_*_ coding: utf-8 _*_
#https://sshuhei.com
import json
import logging
from src import channel
import os
if __name__ == '__main__':
#logging設定
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s %(levelname)s: %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
logfile=logging.handlers.TimedRotatingFileHandler(
filename = 'log/trade.log',
when = 'midnight'
)
logfile.setLevel(logging.INFO)
logfile.setFormatter(logging.Formatter(
fmt='%(asctime)s %(levelname)s: %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'))
logging.getLogger('').addHandler(logfile)
logging.info('Wait...')
#config.jsonの読み込み
f = open('config/config.json', 'r', encoding="utf-8")
config = json.load(f)
#channelBreakOut設定値
channelBreakOut = channel.ChannelBreakOut()
channelBreakOut.lot = config["lotSize"]
channelBreakOut.entryTerm = config["entryTerm"]
channelBreakOut.closeTerm = config["closeTerm"]
channelBreakOut.rangePercent = config["rangePercent"]
channelBreakOut.rangePercentTerm = config["rangePercentTerm"]
channelBreakOut.rangeTerm = config["rangeTerm"]
channelBreakOut.rangeTh = config["rangeTh"]
channelBreakOut.waitTerm = config["waitTerm"]
channelBreakOut.waitTh = config["waitTh"]
channelBreakOut.candleTerm = config["candleTerm"]
channelBreakOut.sfdLimit = config["sfdLimit"]
channelBreakOut.fileName = None
# 約定履歴ファイルを引き継がない場合は削除
if config["keepPosition"]==False :
try:
os.remove( 'log/orderhistory.csv' )
except:
pass
#実働
channelBreakOut.loop()