254 questions
0
votes
0
answers
56
views
Performing product operation on consecutive true segments in a vector
I have two vectors of equal length, one integer vector and one boolean vector. I want to calculate the product of elements in the integer vector where the corresponding boolean vector has consecutive ...
-1
votes
0
answers
16
views
Real-time ranking and percentile calculation on streaming data in DolphinDB
I'm using DolphinDB's stream processing engine to handle a real-time data feed of financial metrics. My requirement is to maintain the latest f1 value for each unique symbol (sym). Every time a new ...
0
votes
1
answer
54
views
How to configure roll function for sliding window on irregular stock data?
I am working with irregular minute-level stock data in DolphinDB and need to implement a specific rolling calculation using the roll function which is new in version 3.00.4.
I have a custom ...
0
votes
1
answer
34
views
Upsert! Operation Throws "A table can't contain duplicate column names" Error
I have a base table A and a result table B in DolphinDB. Table B was initially empty and is used to store calculated results based on table A. When trying to insert the calculated results into table B,...
2
votes
1
answer
61
views
How to join a pivoted table with other tables
I’m working with the DolphinDB Python API to analyze financial data, but I can’t join a table transformed by pivotby() with another table directly. The error says TablePivotBy has no merge attribute. ...
1
vote
1
answer
56
views
How to reverse a DolphinDB table aggregated by group by + toArray back to its original form?
I have an in - memory DolphinDB table created as follows:
ticker = `AAPL`IBM`IBM`AAPL`AMZN`AAPL`AMZN`IBM`AMZN
volume = 106 115 121 90 130 150 145 123 155;
t = table(ticker, volume);
t;
The output of ...
0
votes
0
answers
103
views
How to calculate 1-minute forward moving average
I'm working with stock market snapshot data (3-second intervals) in DolphinDB and need to calculate the 1-minute forward moving average for each data point.
For backward moving average (past 1 minute),...
0
votes
0
answers
20
views
How to resolve metaprogramming function when variable is indirectly assigned a function name?
I'm working with metaprogramming in Python and need to dynamically resolve functions. When a variable is directly assigned a function name, everything works. However, when assigned indirectly via ...
1
vote
0
answers
56
views
Why does SQL meta-programming using macro variables fail
I have an in-memory table defined as follows in DolphinDB:
t = table(2025.01.01 as date, 1 as M01, 2 as M02, 3 as M03, 4 as M04, 5 as M05, 6 as M06, 1 as M07, 2 as M08, 3 as M09, 4 as M10, 5 as M11, 6 ...
-1
votes
1
answer
51
views
Column-wise aggregation of array vectors :calculating mean per “level” for bid/ask data
I am currently working on a data analysis task in DolphinDB where I need to perform column-wise aggregation on array vectors that store level - 10 bid/ask data. Specifically, I have data for bid ...
0
votes
1
answer
58
views
How to achieve Python-like tuple unpacking in DolphinDB SQL to dynamically select columns?
In Python, I can unpack a list into individual variables:
>>> name,age,date = ['Bob',20,'2025-1-1']
>>> name
'Bob'
>>> age
20
>>> date
'2025-1-1'
In DolphinDB, I ...
0
votes
1
answer
34
views
How to group by a column and calculate correlation coefficients between multiple columns?
I'm encountering some issues when trying to perform grouped correlation calculations in DolphinDB. Here's my scenario:
I'm using DolphinDB to calculate correlations between multiple columns in a table....
0
votes
0
answers
32
views
How to implement FIFO queue operations in DolphinDB similar to Python’s deque?
In Python, we can use collections.deque to implement FIFO queue operations. For example:
from collections import deque
queue = deque([1, 2, 3])
print("Initial queue:", queue) # ...
0
votes
1
answer
39
views
How can I parse array-style string data that isn't in standard JSON format?
I have data in an array-style string format that I need to parse and insert into a DolphinDB table, with each nested array element becoming a separate record. Here's an example of the data:
'[["...
-3
votes
1
answer
74
views
How to convert start/end dates to daily sequence per symbol in table?
I want to expand my table based on the two fields, entry_date and remove_date, with the main purpose of facilitating subsequent table joins for date matching.
Below is the expected outcome I hope to ...
0
votes
1
answer
37
views
Calculate cumulative minimum by group based on value changes
Suppose I have a table with simulated data as follows:
time = [09:00:00, 09:00:01, 09:00:02, 09:00:03, 09:00:04, 09:00:05, 09:00:06, 09:00:07, 09:00:08]
b = [101, 103, 105, 110, 129, 134, 123, 111, ...
-3
votes
1
answer
63
views
How to write recursive query for path generation and cycle detection?
I'm working with hierarchical tree data in DolphinDB and need to solve two specific programming challenges:
Generate full paths (concatenated IDs and names) for all nodes, including infinite-level ...
1
vote
1
answer
45
views
How to calculate the maximum drawdown of a stock over a rolling time window?
In quantitative finance, maximum drawdown is a key risk metric that measures the largest decline from a peak to a trough over a period.
I want to calculate the maximum drawdown over the past 10 ...
0
votes
1
answer
21
views
How to compute Inner product between block weights and feature table?
I have two tables:
Table 1 (tb1): Shows which symbols belong to which blocks (1 = belongs, NULL = doesn't belong)
SYMBOL | block1 | block2 | block3 | block4
-------|--------|--------|--------|-------
...
1
vote
1
answer
22
views
The way to compute an aggregate index over a time window [closed]
I want to create a new column in the OHLC table based on the following rule:
If the current 5-minute high is less than or equal to the previous 5-minute high and the current low is greater than or ...
0
votes
1
answer
30
views
Batch processing futures data to exclude non-trading hours
I'm using DolphinDB to process futures data and need to filter out non-trading hours based on different trading time ranges for each futures symbol. Since each futures product has different trading ...
0
votes
1
answer
47
views
How to calculate position state in SQL where each row depends on previous calculation?
Sharing a common DolphinDB use case and solution for data processing.
I have a table of stock observation data recording minute-by-minute indicator states, with two key indicators:
ov95: ...
2
votes
1
answer
55
views
Is there an equivalent of Python's argsort function in DolphinDB?
I'm trying to implement the following functionality in DolphinDB:
Create a dictionary with city names as keys and population counts as values
Find cities with population over 10 million
Sort cities by ...
0
votes
1
answer
29
views
Achieving Grouping to Make the Sum of Each Group's Data Equal
I have a dataset with two columns: sID and sum_count. Now, I need to divide the sID into 5 groups with the requirement that:
The sum of the sum_count column in each group should be as equal as ...
1
vote
1
answer
74
views
How to Efficiently Solve Millions of Independent 2x2 Linear Systems with Augmented Matrices
I need to solve millions to tens of millions of independent 2-variable linear systems represented in augmented matrix form. The input consists of coefficient vectors A, B, C, A', B', C' (each ...