Questions tagged [dolphindb]

DolphinDB is a high performance time series database. It is written in C++ and optimized for fast injection, storage, retrieval and analysis of time series data in fields such as quantitative finance, Internet of Things, real-time analytics, etc. DolphinDB runs extremely fast. It is also easy to use as the syntax of the programming language of DolphinDB is similar to SQL and Python.

Filter by
Sorted by
Tagged with
0 votes
1 answer
14 views

DolphinDB: how to perform iterative operations based on previous results using SQL statements?

I intend to calculate a column named “position“ with an initial value of 0. The calculation logic is: when “position” = 0 and “ov95” = 1, “position” returns 1; when “position” = 1 and “ov70” = 0, “...
zhihengqu's user avatar
  • 421
1 vote
1 answer
10 views

DolphinDB: Fail to parse function definitions submitted by submitJob

When running the following code directly with run_factor(), it executes successfully. However, when I use the submitJob function, an error occurs: Syntax Error: [line #1] Cannot recognize the token ...
biggggtomato's user avatar
0 votes
1 answer
9 views

Failed to grant permission in DolphinDB

I create a user and grant him read permission for all databases and tables. However, when I log in as this user, related permission is not granted as expected. The following is my script: grant('...
biggggtomato's user avatar
0 votes
1 answer
35 views

How to correctly write SQL metacode in metaprogramming?

Here is my script: snap = loadTable("dfs://China_Market_HF", `Market_Snapshot) select count(*) from snap where Date = 2015.01.15 exec(<select count(*) from snap where Date = 2015.01.15>...
biggggtomato's user avatar
0 votes
1 answer
9 views

Passing variables in DolphinDB metaprogramming

Is it feasible to replace a specified value with a variable in metaprogramming? For example, I intend to replace where Date = 2015.01.15 with where Date = $(date), in which “date“ is a variable.
biggggtomato's user avatar
0 votes
1 answer
22 views

how to perform factor calculation using sliding windows with elements from different columns?

Suppose there is a table with 6 columns: “date”, “symbol”, “a”, “b”, “c”, and “d”. I intend to calculate a factor with a sliding window of length 10, grouped by “symbol“. I intend that the first 9 ...
carbonhydrate's user avatar
0 votes
1 answer
23 views

How to download and save BLOB data to local storage through DolphinDB Python API?

When I save a table with PROTOCOL_PICKLE, an error occurs: Server response: 'pickle not support BLOB. IP[]. uuid[]. int128[]'. The following is my script: t = loadTable("dfs://GILDATA....
carbonhydrate's user avatar
0 votes
1 answer
18 views

In DolphindDB, is it feasible to use the SET...IF statement with UPDATE in SQL queries?

Does DolphinDB support the following script? update tmp set exchangecd='XSHG' if exchangecd='SH' set exchangecd='XSHE' if exchangecd='sz'
jinwandalaohu's user avatar
1 vote
1 answer
11 views

How to address the DolphinDB error: The function [nullFill] expects 2 argument(s), but the actual number of arguments is: 1?

For the following script, DolphinDB reports the error: The function [nullFill] expects 2 argument(s), but the actual number of arguments is: 1 . sqlCol(zfill_col, nullFill(0), zfill_col)) How to ...
jinwandalaohu's user avatar
-1 votes
1 answer
16 views

Question with the result of fj (full join) in DolphinDB

Part 1: test_fj = fj(t_test_821, t_test, `trade_date `strategy_id `secu_code) select * from test_fj where trade_date=2019.08.27 and strategy_id=5026 Part 2: ttt1 = select * from t_test_821 where ...
jinwandalaohu's user avatar
1 vote
2 answers
36 views

how to retrieve the Nth-to-last element in a vector?

I have a question about DolphinDB: how to retrieve the Nth-to-last element in a vector? For example, I want to access the second-to-last element. In Python, I can use v[-2]. How can I do this in ...
jinwandalaohu's user avatar
0 votes
2 answers
32 views

How to calculate the difference in trading days within a date vector?

I have a date vector containing trading days. I would like to subtract N trading days from this vector, or find out the number of trading days between two dates in this vector. For instance, I want to ...
damie's user avatar
  • 437
0 votes
1 answer
18 views

How to remove the last row of a table in DolphinDB?

Is there a way to remove the last row of a table in DolphinDB? Take the following table as an example: t = table(1..5 as id) How can I remove the record with id=5?
damie's user avatar
  • 437
0 votes
1 answer
16 views

How to calculate the weighted sum of columns in tables stored in a dictionary in DolphinDB?

There are N tables with the same structure, consisting of three columns: “datetime“, ”symbol“, and ”faN“. I store these tables in a dictionary named datadict, where the keys match the names in the ...
lulunolemon's user avatar
1 vote
1 answer
11 views

How to control the total row count of a stream table in DolphinDB?

I need to insert records to a persistent stream table, but I'm concerned about it growing too large. I aim to cap the row count at specific rows (e.g. 1000). This would not only reduce memory usage ...
lulunolemon's user avatar
1 vote
1 answer
15 views

How to remove rows with 0 values from an indexed series in DolphinDB?

I have a series indexed by date: s = indexedSeries(2011.12.30..2012.01.01, [0, 60, 0]) I want to remove all rows with 0 values from the series. How should I script this in DolphinDB?
lulunolemon's user avatar
0 votes
1 answer
11 views

How to merge tables with different number of columns in DolphinDB?

I want to join tables with different number of columns into a single table. Is there a more efficient way to do this, apart from using iterative appending via a for loop?
lulunolemon's user avatar
0 votes
1 answer
75 views

How to calculate the distance to the nearest higher value in DolphinDB?

In my dataset, there's a column named “f1“. Given a specific row with a value of 10, I want to find the nearest higher value above it, which is 11 in the first row. The distance between them is 4 (...
Smalllpotato's user avatar
0 votes
1 answer
19 views

Why don't TCP connections automatically close on timeout?

I use the getConnections() function to check the number of active connections: I've configured the timeout setting with tcp_keepalive_time set to 7200 (i.e., 2 hours). However, the connections are ...
Smalllpotato's user avatar
0 votes
1 answer
9 views

How to set the partitionCol parameter when using "MultithreadedTableWriter" to write data into a DolphinDB COMPO-partitioned table?

Below is the script for creating databases and tables: db1 = database('',VALUE,2016.11.15..2016.11.18) db2 = database('',HASH,[SYMBOL,10]) db = database('dfs://iot',COMPO,[db1,db2]) schema=table(1:0,`...
molddd123's user avatar
  • 305
0 votes
1 answer
26 views

How to write ClickHouse OVER statement in DolphinDB?

I have a query in ClickHouse with the following syntax: avg(ask) over(partition by sym order by time asc rows between 13 preceding and 0 following) How can I write a DolphinDB script that can achieve ...
molddd123's user avatar
  • 305
0 votes
1 answer
21 views

How to import a CSV file into a partitioned table with MultithreadedTableWriter provided by DolphinDB C++ API?

I have a CSV file and the first 10 records of the file are as follows: time device_id battery_level battery_status battery_temperature bssid cpu_avg_1min cpu_avg_5min cpu_avg_15min ...
molddd123's user avatar
  • 305
1 vote
2 answers
30 views

How to calculate the Cartesian product of two vectors?

Is there an efficient method to calculate the Cartesian product of two vectors in DolphinDB? For example, given the vectors ['aa', 'bb'] and ['cc', 'dd'], the desired result is ['aacc', 'aadd', 'bbcc',...
Claire's user avatar
  • 310
0 votes
1 answer
12 views

How to add an output column without altering the original logic in a metaprogramming script?

In the following metaprogramming script: def generateReport(tbl, colNames, colFormat): sql(sqlColAlias(each(makeCall{format},sqlCol(colNames),colFormat),colNames), tbl).eval() t = table(1..100 as id, (...
Claire's user avatar
  • 310
1 vote
1 answer
14 views

Error occurs when updating values of a nested dictionary in DolphinDB

As shown in the following script, I want to update values of a nested dictionary “d2“: d1 = dict( STRING, ANY ) d2 = dict( STRING, ANY ) d2[`d2_K] = 1 d1[`d1_K] = d2 d1[`d1_K][`d2_K] = 3 But when I ...
carbonhydrate's user avatar
1 vote
1 answer
10 views

An easier method to extract the last four elements of a vector in DolphinDB?

I want to extract the last four elements of a vector in DolphinDB. For example: v=1..9 v[5:9] Output: I'd like to find an easier method to achieve this, so I tried the following method: l=size(v) v[...
molddd123's user avatar
  • 305
0 votes
1 answer
12 views

How to update a nested dictionary in DolphinDB?

I'm trying to update values within a nested dictionary in DolphinDB, as shown in the following scipt: d1 = dict( STRING, ANY ) d2 = dict( STRING, ANY ) d2[`d2_K] = 1 d1[`d1_K] = d2 d2[`d2_K] = 3 But ...
Claire's user avatar
  • 310
0 votes
1 answer
12 views

How to merge two dictionaries in DolphinDB?

I would like to merge two dictionaries, “a” and “b”, in DolphinDB. In Python, I can use the ** operator to unpack the two dictionaries, and then use {**a, **b} to create a new dictionary containing ...
carbonhydrate's user avatar
1 vote
1 answer
9 views

How to insert rows with NULL values to a DolphinDB table?

I want to insert a record to a table with columns “A”, “B”, and “C”. In this record, the “B” column contains a NULL value. When I used table(12 as A, NULL as B, 13 as C), I encountered an error: Not ...
carbonhydrate's user avatar
0 votes
1 answer
16 views

How to calculate the element-wise minimum of multiple matrices?

I'm working with multiple M x N matrices in DolphinDB. I want to calculate the maximum/minimum values of elements with the same index across these matrices and return a M x N matrix. For minimum ...
molddd123's user avatar
  • 305
0 votes
1 answer
15 views

How to construct a DolphinDB SQL statement with a multi-output function?

I want to define a UDF to calculate different metrics for one specific column. Can I use such a multi-output function within a SQL statement? For example: tb=table(1 2 3 as `a, 1 1 2 as `b) def ...
Smalllpotato's user avatar
0 votes
1 answer
25 views

Memory overflowed when performing a left join (lj)

for (num in getPeriod()){ // iterate through columns for(col in getCol()){ // factor calculation col_data = sql(select=[sqlCol("symbol"),sqlCol("trade_date"),...
Claire's user avatar
  • 310
1 vote
1 answer
13 views

How to pass a variable to DolphinDB’s panel function as the metrics parameter?

As shown in the following script, I’d like to use a variable containing a list of column names as the metrics parameter in DolphinDB’s panel function. fields=`factor1`factor2`factor3`factor4 res1=...
Eva Gao's user avatar
  • 412
1 vote
1 answer
10 views

Error when using "moving" on a matrix input in DolphinDB

I want to calculate the moving average for each column of a matrix in DolphinDB. But I encountered an error when using higher order function moving(avg, m, w), which is shown in the following figure. ...
Eva Gao's user avatar
  • 412
1 vote
1 answer
7 views

Understanding the output of "createWindowJoinEngine" with parameter window set to 0:0

I'm having trouble comprehending the output of the createWindowJoinEngine function in the context of special windows (window=0:0), as shown in the following diagram. Could you please provide a ...
Eva Gao's user avatar
  • 412
0 votes
1 answer
13 views

How to combine conditions with the "or" operator using DolphinDB's "unifiedExpr"?

I'm trying to utilize DolphinDB's unifiedExpr function to combine multiple conditions with the or operator. When I executed the following script: data=table(1..6 as id1,7..12 as id2) whereCodes = [<...
jinwandalaohu's user avatar
1 vote
1 answer
11 views

Exponentiation with Negative Bases in DolphinDB

As shown in the following script, I want to raise all elements of x to the power of y. x=[-3,-2,3,3,3,4] y=[1/3.0,0.334,0.334,1/3,1/3.0,2] pow(x,y) I noticed that the result contains NULL values for ...
JaneYe's user avatar
  • 181
0 votes
1 answer
11 views

How to calculate the average of the last four records within each group in DolphinDB?

I want to calculate the average of the last four records in each group. I'm wondering if there's an efficient approach to achieve this. Could someone share any tips or methods?
JaneYe's user avatar
  • 181
1 vote
1 answer
14 views

Errors "IO error type 6" and "IO error type 13" occur when DolphinDB Python API is used

When using DolphinDB Python API to query data from DolphinDB database, I often encounter two types of errors: Failed to parse the incoming object with IO error type 6 or Failed to parse the incoming ...
zhihengqu's user avatar
  • 421
0 votes
1 answer
14 views

DolphinDB: the data deduplication effect of using upsert! in a TSDB database

I have learned that the upsert! function performs data deduplication based on its parameter keyColNames, while the TSDB engine deals with duplicated records based on the sort columns of a table. If I ...
JaneYe's user avatar
  • 181
0 votes
1 answer
13 views

How to retrieve the records of the Nth and the last Nth trading days within each period in DolphinDB?

How to retrieve the records of the Nth trading day and the last Nth trading day for each period (such as a year, quarter, or month)?
Smalllpotato's user avatar
1 vote
1 answer
19 views

DolphinDB: How to calculate the difference between two rows in a table?

I have a table containing the four columns “order_book_id”, “date”, “Q”, and “revenue”. I want to perform the following operations: Group the table by “order_book_id” and “date”. Verify if the ...
Smalllpotato's user avatar
0 votes
1 answer
16 views

How to extract values from a vector with a specified step in DolphinDB?

I have two quetions: Does DolphinDB offer any functions or methods to generate an arithmetic sequence of natural numbers or dates? I also want to extract values from a vector with a specified step. ...
zhihengqu's user avatar
  • 421
0 votes
1 answer
15 views

How to merge two tables based on a composite key in DolphinDB?

I have two factor tables, one containing numerical values and the other containing strings. I want to merge the two tables into a single table based on a composite key and return it to users. I have ...
zhihengqu's user avatar
  • 421
0 votes
2 answers
23 views

DolphinDB: Find records only exist in one table but not other

I have two tables, new (shared table) and old (regular in-memory table), each with less than 10,000 rows. Both tables contain columns “a“ and “b“, and values in the "a" columns are unique. I ...
lulunolemon's user avatar
0 votes
1 answer
16 views

How to upload a Python dictionary to DolphinDB with the original order?

I want to upload a dictionary from my Python client to the DolphinDB server using the session.upload(dict) method. I would like to keep the original order of the dictionary after uploading. Does ...
Polly's user avatar
  • 633
0 votes
1 answer
14 views

How to combine real-time and historical data for moving average calculation in DolphinDB?

There is a DolphinDB stream table containing the real-time closing price for a specific financial instrument. I want to combine the real-time data with the historical data stored in a DFS table to ...
Polly's user avatar
  • 633
0 votes
1 answer
9 views

Failed to perform join operation when using metaprogramming in DolphinDB

I want to add custom indicators after certain columns in a table through join operation using SQL metadata code. But when I executed the metacode for execution, an error was reported. Here is the ...
lulunolemon's user avatar
0 votes
1 answer
9 views

How to synchronize changes to modules across DolphinDB cluster nodes?

I made some changes to the functions in a custom module located in the server/modules directory, but the modifications were not automatically synchronized to other nodes in the cluster. Does anyone ...
lulunolemon's user avatar
0 votes
1 answer
14 views

How to configure MemLimitOfQueryResult in DolphinDB?

I want to modify the memory limit for a query result by configuring the related parameter MemLimitOfQueryResult. Does anyone know where I can set this configuration? Is it involved in any file that ...
molddd123's user avatar
  • 305

1
2 3 4 5
16