Get in touch with Limex team!
#!pip install limexhub
import limexhub
import pandas as pd
api_token = 'YOUR_API_KEY'
client = limexhub.RestAPI(token=api_token)
models = client.models()
signals = client.signals(symbol='AMZN')
candles = client.candles(symbol='AMZN')
df = signals.join(candles)
df['ret'] = df['c'].pct_change(1)
max_w = max(df['allocation'])
df['w'] = df['allocation']/max_w
df['pnl'] = df['ret'].shift(-1) * df['w']
profit = sum(100*df['pnl'].dropna())
print(f'Your PnL = {profit}')
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
token := "WFU9EF92HF" // set token
symbol := "AMZN" // set asset
apiURL := fmt.Sprintf("https://hub.limex.com/v1/news?symbol=%s&token=%s&from=2023-10-01", symbol, token)
// Make HTTP request
response, err := http.Get(apiURL)
if err != nil {
fmt.Println("Error making HTTP request:", err)
return
}
defer response.Body.Close()
// Read response body
body, err := ioutil.ReadAll(response.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return
}
// Parse JSON
var news []interface{}
err = json.Unmarshal(body, &news)
if err != nil {
fmt.Println("Error parsing JSON:", err)
return
}
// Display the first two elements
for i := 0; i < 2 && i < len(news); i++ {
fmt.Println(news[i])
}
}
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class NewsDownloader {
public static void main(String[] args) {
String token = "WFU9EF92HF"; // set token
String symbol = "AMZN"; // set asset
try {
// Download news
String apiUrl = "https://hub.limex.com/v1/news?symbol=" + symbol + "&token=" + token + "&from=2023-10-01";
String jsonResponse = makeHttpRequest(apiUrl);
// Parse JSON response
ObjectMapper objectMapper = new ObjectMapper();
JsonNode newsNode = objectMapper.readTree(jsonResponse);
// Display the first two elements
for (int i = 0; i < 2 && i < newsNode.size(); i++) {
System.out.println(newsNode.get(i));
}
} catch (IOException e) {
e.printStackTrace();
}
}
private static String makeHttpRequest(String apiUrl) throws IOException {
URL url = new URL(apiUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuilder response = new StringBuilder();
String inputLine;
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
return response.toString();
} else {
throw new IOException("HTTP request failed with response code: " + responseCode);
}
}
}
#install.packages('limexhub')
library(limexhub)
limex_token('YOUR_API_KEY')
candles_data <- candles(symbol = 'AMZN')
signals_data <- signals(symbol = 'AMZN')
df = candles_data[signals_data]
df[,ret:=shift(c,-1)/c-1]
df[,pnl:=ret*allocation/max(allocation)]
plot(cumprod(df$pnl+1)-1,type='l')
grid()