예제 #1
0
 def __init__(self):
     self._files = []
     self._count = 0
     self._error = 0
     self._running = False
     self._thread = None
     self._connection = MongoConnection()
예제 #2
0
    def upload(self):
        j = 0
        Images_Path = "/home/dark/Programing/Major/Images/"
        collect = MongoConnection.getConnection()
        listImages = os.listdir(Images_Path)

        for i in listImages:
            with open(Images_Path + i, "rb") as imageFile:
                string = base64.b64encode(imageFile.read())
                dataDict = {"Image": string, "Camera_ID": str(j)}
                collect.insert_one(dataDict)
                j = j + 1
                os.remove(Images_Path + i)
        print(str(j) + " Images inserted in db")
예제 #3
0
import os
from extractor import PerformanceExtractor
from connection import MongoConnection

if __name__ == "__main__":
    e = PerformanceExtractor()
    file = os.path.join(os.path.abspath(os.path.dirname(__file__)), "data",
                        "CFFEX.IF HOT  MACD LE_ MACD SE 策略回测绩效报告.xls")
    e.open_with_name(file)
    strategy = e.strategy
    collection = MongoConnection().collection
    result = collection.update_one({"info.策略名称": strategy["info"]["策略名称"]},
                                   {"$set": strategy},
                                   upsert=True)
    print(result.matched_count, result.matched_count, result.upserted_id)
예제 #4
0
from connection import MongoConnection
import base64

a = []
collect = MongoConnection.getConnection()
dits = collect.find({}, {"Image": 1})
i = 0
for dit in dits:

    a.append(dit['Image'])
    imgdata = base64.b64decode(a[i])
    filename = str(i) + '.png'
    with open('/home/krypton/Documents/RetrivedImages/' + filename, 'wb') as f:
        f.write(imgdata)
    i = i + 1
print(str(i) + " Images saved")

collect = MongoConnection.getConnection()
x = collect.delete_many({})
예제 #5
0
    current_threads = len(threads)
    if  current_threads >= MAX_THREAD :
        main_logger.debug("number of threads exceeded")
        main_logger.debug("waiting to release the some threads...")
        release_threads = int(current_threads/2)
        for i in range(release_threads):
            if i is threading.current_thread():
                continue
            th = threads.pop(0)
            th.join()
            main_logger.debug(f"thread {th} released successfully")



schema = Schema("schema.txt","evaluate.txt",mandator_fields)
mongo = MongoConnection()

main_logger.info("database drivers initiated successfully ...")


docs = mongo.get_docs()
threads = []
oracle_rows = []
docs_count = docs.count()


for doc in docs:
    data = schema.pre_processing(doc)
    if data:
        oracle_rows.append(schema.checkout(data))
        if len(oracle_rows) % INSERT_COUNT == 0:
예제 #6
0
from connection import MongoConnection
import pymongo

INDEX_TUPLE = {
    "年化收益率": [("strategy_analysis.策略绩效概要.年化收益利率.所有交易", pymongo.DESCENDING)],
    "风报比": [("strategy_analysis.策略绩效概要.策略最大潜在亏损收益比.所有交易", pymongo.DESCENDING)],
    "最大回撤率":
    [("strategy_analysis.策略绩效概要.策略最大潜在亏损(%).所有交易", pymongo.DESCENDING)],
    "总盈利": [("strategy_analysis.策略绩效概要.账户资金收益比.所有交易", pymongo.DESCENDING)],
    "夏普比率": [("strategy_analysis.绩效比率.夏普比率.value", pymongo.DESCENDING)],
    "索提诺比率": [("strategy_analysis.绩效比率.Sortino 比率.value", pymongo.DESCENDING)],
    "Calmar比率":
    [("strategy_analysis.绩效比率.Calmar 比率.value", pymongo.DESCENDING)],
    "胜率": [("trade_analysis.总体交易分析.% 胜率.所有交易", pymongo.DESCENDING)],
    "平均盈利": [("trade_analysis.总体交易分析.平均盈利额.所有交易", pymongo.DESCENDING)],
    "当月收益率": [("period_analysis.Monthly Rolling Period Analysis.0.盈利(%)",
               pymongo.DESCENDING)],
    "策略名称": [("info.策略名称", pymongo.ASCENDING)],
}

if __name__ == "__main__":
    c = MongoConnection()
    indexes = [pymongo.IndexModel(v, name=k) for k, v in INDEX_TUPLE.items()]
    c.collection.create_indexes(indexes)
    print(c.collection.index_information())