New takes an input matches to relevant package assets
(input string)
| 266 | |
| 267 | // New takes an input matches to relevant package assets |
| 268 | func New(input string) (Item, error) { |
| 269 | switch input = strings.ToLower(input); input { |
| 270 | case spot: |
| 271 | return Spot, nil |
| 272 | case margin: |
| 273 | return Margin, nil |
| 274 | case marginFunding: |
| 275 | return MarginFunding, nil |
| 276 | case crossMargin: |
| 277 | return CrossMargin, nil |
| 278 | case deliveryFutures: |
| 279 | return DeliveryFutures, nil |
| 280 | case index: |
| 281 | return Index, nil |
| 282 | case binary: |
| 283 | return Binary, nil |
| 284 | case perpetualContract: |
| 285 | return PerpetualContract, nil |
| 286 | case perpetualSwap, swap: |
| 287 | return PerpetualSwap, nil |
| 288 | case spread: |
| 289 | return Spread, nil |
| 290 | case futures: |
| 291 | return Futures, nil |
| 292 | case upsideProfitContract: |
| 293 | return UpsideProfitContract, nil |
| 294 | case downsideProfitContract: |
| 295 | return DownsideProfitContract, nil |
| 296 | case coinMarginedFutures: |
| 297 | return CoinMarginedFutures, nil |
| 298 | case usdtMarginedFutures: |
| 299 | return USDTMarginedFutures, nil |
| 300 | case usdcMarginedFutures: |
| 301 | return USDCMarginedFutures, nil |
| 302 | case options, "option": |
| 303 | return Options, nil |
| 304 | case optionCombo: |
| 305 | return OptionCombo, nil |
| 306 | case futureCombo: |
| 307 | return FutureCombo, nil |
| 308 | case linearContract: |
| 309 | return LinearContract, nil |
| 310 | case all: |
| 311 | return All, nil |
| 312 | default: |
| 313 | return 0, fmt.Errorf("%w '%v', only supports %s", ErrNotSupported, input, supportedList) |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | // UseDefault returns default asset type |
| 318 | func UseDefault() Item { |
no outgoing calls