Unable to enable Set a maximum cost per click bid limit and set bid max using google adwords api - google-ads-api

I have created google adCampaigns, adGroups, Keywords, Ads, Locations using Google Adwords API
but I am not able to set "Set a maximum cost per click bid limit" using api
I have used this code to set but it's not getting set
$operations = [];
// Create ad group with the specified ID.
$groupId = $adGroup->getId();
$adGroupNew = new AdGroup();
$adGroupNew->setId($groupId);
$cpcBidMicroAmount = intval($_GET['cpc']) * 1000000;
// Update the CPC bid if specified.
if (!is_null($cpcBidMicroAmount)) {
$bid = new CpcBid();
$money = new Money();
$money->setMicroAmount($cpcBidMicroAmount);
$bid->setBid($money);
$biddingStrategyConfiguration = new BiddingStrategyConfiguration();
$biddingStrategyConfiguration->setBids([$bid]);
$adGroup->setBiddingStrategyConfiguration($biddingStrategyConfiguration);
}
// Create ad group operation and add it to the list.
$operation = new AdGroupOperation();
$operation->setOperand($adGroupNew);
$operation->setOperator(Operator::SET);
$operations[] = $operation;
// Update the ad group on the server.
$adGroupService->mutate($operations);

$biddingScheme = new TargetSpendBiddingScheme();
$bidCeiling = new Money();
$bidCeiling->setMicroAmount($_GET['cpc'] * 1000000);
$biddingScheme->setBidCeiling($bidCeiling);
$spendTarget = new Money();
$spendTarget->setMicroAmount($_GET['cpc'] * 1000000);
$biddingScheme->setSpendTarget($spendTarget);
Do this at Campaign Level to set Bid Max Limit

Related

How to set and apply offset to parent order setting in bracket order for Interactive brokers python api?

From TWS, I can place a bracket order where I can place the takeprofit and stoploss order with a setting "apply offset to parent order". How do one apply same setting "apply offset to parent order" from python API while placing bracket order? My code
parent.orderId = parentOrderId
parent.action = action
parent.orderType = "STP LMT"
parent.totalQuantity = quantity
parent.auxPrice=auxPrice
parent.lmtPrice = limitPrice #upper price when stop trigerred
#The parent and children orders will need this attribute set to False to prevent accidental executions.
#The LAST CHILD will have it set to True,
parent.transmit = False
takeProfit = Order()
takeProfit.orderId = getNextOrderID()
takeProfit.action = "SELL" if action == "BUY" else "BUY"
takeProfit.orderType = "LMT"
takeProfit.totalQuantity = quantity
takeProfit.lmtPrice = takeProfitLimitPrice
takeProfit.parentId = parentOrderId
takeProfit.transmit = False
stopLoss = Order()
stopLoss.orderId = getNextOrderID()
stopLoss.action = "SELL" if action == "BUY" else "BUY"
stopLoss.orderType = "STP"
#Stop trigger price
stopLoss.auxPrice = stopLossPrice
stopLoss.totalQuantity = quantity
stopLoss.parentId = parentOrderId
#In this case, the low side order will be the last child being sent. Therefore, it needs to set this attribute to True
#to activate all its predecessors
stopLoss.transmit = True
I wrote to IB team. Got this reply
Thank you for reaching out to Interactive Brokers.The said settings are related to presets and currently, there are no APIs which can configure the said settings.

Limit of 1024 stream entries in the handler in DolphinDB subscription?

n=1000000
tmpTrades = table(n:0, colNames, colTypes)
lastMinute = [00:00:00.000]
colNames = `time`sym`vwap
colTypes = [MINUTE,SYMBOL,DOUBLE]
enableTableShareAndPersistence(table=streamTable(n:0, colNames, colTypes), tableName="vwap_stream")
go
def calcVwap(mutable vwap, mutable tmpTrades, mutable lastMinute, msg){
tmpTrades.append!(msg)
curMinute = time(msg.time.last().minute()*60000l)
t = select wavg(price, qty) as vwap from tmpTrades where time < curMinute, time >= lastMinute[0] group by time.minute(), sym
if(t.size() == 0) return
vwap.append!(t)
t = select * from tmpTrades where time >= curMinute
tmpTrades.clear!()
lastMinute[0] = curMinute
if(t.size() > 0) tmpTrades.append!(t)
}
subscribeTable(tableName="trades_stream", actionName="vwap", offset=-1, handler=calcVwap{vwap_stream, tmpTrades, lastMinute}, msgAsTable=true)
This is what I wrote to subscribe to the stream. Even though the data ingested to the publishing table vwap_stream is 5000 records per batch, the maximum number ingested to the handler is still 1024. Is there a limit to the subscription?
You can modify the configuration parameter maxMsgNumPerBlock to specify the maximum number of records in a message block and the default value is 1024.
For a standalone mode the configuration file is dolphindb.cfg, and for a clustered mode is cluster.cfg.

how to fetch all the records every minute from a sql table using Apache Flume

I am trying to get all the data from sql table every minute using Flume.
Can someone please suggest what config changes needs to be done?
Configs :
agent.channels = ch1
agent.sinks = kafkaSink
agent.sources = sql-source
agent.channels.ch1.type = memory
agent.channels.ch1.capacity = 1000000
agent.sources.sql-source.channels = ch1
agent.sources.sql-source.type = org.keedio.flume.source.SQLSource
# URL to connect to database
agent.sources.sql-source.connection.url = jdbc:sybase:Tds:abcServer:4500
# Database connection properties
agent.sources.sql-source.user = user
agent.sources.sql-source.password = XXXXXXX
agent.sources.sql-source.table = person
agent.sources.sql-source.columns.to.select = *
# Increment column properties
agent.sources.sql-source.incremental.column.name = person_id
# Increment value is from you want to start taking data from tables (0 will import entire table)
agent.sources.sql-source.incremental.value = 0
# Query delay, each configured milisecond the query will be sent
agent.sources.sql-source.run.query.delay=1000
# Status file is used to save last readed row
agent.sources.sql-source.status.file.path = /dump/apache-flume-1.6.0-bin
agent.sources.sql-source.status.file.name = sql-source.status
Change value of agent.sources.sql-source.run.query.delay to 60000..

Set new placement in Group Criterion via API

How can I add new placement (website, for example www.example.com) in AdGroup using AdWords API?
I have found
AdGroupCriterionService->mutate,
but I need to know ID of website
$adGroupCriterion->criterion = new Criterion($criterionId);
So my question:
How I can found ID for any website or exist another way to add new Placement in AdGroup?
I found an answer:
$adGroupService = $user->GetService('AdGroupCriterionService', 'v201509');
$AdGroupCriterionOperation = new AdGroupCriterionOperation();
$AdGroupCriterionOperation->operator = 'ADD';
$AdGroupCriterion = new BiddableAdGroupCriterion();
$AdGroupCriterion->adGroupId = $adGroupId;
$AdGroupCriterion->criterionUse = 'BIDDABLE';
$AdGroupCriterion->AdGroupCriterionType = 'PLACEMENT';
$Placement = new Placement();
$Placement->id = null;
$Placement->CriterionType = 'PLACEMENT';
$Placement->type = 'PLACEMENT';
$Placement->url = $url;
$AdGroupCriterion->criterion = $Placement;
$AdGroupCriterionOperation->operand = $AdGroupCriterion;
$operations = array($AdGroupCriterionOperation);
// Make the mutate request.
$result = $adGroupService->mutate($operations);

FedEx Webservice for printing Multiple shipping labels

I am trying to connect to the FedEx shipping webservice v8.
Everything works fine when I only have one RequestedPackageLineItems set. When I add two items I get the following error.
"Invalid package count or invalid package sequence number."
My Code is as follows
ProcessShipmentRequest request = CreatePendingShipmentRequest();
ShipService service = new ShipService();
ProcessShipmentReply reply = service.processShipment(request);
...
private static ProcessShipmentRequest CreatePendingShipmentRequest()
{
ProcessShipmentRequest request = new ProcessShipmentRequest();
request.WebAuthenticationDetail = new WebAuthenticationDetail();
request.WebAuthenticationDetail.UserCredential = new WebAuthenticationCredential();
request.WebAuthenticationDetail.UserCredential.Key = "XXX";
request.WebAuthenticationDetail.UserCredential.Password = "XXX";
request.ClientDetail = new ClientDetail();
request.ClientDetail.AccountNumber = "XXX";
request.ClientDetail.MeterNumber = "XXX";
request.TransactionDetail = new TransactionDetail();
request.TransactionDetail.CustomerTransactionId = "*** Ground Domestic Shipping Request v8 using C# ***";
request.Version = new VersionId();
//Inside this method I set request.RequestedShipment.PackageCount = "2";
SetShipmentDetails(request);
SetPackageLineItems(request);
return request;
}
private static void SetPackageLineItems(ProcessShipmentRequest request)
{
request.RequestedShipment.RequestedPackageLineItems = new RequestedPackageLineItem[2];
request.RequestedShipment.RequestedPackageLineItems[0] = new RequestedPackageLineItem();
request.RequestedShipment.RequestedPackageLineItems[0].SequenceNumber = "1";
request.RequestedShipment.RequestedPackageLineItems[0].Weight = new Weight();
request.RequestedShipment.RequestedPackageLineItems[0].Weight.Value = 50.0M;
request.RequestedShipment.RequestedPackageLineItems[0].Weight.Units = WeightUnits.LB;
request.RequestedShipment.RequestedPackageLineItems[0].ItemDescription = "Item";
request.RequestedShipment.RequestedPackageLineItems[0].Dimensions = new Dimensions();
request.RequestedShipment.RequestedPackageLineItems[0].Dimensions.Length = "108";
request.RequestedShipment.RequestedPackageLineItems[0].Dimensions.Width = "5";
request.RequestedShipment.RequestedPackageLineItems[0].Dimensions.Height = "5";
request.RequestedShipment.RequestedPackageLineItems[0].Dimensions.Units = LinearUnits.IN;
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences = new CustomerReference[3];
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[0] = new CustomerReference();
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[0].CustomerReferenceType = CustomerReferenceType.CUSTOMER_REFERENCE;
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[0].Value = "[LOT NUMBER]";
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[1] = new CustomerReference();
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[1].CustomerReferenceType = CustomerReferenceType.INVOICE_NUMBER;
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[1].Value = "45646";
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[2] = new CustomerReference();
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[2].CustomerReferenceType = CustomerReferenceType.P_O_NUMBER;
request.RequestedShipment.RequestedPackageLineItems[0].CustomerReferences[2].Value = "456446";
request.RequestedShipment.RequestedPackageLineItems[1] = new RequestedPackageLineItem();
request.RequestedShipment.RequestedPackageLineItems[1].SequenceNumber = "2";
request.RequestedShipment.RequestedPackageLineItems[1].Weight = new Weight();
request.RequestedShipment.RequestedPackageLineItems[1].Weight.Value = 50.0M;
request.RequestedShipment.RequestedPackageLineItems[1].Weight.Units = WeightUnits.LB;
request.RequestedShipment.RequestedPackageLineItems[1].ItemDescription = "Item";
....
}
Found out how to do this.
In order to get multiple shipping labels into one pdf the process is as follows.
Create a request
Fill in the shipping info
Post and get a reply.
Save that replay and the byte array and MasterShippingID
Create a new request and assign the master shipping id to it.
Added shipping weight and dimensions
Post and get reply
Save byte array with the other
Continue until all shipments are generated (max 200 per master shipping id)
Merge all the pdfs returned from FedEx into one pdf.
Do a happy dance.
A simpler approach, (though there is a cost) is the Shiprush SDK. It lets you build a single XML block and let ShipRush do all the funny stuff with fedex (or whoever).
They also support their tool.

Resources