From 17cc863672bc9ae94ecfaa8436d4d9ef651c4d0e Mon Sep 17 00:00:00 2001 From: ened Date: Sun, 7 Jul 2024 18:22:24 +0900 Subject: [PATCH] Add KissMeSacks module --- KissMeSacks/Package.swift | 34 ++ KissMeSacks/README.md | 28 ++ KissMeSacks/Sources/CandleCache.swift | 46 +++ KissMeSacks/Sources/KissSacks.swift | 18 ++ KissMeSacks/Sources/main.swift | 10 + .../contents.xcworkspacedata | 3 + .../KissMeSacks.xcodeproj/project.pbxproj | 303 ++++++++++++++++++ .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + 9 files changed, 457 insertions(+) create mode 100644 KissMeSacks/Package.swift create mode 100644 KissMeSacks/README.md create mode 100644 KissMeSacks/Sources/CandleCache.swift create mode 100644 KissMeSacks/Sources/KissSacks.swift create mode 100644 KissMeSacks/Sources/main.swift create mode 100644 projects/macos/KissMeSacks.xcodeproj/project.pbxproj create mode 100644 projects/macos/KissMeSacks.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 projects/macos/KissMeSacks.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/KissMeSacks/Package.swift b/KissMeSacks/Package.swift new file mode 100644 index 0000000..931e8dc --- /dev/null +++ b/KissMeSacks/Package.swift @@ -0,0 +1,34 @@ +// swift-tools-version: 5.8 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "KissMeSacks", + platforms: [ + .macOS(.v13), .iOS(.v14), .tvOS(.v14) + ], + products: [ + // Products define the executables and libraries a package produces, and make them visible to other packages. + .executable( + name: "KissMeSacks", + targets: ["KissMeSacks"]), + ], + dependencies: [ + // Dependencies declare other packages that this package depends on. + //.package(url: "../KissMe", from: "1.0.0"), + .package(path: "../KissMe"), + ], + targets: [ + // Targets are the basic building blocks of a package. A target can define a module or a test suite. + // Targets can depend on other targets in this package, and on products in packages this package depends on. + .executableTarget( + name: "KissMeSacks", + dependencies: ["KissMe"], + path: "Sources"), + //.testTarget( + // name: "KissMeSacksTests", + // dependencies: ["KissMeSacks"], + // path: "Tests"), + ] +) diff --git a/KissMeSacks/README.md b/KissMeSacks/README.md new file mode 100644 index 0000000..5bf5d5e --- /dev/null +++ b/KissMeSacks/README.md @@ -0,0 +1,28 @@ +# KissMeSacks + +KissMeSacks 는 분봉을 바탕으로 가상의 매매를 시뮬레이션 해주는 도구입니다. + +## Concept + +* 황금 고블린이 스폰(매수)되어 돌아다니다가, 사냥이 완료되면 전설의 아이템을 드랍(매도)하고 사라지는 컨셉에 착안합니다. +* 아이템 드랍이 없으면 Nothing 이 되고, 다음 기회를 기다립니다. + +## Design + +* 분봉을 n초 단위로 s=(60/n)구간을 나눕니다. (기본값 n=20) +* 각 s구간마다 매수(Buy)/매도(Sell)/Nothing 을 수행합니다. +* 매수(Buy)를 위한 HP energy 를 채워야 하고, HP energy 가 가득차게 되면 매수(Buy)를 수행합니다. +* 매수(Buy)가 된 상태에서 MP energy 를 채워야 하고, MP energy 가 가득차게 되면 매도(Sell)를 수행합니다. +* 매수(Buy)가 된 상태에서 지속적으로 SP energy 가 채워지고, SP energy 가 가득차게 되면 손절(Sell)을 수행합니다. + +### HP design + +* + +### MP design + +* + +### SP design + +* diff --git a/KissMeSacks/Sources/CandleCache.swift b/KissMeSacks/Sources/CandleCache.swift new file mode 100644 index 0000000..974845a --- /dev/null +++ b/KissMeSacks/Sources/CandleCache.swift @@ -0,0 +1,46 @@ +// +// CandleCache.swift +// KissMeSacks +// +// Created by ened-book-m1 on 7/7/24. +// + +import KissMe + +public class CandleCache { + + private var candleCaches: [String: [Domestic.Candle]] = [:] + + func getCandle(productNo: String, day: String, time: String) -> Domestic.Candle? { + let basePath = URL.currentDirectory().appending(path: "data") + let candleUrl = basePath.appending(path: "\(productNo)/min/candle-\(day).log") + + let candles: [Domestic.Candle] + + if let cache = candleCaches[candleUrl.path] { + candles = cache + } + else { + do { + candles = try [Domestic.Candle].readCsv(fromFile: candleUrl) + candleCaches[candleUrl.path] = candles + } catch { + printError(error) + return nil + } + } + + guard let candle = candles.first(where: { $0.stockConclusionTime == time }) else { + return nil + } + return candle + } + + + func getPrice(productNo: String, day: String, time: String) -> Int? { + guard let candle = getCandle(productNo: productNo, day: day, time: time) else { + return nil + } + return Int(candle.currentStockPrice) + } +} diff --git a/KissMeSacks/Sources/KissSacks.swift b/KissMeSacks/Sources/KissSacks.swift new file mode 100644 index 0000000..bcf598f --- /dev/null +++ b/KissMeSacks/Sources/KissSacks.swift @@ -0,0 +1,18 @@ +// +// KissSacks.swift +// KissMeSacks +// +// Created by ened-book-m1 on 6/25/24. +// + +import Foundation +import KissMe + + +class KissSacks: KissMe.ShopContext { + let cache = CandleCache() + + func run() { + //cache.getPrice(productNo: , day: , time: ) + } +} diff --git a/KissMeSacks/Sources/main.swift b/KissMeSacks/Sources/main.swift new file mode 100644 index 0000000..f4ec2b6 --- /dev/null +++ b/KissMeSacks/Sources/main.swift @@ -0,0 +1,10 @@ +// +// main.swift +// KissMeSacks +// +// Created by ened-book-m1 on 6/25/24. +// + +import Foundation + +KissSacks().run() diff --git a/projects/macos/KissMe.xcworkspace/contents.xcworkspacedata b/projects/macos/KissMe.xcworkspace/contents.xcworkspacedata index d81ad0d..22f43a9 100644 --- a/projects/macos/KissMe.xcworkspace/contents.xcworkspacedata +++ b/projects/macos/KissMe.xcworkspace/contents.xcworkspacedata @@ -13,6 +13,9 @@ + + diff --git a/projects/macos/KissMeSacks.xcodeproj/project.pbxproj b/projects/macos/KissMeSacks.xcodeproj/project.pbxproj new file mode 100644 index 0000000..f5ea3f4 --- /dev/null +++ b/projects/macos/KissMeSacks.xcodeproj/project.pbxproj @@ -0,0 +1,303 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 56; + objects = { + +/* Begin PBXBuildFile section */ + 349B05262C2A234000378D55 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 349B05252C2A234000378D55 /* main.swift */; }; + 349B052D2C2A2AAF00378D55 /* KissSacks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 349B052C2C2A2AAF00378D55 /* KissSacks.swift */; }; + 349B052F2C3A938000378D55 /* CandleCache.swift in Sources */ = {isa = PBXBuildFile; fileRef = 349B052E2C3A938000378D55 /* CandleCache.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 349B05202C2A234000378D55 /* CopyFiles */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = /usr/share/man/man1/; + dstSubfolderSpec = 0; + files = ( + ); + runOnlyForDeploymentPostprocessing = 1; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 349B05222C2A234000378D55 /* KissMeSacks */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = KissMeSacks; sourceTree = BUILT_PRODUCTS_DIR; }; + 349B05252C2A234000378D55 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = ""; }; + 349B052C2C2A2AAF00378D55 /* KissSacks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KissSacks.swift; sourceTree = ""; }; + 349B052E2C3A938000378D55 /* CandleCache.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CandleCache.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 349B051F2C2A234000378D55 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 349B05192C2A234000378D55 = { + isa = PBXGroup; + children = ( + 349B05242C2A234000378D55 /* KissMeSacks */, + 349B05232C2A234000378D55 /* Products */, + ); + sourceTree = ""; + }; + 349B05232C2A234000378D55 /* Products */ = { + isa = PBXGroup; + children = ( + 349B05222C2A234000378D55 /* KissMeSacks */, + ); + name = Products; + sourceTree = ""; + }; + 349B05242C2A234000378D55 /* KissMeSacks */ = { + isa = PBXGroup; + children = ( + 349B05252C2A234000378D55 /* main.swift */, + 349B052C2C2A2AAF00378D55 /* KissSacks.swift */, + 349B052E2C3A938000378D55 /* CandleCache.swift */, + ); + name = KissMeSacks; + path = ../../KissMeSacks/Sources; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 349B05212C2A234000378D55 /* KissMeSacks */ = { + isa = PBXNativeTarget; + buildConfigurationList = 349B05292C2A234000378D55 /* Build configuration list for PBXNativeTarget "KissMeSacks" */; + buildPhases = ( + 349B051E2C2A234000378D55 /* Sources */, + 349B051F2C2A234000378D55 /* Frameworks */, + 349B05202C2A234000378D55 /* CopyFiles */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = KissMeSacks; + productName = KissMeSacks; + productReference = 349B05222C2A234000378D55 /* KissMeSacks */; + productType = "com.apple.product-type.tool"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 349B051A2C2A234000378D55 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1540; + LastUpgradeCheck = 1540; + TargetAttributes = { + 349B05212C2A234000378D55 = { + CreatedOnToolsVersion = 15.4; + }; + }; + }; + buildConfigurationList = 349B051D2C2A234000378D55 /* Build configuration list for PBXProject "KissMeSacks" */; + compatibilityVersion = "Xcode 14.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 349B05192C2A234000378D55; + productRefGroup = 349B05232C2A234000378D55 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 349B05212C2A234000378D55 /* KissMeSacks */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 349B051E2C2A234000378D55 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 349B05262C2A234000378D55 /* main.swift in Sources */, + 349B052F2C3A938000378D55 /* CandleCache.swift in Sources */, + 349B052D2C2A2AAF00378D55 /* KissSacks.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 349B05272C2A234000378D55 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 14.5; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = macosx; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)"; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 349B05282C2A234000378D55 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++20"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_USER_SCRIPT_SANDBOXING = YES; + GCC_C_LANGUAGE_STANDARD = gnu17; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + LOCALIZATION_PREFERS_STRING_CATALOGS = YES; + MACOSX_DEPLOYMENT_TARGET = 14.5; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = macosx; + SWIFT_COMPILATION_MODE = wholemodule; + }; + name = Release; + }; + 349B052A2C2A234000378D55 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = NYU8YAYHF8; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Debug; + }; + 349B052B2C2A234000378D55 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + CODE_SIGN_STYLE = Automatic; + DEVELOPMENT_TEAM = NYU8YAYHF8; + ENABLE_HARDENED_RUNTIME = YES; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 349B051D2C2A234000378D55 /* Build configuration list for PBXProject "KissMeSacks" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 349B05272C2A234000378D55 /* Debug */, + 349B05282C2A234000378D55 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 349B05292C2A234000378D55 /* Build configuration list for PBXNativeTarget "KissMeSacks" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 349B052A2C2A234000378D55 /* Debug */, + 349B052B2C2A234000378D55 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 349B051A2C2A234000378D55 /* Project object */; +} diff --git a/projects/macos/KissMeSacks.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/projects/macos/KissMeSacks.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..919434a --- /dev/null +++ b/projects/macos/KissMeSacks.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/projects/macos/KissMeSacks.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/projects/macos/KissMeSacks.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/projects/macos/KissMeSacks.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + +