File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -21,12 +21,8 @@ public extension SwiftTrader {
21
21
let profitPercentage : Double = ( input. profitPercentage / 100 )
22
22
logger. log ( " Profit percentage: \( profitPercentage. toDecimalString ( ) ) " )
23
23
24
- // Instead of creating an order with a fixed target percentage (say 0.025), add some fat to it (e.g.: 0.027)
25
- let offsetMargin : Double = 0.02
26
- logger. log ( " Offset margin: \( offsetMargin. toDecimalString ( ) ) " )
27
-
28
- // E.g.: (0.75 - 0.02) / 100 = 0.0073, which translates to 0.0027 (0,27%)
29
- let offset : Double = ( input. offset - offsetMargin) / 100
24
+ // E.g.: 0.75 -> 0.0075
25
+ let offset : Double = ( input. offset / 100 )
30
26
logger. log ( " Offset: \( offset. toDecimalString ( ) ) " )
31
27
32
28
// E.g.: (0.0747 - 0.0073) = 0.0674 (6,74%)
Original file line number Diff line number Diff line change @@ -97,7 +97,15 @@ public extension SwiftTrader {
97
97
/// - Returns: An instance of `KucoinFuturesPlaceOrder` or `SwiftTraderError`.
98
98
func kucoinFuturesPlaceOrder( _ orderInput: SwiftTraderOrderInput ) async throws -> Result < KucoinFuturesPlaceOrder , SwiftTraderError > {
99
99
100
+ #warning("TODO: parameterize cleaning up untriggered stop orders")
100
101
let orderParameters = try createOrderParameters ( for: orderInput)
102
+
103
+ do {
104
+ #warning("TODO: test")
105
+ try await kucoinFuturesCancelStopOrders ( symbol: orderInput. contractSymbol)
106
+ } catch {
107
+ #warning("TODO: log")
108
+ }
101
109
102
110
let request = KucoinFuturesPlaceOrdersRequest (
103
111
orderParameters: orderParameters,
@@ -124,7 +132,7 @@ public extension SwiftTrader {
124
132
///
125
133
/// - Parameter symbol: `String`, represents the specific contract for which all the untriggered stop orders will be cancelled.
126
134
/// - Returns: An instance of `KucoinFuturesCancelStopOrders` or `SwiftTraderError`.
127
- func kucoinFuturesCancelStopOrders( symbol: String ) async throws -> Result < KucoinFuturesCancelStopOrders , SwiftTraderError > {
135
+ @ discardableResult func kucoinFuturesCancelStopOrders( symbol: String ) async throws -> Result < KucoinFuturesCancelStopOrders , SwiftTraderError > {
128
136
let request = KucoinFuturesCancelOrdersRequest (
129
137
symbol: symbol,
130
138
kucoinAuth: kucoinAuth,
You can’t perform that action at this time.
0 commit comments