-
Notifications
You must be signed in to change notification settings - Fork 6
/
CoinbasePro-Powershell.psm1
96 lines (86 loc) · 3.24 KB
/
CoinbasePro-Powershell.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
Get-ChildItem -Path $PSScriptRoot -Recurse -File | Unblock-File
Get-ChildItem -Path $PSScriptRoot\*.ps1 -Recurse | Foreach-Object{ . $_.FullName }
$FunctionsToExport = @(
'Get-CoinbaseAccounts',
'Get-CoinbaseProAccounts',
'Get-CoinbaseProAccountHistory',
'Get-CoinbaseProFees',
'Get-CoinbaseProAccountHolds',
'Get-CoinbaseProProducts',
'Get-CoinbaseProCurrencies',
'Get-CoinbaseProTime',
'Get-CoinbaseProFills',
'Get-CoinbaseProOrder',
'Get-CoinbaseProOrders',
'Get-CoinbaseProProductOrderBook',
'Get-CoinbaseProProductTicker',
'Get-CoinbaseProProductTrades',
'Get-CoinbaseProProductStats',
'New-CoinbaseProLimitOrder',
'New-CoinbaseProMarketOrder',
'New-CoinbaseProStopOrder',
'New-CoinbaseProConversionOrder',
'Get-CoinbaseProPaymentMethods',
'Invoke-CoinbaseProDeposit',
'Invoke-CoinbaseProWithdrawal',
'Remove-CoinbaseProOrder',
'Get-CoinbaseProTransfers',
'Get-CoinbaseProProfiles',
'Get-CoinbaseProProfile',
'Invoke-CoinbaseProProfileTransfer',
'Get-CoinbaseProMarginInfo',
'Get-CoinbaseProMarginBuyingPower',
'Get-CoinbaseProMarginWithdrawalPower',
'Get-CoinbaseProMarginExitPlan',
'Get-CoinbaseProMarginStatus',
'Get-CoinbaseProMarginPositionRefreshAmounts',
'Get-CoinbaseProMarginLiquidationHistory',
'Get-CoinbaseProTrailingVolume'
)
$CBProducts = Get-CoinbaseProProducts
$CBCurrencies = Get-CoinbaseProCurrencies
if (!$CBProducts -or !$CBCurrencies) {
Throw "Unable to import Coinbase Pro products & currencies."
Break
} else {
$CBProducts | select-object id | ConvertTo-Csv | out-file "$([system.io.path]::GetTempPath())/CoinbaseProPS-products.csv" -Force
$CBCurrencies | select-object id | ConvertTo-Csv | out-file "$([system.io.path]::GetTempPath())CoinbaseProPS-currencies.csv" -Force
Write-Host "Coinbase Pro Module Imported: $($CBProducts.count) Tradable Products and $($CBCurrencies.count) Currencies" -ForegroundColor Green
}
$Products = {
$CBProducts | Select-Object -ExpandProperty id | ForEach-Object {
"$_"
}
}
$Currencies = {
$CBCurrencies | Select-Object -ExpandProperty id | ForEach-Object {
"$_"
}
}
$ProductFunctions = @(
'New-CoinbaseProLimitOrder',
'Get-CoinbaseProFills',
'New-CoinbaseProMarketOrder',
'New-CoinbaseProStopOrder',
'Get-CoinbaseProOrders',
'Remove-CoinbaseProOrder',
'Get-CoinbaseProProductOrderBook',
'Get-CoinbaseProProductStats',
'Get-CoinbaseProProductTicker',
'Get-CoinbaseProProductTrades',
'Get-CoinbaseProMarginMarginInfo',
'Get-CoinbaseProMarginBuyingPower'
)
Foreach ($function in $ProductFunctions) {
Register-ArgumentCompleter -CommandName $function -ParameterName 'ProductID' -ScriptBlock $Products
}
$CurrencyFunctions = @(
'New-CoinbaseProConversionOrder',
'Get-CoinbaseProMarginWithdrawalPower'
)
Foreach ($function in $CurrencyFunctions) {
Register-ArgumentCompleter -CommandName $function -ParameterName 'To' -ScriptBlock $Currencies
Register-ArgumentCompleter -CommandName $function -ParameterName 'From' -ScriptBlock $Currencies
Register-ArgumentCompleter -CommandName $function -ParameterName 'Currency' -ScriptBlock $Currencies
}
Export-ModuleMember -Function $FunctionsToExport