Your Name 3 tahun lalu
melakukan
8b4071351c
4 mengubah file dengan 116 tambahan dan 0 penghapusan
  1. 63 0
      com_read_data.py
  2. 8 0
      db_readtest.py
  3. 32 0
      mt5_to_amibroker.py
  4. 13 0
      readdata.py

+ 63 - 0
com_read_data.py

@@ -0,0 +1,63 @@
+# -*- coding: utf-8 -*-
+import codecs
+import time
+import traceback
+import sys
+import time
+from datetime import date
+import datetime
+import traceback
+import os
+import subprocess
+import ctypes
+import time
+import os
+import pythoncom
+import win32com
+import win32com.client 
+from subprocess import Popen
+import threading
+import traceback
+
+
+def gen_and_save(AB,itemnum,tabnum,fname):
+    width=1024
+    height=768
+    AB.Documents.Item(itemnum).Windows.Item(0).Activate()
+    AB.ActiveDocument.ActiveWindow.SelectedTab=tabnum
+    AW = AB.Documents.Item(itemnum).Windows.Item(0)
+    prefix='c:/gitlab/win10-forex/static'
+    img = prefix+"/"+fname
+    print(AW.ExportImage( img,width,height))
+    time.sleep(0.2)
+
+
+def runTA():
+    try:
+        width=1024
+        height=768
+        dtnow=datetime.datetime.now()
+        si = subprocess.STARTUPINFO()
+        si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
+        AB = win32com.client.Dispatch("Broker.Application")
+        pythoncom.CoInitialize()
+        AB.Documents.Item(0).Windows.Item(0).Activate()
+        AB.ActiveDocument.ActiveWindow.SelectedTab=0
+        time.sleep(4)
+
+#        gen_and_save(AB,0,0,'ec.png')
+
+#        gen_and_save(AB,2,0,'cad.png')
+#        gen_and_save(AB,2,1,'ydx.png')
+#        gen_and_save(AB,4,0,'day.png')
+
+        AB.SaveDatabase()
+        pythoncom.CoUninitialize()
+		
+    except Exception:
+         print("exception ")  
+         traceback.print_exc()
+
+
+runTA()
+

+ 8 - 0
db_readtest.py

@@ -0,0 +1,8 @@
+from ami2py import AmiDataBase, SymbolEntry
+db = AmiDataBase('c:\\amibroker')
+symbols = db.get_symbols()
+print(symbols)
+
+data=db.get_symbol_data('M1ECH')
+#data = db.get_dict_for_symbol("hour")
+print(data)

+ 32 - 0
mt5_to_amibroker.py

@@ -0,0 +1,32 @@
+import os
+import codecs
+import datetime
+import dataset
+
+#fw=codecs.open('c:/tmp/halfday.csv','w','utf-8')
+fw=codecs.open('c:/tmp/hour.csv','w','utf-8')
+
+fw.write('aaa\n')
+fw.write('aaa\n')
+
+#fr=codecs.open('c:/tmp/h12.csv','r','utf-8')
+#fr=codecs.open('c:/tmp/m30.csv','r','utf-8')
+fr=codecs.open('c:/tmp/h1.csv','r','utf-8')
+
+lines=fr.readlines()[1:]
+fr.close()
+
+for l in lines:
+    elmts=l.split('\t')
+    o=int(float(elmts[2])*10000)
+    h=int(float(elmts[3])*10000)
+    l=int(float(elmts[4])*10000)
+    c=int(float(elmts[5])*10000)
+
+    dt=elmts[0].replace('.','/')+" "+elmts[1]+","+str(o)+","+str(h)+","+str(l)+","+str(c)+',0,\n'
+    entry=dt
+    fw.write(entry)
+    print(entry)
+
+fw.close()
+

+ 13 - 0
readdata.py

@@ -0,0 +1,13 @@
+import codecs
+import numpy
+
+price_ary=[]
+fr=codecs.open('c:/tmp/hour.csv','r','utf-8')
+lines=fr.readlines()
+fr.close()
+for l in lines[1:]:
+    elmts=l.split('\t')
+    val=int(float(elmts[5])*10000)
+    price_ary.append(val)
+
+print(price_ary)