This repository was archived by the owner on May 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.php
More file actions
183 lines (155 loc) · 6.92 KB
/
example.php
File metadata and controls
183 lines (155 loc) · 6.92 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
require_once './src/fxdatapi.php';
use Fxdatapi\Fxdatapi;
// Initialize the Fxdatapi SDK
$fxdatapi = new Fxdatapi();
// Set your username and password for the Currency API
$username = 'your_username';
$password = 'your_password';
// Log in to the API and obtain a token (if necessary)
$loginResult = $fxdatapi->login($username, $password);
if ($loginResult) {
echo "Login successful.\n";
} else {
die("Login failed.\n");
}
// Set currency conversion details
$date = '2023_04_05';
$baseCurrency = 'GBP';
$targetCurrency = 'EUR';
$amount = 1000;
// Set the date for which you want to retrieve the currencies
$day = '05';
$month = '04';
$year = '2023';
// Set the UUID of the currency you want to retrieve
$uuid = 'currency_uuid';
// Set the date for which you want to retrieve the daily average
$dailyAverageDate = '2023_04_10';
// Set the date range for which you want to retrieve the weekly average
$weeklyAverageFromDate = '2023_04_03';
$weeklyAverageToDate = '2023_04_07';
// Call the convert method to perform the currency conversion
$conversionResult = $fxdatapi->convert($username, $date, $baseCurrency, $targetCurrency, $amount);
if ($conversionResult) {
echo "Conversion result: " . json_encode($conversionResult) . "\n";
} else {
echo "Currency conversion failed: " . $conversionResult['error'] . "\n";
}
// Call the convertAll method to convert the base currency to all available target currencies
$convertAllResult = $fxdatapi->convertAll($username, $baseCurrency, $amount, $date);
if ($convertAllResult) {
echo "Conversion to all currencies successful:\n";
echo json_encode($convertAllResult) . "\n";
} else {
echo "Conversion to all currencies failed: " . $convertAllResult['error'] . "\n";
}
// Call the getCurrencies method to get the available currencies for the given date
$currenciesResult = $fxdatapi->getCurrencies($username, $day, $month, $year);
if ($currenciesResult) {
echo "Currencies for " . $day . "/" . $month . "/" . $year . ":\n";
echo json_encode($currenciesResult) . "\n";
} else {
echo "Failed to retrieve currencies for the given date.\n";
}
// Call the getCurrency method to get the details of the specific currency for the given date
$currencyResult = $fxdatapi->getCurrency($uuid, $username, $day, $month, $year);
if ($currencyResult) {
echo "Currency details for " . $day . "/" . $month . "/" . $year . ":\n";
echo json_encode($currencyResult) . "\n";
} else {
echo "Failed to retrieve currency details for the given date.\n";
}
// Call the getHistoricalData method to get historical data for all currencies for the given date
$historicalDataResult = $fxdatapi->getHistoricalData($username, $date, $day, $month, $year);
if ($historicalDataResult) {
echo "Historical data for " . $date . ":\n";
echo json_encode($historicalDataResult) . "\n";
} else {
echo "Failed to retrieve historical data for the given date.\n";
}
// Call the getHistoricalDataForCurrency method to get historical data for a specific currency
$historicalDataForCurrencyResult = $fxdatapi->getHistoricalDataForCurrency($uuid, $username, $day, $month, $year, $date);
if ($historicalDataForCurrencyResult) {
echo "Historical data for currency " . $uuid . " on " . $date . ":\n";
echo json_encode($historicalDataForCurrencyResult) . "\n";
} else {
echo "Failed to retrieve historical data for the given currency and date.\n";
}
// Call the getDailyAverage method to get the daily average for the given date
$dailyAverageResult = $fxdatapi->getDailyAverage($dailyAverageDate);
if ($dailyAverageResult) {
echo "Daily average for " . $dailyAverageDate . ":\n";
echo json_encode($dailyAverageResult) . "\n";
} else {
echo "Failed to retrieve daily average for the given date.\n";
}
// Call the getWeeklyAverage method to get the weekly average for the given date range
$weeklyAverageResult = $fxdatapi->getWeeklyAverage($weeklyAverageFromDate, $weeklyAverageToDate);
if ($weeklyAverageResult) {
echo "Weekly average from " . $weeklyAverageFromDate . " to " . $weeklyAverageToDate . ":\n";
echo json_encode($weeklyAverageResult) . "\n";
} else {
echo "Failed to retrieve weekly average for the given date range.\n";
}
// Call the getMonthlyAverage method to get the monthly average for the given year and month
$monthlyAverageResult = $fxdatapi->getMonthlyAverage($monthlyAverageYear, $monthlyAverageMonth);
if ($monthlyAverageResult) {
echo "Monthly average for " . $monthlyAverageYear . " and " . $monthlyAverageMonth . ":\n";
echo json_encode($monthlyAverageResult) . "\n";
} else {
echo "Failed to retrieve monthly average for the given year and month.\n";
}
// Call the getMarginsSpreads method to get the margins and spreads for the given date
$marginsSpreadsResult = $fxdatapi->getMarginsSpreads($username, $day, $month, $year);
if ($marginsSpreadsResult) {
echo "Margins and spreads for " . $day . "/" . $month . "/" . $year . ":\n";
echo json_encode($marginsSpreadsResult) . "\n";
} else {
echo "Failed to retrieve margins and spreads for the given date.\n";
}
// Call the getMarginSpread method to get the details of the specific margin or spread for the given date
$marginSpreadResult = $fxdatapi->getMarginSpread($uuid, $username, $day, $month, $year);
if ($marginSpreadResult) {
echo "Margin or spread details for " . $day . "/" . $month . "/" . $year . ":\n";
echo json_encode($marginSpreadResult) . "\n";
} else {
echo "Failed to retrieve margin or spread details for the given date.\n";
}
// Call the getAllPerformances method to get all performances
$getAllPerformancesResult = $fxdatapi->getAllPerformances($username);
if ($getAllPerformancesResult) {
echo "Performances list:\n";
echo json_encode($getAllPerformancesResult) . "\n";
} else {
echo "Failed to retrieve performances.\n";
}
// Set the UUID of the performance you want to retrieve
$performanceId = 'performance_id';
// Call the getPerformanceById method to get the details of a specific performance
$getPerformanceByIdResult = $fxdatapi->getPerformanceById($performanceId, $username);
if ($getPerformanceByIdResult) {
echo "Performance details for " . $performanceId . ":\n";
echo json_encode($getPerformanceByIdResult) . "\n";
} else {
echo "Failed to retrieve performance details for the given ID.\n";
}
// Call the getAllSignals method to get all signals
$getAllSignalsResult = $fxdatapi->getAllSignals($username);
if ($getAllSignalsResult) {
echo "Signals list:\n";
echo json_encode($getAllSignalsResult) . "\n";
} else {
echo "Failed to retrieve signals.\n";
}
// Set the UUID of the signal you want to retrieve
$signalId = 'signal_id';
// Call the getSignalById method to get the details of a specific signal
$getSignalByIdResult = $fxdatapi->getSignalById($signalId, $username);
if ($getSignalByIdResult) {
echo "Signal details for " . $signalId . ":\n";
echo json_encode($getSignalByIdResult) . "\n";
} else {
echo "Failed to retrieve signal details for the given ID.\n";
}
?>