A Swift package for connecting and trading on crypto exchanges such as Kucoin and Binance via REST. Additionally:
-
π° It can calculate the stop and limit prices for a trailing stop strategy based on a set of given input parameters.
Refer to SwiftTrader+TrailingStop.swift -
π It can calculate the distance of the price of multiple buying/selling orders simultaneously, creating and placing them. This feature is particularly useful for new cryptocurrency listings. Refer to SwiftTrader+KucoinSpotHFMultiOrders.swift, CreateMultiLongLimitOrderTests.swift, and CreateMultiShortLimitOrderTests.swift for detailed input/output samples.
-
π€ Supports being deployed to Heroku (Linux). Tested with Vapor, which means automated trading by using webhooks and scripts such as the Profit Percentage Tracker (TradingView). #ka-ching! π€
Kucoin Spot | Explanation | API Documentation |
---|---|---|
SwiftTrader.kucoinSpotListAccounts |
Gets the list of accounts. | list-accounts |
SwiftTrader.kucoinSpotGetAccount |
Retrieves information for a single account. | get-an-account |
SwiftTrader.kucoinSpotGetTransferable |
Returns the transferable balance of a specified account. | get-the-transferable |
SwiftTrader.kucoinSpotPlaceStopLimitOrder |
Places a spot stop limit order. | place-a-new-order |
SwiftTrader.kucoinSpotOrderList |
Lists active Spot orders. | list-orders |
SwiftTrader.kucoinSpotStopOrderList |
Lists active Spot stop orders. | list-stop-orders |
SwiftTrader.kucoinSpotCancelStopOrders |
Cancels all untriggered stop orders of a given symbol (contract). | cancel-orders |
SwiftTrader.kucoinSpotWebSocketRequestPrivateToken |
Apply for a private token to create a WebSocket connection, subscribe to private topics, and receive private messages (e.g., account balance, open orders, etc.). | apply-connect-token-private |
Kucoin Spot HF | Explanation | API Documentation |
---|---|---|
SwiftTrader.kucoinSpotHFPlaceMultipleLongLimitOrders(_:) |
Supports sequential batch long order placement from a single endpoint. A maximum of 5orders can be placed simultaneously. | place-multiple-orders |
SwiftTrader.kucoinSpotHFPlaceMultipleLongLimitOrders(_:) |
Supports sequential batch short order placement from a single endpoint. A maximum of 5orders can be placed simultaneously. | place-multiple-orders |
Kucoin Futures | Explanation | API Documentation |
---|---|---|
SwiftTrader.kucoinFuturesAccountOverview |
Retrieves the overview of a Kucoin Futures account. | account |
SwiftTrader.kucoinFuturesStopOrderList |
Retrieves the list of un-triggered stop orders. | get-untriggered-stop-order-list |
SwiftTrader.kucoinFuturesOrderList |
Retrieves the list of active Futures orders. | get-order-list |
SwiftTrader.kucoinFuturesPlaceStopLimitOrder |
Places a Futures stop limit order. | place-an-order |
SwiftTrader.kucoinFuturesCancelStopOrders |
Cancels all untriggered Futures stop orders of a given symbol (contract). | stop-order-mass-cancelation |
SwiftTrader.kucoinFuturesPositionList |
Lists open Futures positions. | get-position-list |
Binance Spot | Explanation | API Documentation |
---|---|---|
SwiftTrader.binanceSpotNewOrder |
Send in a new order. Currently, only MARKET orders are supported (but this can be easily changed). |
new-order-trade |
Use Xcode's built-in support for SPM.
or...
In your Package.swift
, add SwiftTrader
as a dependency:
dependencies: [
.package(url: "https://github.com/backslash-f/swift-trader", from: "1.0.0")
]
Associate the dependency with your target:
targets: [
.target(
name: "YourAppName",
dependencies: [
.product(name: "SwiftTrader", package: "swift-trader")
]
)
]
Run: swift build